Skip to content

fix(scheduled-tasks): reset an explicitly null assistant to lead_agent - #6185

Merged
WillemJiang merged 1 commit into
bytedance:mainfrom
lakers-abing:codex/scheduled-task-null-assistant
Oct 2, 2026
Merged

WillemJiang merged 1 commit into
bytedance:mainfrom
lakers-abing:codex/scheduled-task-null-assistant

Conversation

@lakers-abing

Copy link
Copy Markdown
Contributor

Related: #5288.

Why

PATCHing a scheduled task pinned to a custom agent with {"assistant_id": null} succeeds but silently retains the custom agent. model_dump(exclude_none=True) drops the explicit field before the shared resolver can map it to lead_agent, although creation already supports that default.

What changed

An explicitly supplied null now resets the task to lead_agent. Omitting assistant_id preserves the current pin, even if its custom agent has been deleted. Other null update fields keep their existing ignored behavior. Both cases avoid loading the previous agent.

The change uses Pydantic's model_fields_set and the existing assistant resolver. Tests cover the route and actual SQLite persistence. README and Gateway guidance document the PATCH semantics; the guidance replaces a duplicate nginx-routing sentence to remain within its existing size budget.

Surface area

  • Frontend UI
  • Backend API — scheduled-task PATCH handling
  • Agents / LangGraph
  • Sandbox
  • Skills
  • Dependencies
  • Default behavior change — an explicit null PATCH now resets the pin rather than being ignored
  • Docs / tests / CI only

Bug fix verification

  • Regression path: backend/tests/test_scheduled_task_router_behavior.py.
  • Before the handler fix, the explicit-null route and SQLite regressions failed: 2 failed, 49 passed.
  • After the fix, both regressions pass. The omitted-field case still preserves a deleted custom agent's pin.

Validation

From backend/:

  • Related router, scheduler, dispatch and authorization tests: 124 passed.
  • make lint: passed; Ruff formatting check covered 1,744 files.
  • make test-blocking-io: 189 passed, both before and after.
  • All four offline backend shards, using make test with pytest-split's least_duration strategy: 22,096 passed; optional integrations and live tests skipped. The first shard was rerun after adjusting the guidance note's location/size and passed.
  • pytest tests/test_agent_guidance_check.py -q: 13 passed.
  • python ../scripts/check_agent_guidance.py --base-ref origin/main --head-ref HEAD: 0 errors; existing soft-size warnings remain.
  • git diff --check: passed.

The initial full baseline additionally failed 22 web-fetch cases because this host lacked Node/Readability.js. After adding Node to the test PATH and installing ReadabiliPy's JavaScript dependencies in the local virtual environment, that unchanged test file passed all 48 cases. No dependency or lockfile changes are included in this PR.

AI assistance

Tool(s) used: Codex.

How you used it: Codex inspected the original agent-pinning issue/PR and current code, checked for duplicate contributions, wrote the handler fix, regression tests and documentation, and ran the validation above.

  • I've read and understand every line of this change and take responsibility for it — it's not unreviewed AI output.

@github-actions github-actions Bot added area:backend Gateway / runtime / core backend under backend/ area:docs Documentation and Markdown only needs-validation Touches front/back contract surface; needs real-path validation risk:high High risk: backend API, agents, sandbox, auth, deps, CI size/S PR changes 20-100 lines labels Oct 2, 2026

@willem-bd willem-bd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against head 63958b5 — no issues found. The switch from "assistant_id" in updates to "assistant_id" in body.model_fields_set is correct Pydantic v2 usage for FastAPI-parsed bodies, and resolve_scheduled_task_assistant_id(None) returns lead_agent before any load_agent_config call, so both the explicit-null and omitted paths avoid loading the previous agent as claimed. The SQL repository's update setattr loop persists the injected updates["assistant_id"], and the new tests cover both the route-level behavior and real SQLite persistence for the explicit-null and omitted cases, each asserting the loader is never called. Docs match the implemented semantics, and the nginx-routing sentence removed from backend/app/gateway/AGENTS.md remains covered by backend/AGENTS.md (runtime exposition and the /api/langgraph/* rewrite note), so no information is lost.

@WillemJiang WillemJiang added this to the 2.2.0 milestone Oct 2, 2026
@WillemJiang
WillemJiang merged commit fafe904 into bytedance:main Oct 2, 2026
19 checks passed
makutaku pushed a commit to altakleos/hartmesh that referenced this pull request Nov 3, 2026
)

Co-authored-by: lakers-abing <[email protected]>

HartMesh: code applies cleanly; doc conflicts keep HartMesh's text plus only this commit's lines; changelog hunks dropped.

(cherry picked from upstream commit fafe904)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GujxPsQnaanjqeHp5fwAUn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Gateway / runtime / core backend under backend/ area:docs Documentation and Markdown only needs-validation Touches front/back contract surface; needs real-path validation risk:high High risk: backend API, agents, sandbox, auth, deps, CI size/S PR changes 20-100 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants