Skip to content

refactor: separate loader defaults, bootstrap runtime opts, narrow chatserver contract - #4533

Merged
dgageot merged 3 commits into
mainfrom
worktree-board-ab1e1e9ba58a2970
Oct 7, 2026
Merged

dgageot merged 3 commits into
mainfrom
worktree-board-ab1e1e9ba58a2970

Conversation

@dgageot

@dgageot dgageot commented Oct 7, 2026

Copy link
Copy Markdown
Member

teamloader/defaults.Opts always registered global runtime factories (jscommands.Register(), runtime.RegisterHarness) as a side effect of asking for loader defaults, which made it impossible to build a loader's options without also mutating process-wide runtime state. The model-switcher and budget wiring that turns a teamloader.LoadResult into runtime options was also duplicated between the CLI's initial run and its spawned sub-runtimes, and chatserver depended on the full runtime.Runtime interface even though it only ever drives three methods of it.

This splits defaults.Opts() into a registration-free defaults.LoaderOpts() plus the existing Opts(), which now just calls LoaderOpts() after doing its registration as before — so nothing changes for existing callers. It adds a pkg/bootstrap package whose RuntimeOpts(loadResult, runConfig) assembles the ModelSwitcherConfig, shared models.dev store, and budget options from a LoadResult; cmd/root/run.go now calls it from both the initial and spawned runtime paths instead of duplicating the assembly. Finally, chatserver defines a private runtimeRunner interface with just RunStream, Resume, and ResumeElicitation, and the agent loop, server handlers, and runtime pool are narrowed to that contract instead of the full runtime.Runtime.

Public interfaces, HTTP schemas, and serving budget behavior are unchanged; this is a pure internal reshuffle with new regression tests for bootstrap, defaults.LoaderOpts, and the narrowed chatserver contract (including a minimal fake runtime). Docs (docs/guides/go-sdk/index.md) and the dependency guard test (e2e/dependencies_test.go) were updated to reflect the new pkg/bootstrap package; no go.mod/go.sum changes were needed.

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 7, 2026 09:17
@dgageot
dgageot added this pull request to the merge queue Oct 7, 2026
@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/docs Documentation changes area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/refactor PR refactors code without behavior change labels Oct 7, 2026
Merged via the queue into main with commit 79e8175 Oct 7, 2026
22 checks passed
@dgageot
dgageot deleted the worktree-board-ab1e1e9ba58a2970 branch October 7, 2026 09:34
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/docs Documentation changes area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants