Skip to content

refactor(scheduler): scope worker lifetime to blocking Run(ctx) - #4705

Merged
aheritier merged 6 commits into
mainfrom
worktree-board-64dda7a3273b6e47
Oct 22, 2026
Merged

aheritier merged 6 commits into
mainfrom
worktree-board-64dda7a3273b6e47

Conversation

@dgageot

@dgageot dgageot commented Oct 22, 2026

Copy link
Copy Markdown
Member

Why

The scheduler's worker lifetime was owned by separate Start/Stop calls,
which made lifecycle ownership (who starts, who stops, who owns restarts)
hard to reason about across nested tools and forked sessions, and left gaps
where completion/restart/probe signals could race or be lost.

What

  • Replace Start/Stop worker ownership with a single blocking
    Run(ctx) on the scheduler; the worker's lifetime is now scoped to that
    call and tied to context cancellation.
  • Introduce tools.Runnable as the canonical host bridge for this model, and
    migrate all callers: normal and additional toolsets, Code Mode, the
    fork-skill path, and raw session extras.
  • Make team/runtime cancellation and join explicit instead of implicit via
    Stop.
  • Fix nested lifecycle correctness: worker completion propagation, restart
    ownership, and probe non-blocking behavior, and distinguish lifecycle
    contention from actual signal loss.

Validation

  • Independent iterative deep review — final verdict clean.
  • CI=true task build, task test, task lint all pass.
  • Affected-package race tests (tools, codemode, agent, runtime,
    teamloader, scheduler) repeated 10x.
  • Cross builds verified for Windows amd64 and JS/WASM.
  • SplitGoroutineLifetime audit via temporary overlay: 9 warnings, down
    from 10 (scheduler's removed); the checker remains disabled globally.

No further code changes intended in this PR.

Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot
dgageot requested a review from a team as a code owner October 22, 2026 14:53
@aheritier aheritier added area/agent For work that has to do with the general agent loop/agentic features of the app area/core Core agent runtime, session management area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/refactor PR refactors code without behavior change labels Oct 22, 2026
@aheritier
aheritier added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit b932d65 Oct 22, 2026
22 checks passed
@aheritier
aheritier deleted the worktree-board-64dda7a3273b6e47 branch October 22, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent For work that has to do with the general agent loop/agentic features of the app area/core Core agent runtime, session management area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/tools For features/issues/fixes related to the usage of built-in and MCP tools kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants