Refactor AgentService instantiation - #331861
Merged
roblourens merged 15 commits intoAug 20, 2026
Merged
Conversation
Create an agent-host application DI scope, construct AgentService through it, and remove child-to-parent service re-exports. Update tests to use the production construction path. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update newly added AgentService tests to use the DI-backed test factory. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use explicit bootstrap and application names for service collections and instantiation services. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use one strict DI scope and centralize common base and provider service setup for both Agent Host entry points. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve the single-scope bootstrap while integrating Agent Host debug-log collection. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose one runtime factory that owns common file, session, DI, AgentService, diagnostics, and optional provider infrastructure initialization. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Integrate Agent Host proxy configuration ownership and terminal-chat session metadata with the streamlined runtime factory. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Construct and register the AgentService core and collaborator graph outside AgentService, use one guarded initialization step for genuine back-references, and replace the test-only clock injection with virtual timers. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve external AgentService composition while integrating state-file resolution, catalog hardening, durable Agent Merge monitoring, and GitHub MCP support. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve external AgentService composition while integrating cold-start state-file resolution and session artifact tooling. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove optional provider-infrastructure setup, make BYOK policy explicit, and defer Claude SDK environment mutation until first use. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> # Conflicts: # src/vs/platform/agentHost/node/agentService.ts # src/vs/platform/agentHost/test/node/agentService.test.ts
Keep mock-provider configuration distinct from host-owned worktree settings and use an existing workspace for permission containment tests. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors Agent Host startup around a shared, strict dependency-injection composition root.
Changes:
- Centralizes runtime and
AgentServicecollaborator construction. - Reuses the runtime graph across utility-process, standalone, and test hosts.
- Updates tests, fixtures, timer handling, and lazy Claude SDK environment setup.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/browser/chatDropdownPill.ts |
Removes trailing whitespace. |
src/vs/platform/agentHost/test/node/protocol/toolApproval.integrationTest.ts |
Uses real containment roots in approval tests. |
src/vs/platform/agentHost/test/node/protocol/sessionConfig.integrationTest.ts |
Separates mock-provider configuration keys. |
src/vs/platform/agentHost/test/node/mockAgent.ts |
Updates mock configuration and permission paths. |
src/vs/platform/agentHost/test/node/claudeAgent.test.ts |
Tests composition helper and lazy environment setup. |
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts |
Uses the shared test composition helper. |
src/vs/platform/agentHost/test/node/agentServiceTestUtils.ts |
Adds strict-DI test service construction. |
src/vs/platform/agentHost/test/node/agentService.test.ts |
Migrates construction and uses fake timers. |
src/vs/platform/agentHost/test/node/agentHostBootstrap.test.ts |
Verifies renderer-BYOK runtime construction. |
src/vs/platform/agentHost/node/claude/claudeAgentSdkService.ts |
Defers environment mutation until SDK use. |
src/vs/platform/agentHost/node/agentServiceComposition.ts |
Defines the complete collaborator graph. |
src/vs/platform/agentHost/node/agentService.ts |
Accepts DI-managed core services and initialization. |
src/vs/platform/agentHost/node/agentMergeController.ts |
Exports composition options. |
src/vs/platform/agentHost/node/agentHostServerMain.ts |
Adopts the shared runtime bootstrap. |
src/vs/platform/agentHost/node/agentHostMain.ts |
Adopts the shared runtime bootstrap. |
src/vs/platform/agentHost/node/agentHostBootstrap.ts |
Builds the unified strict-DI runtime. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 15/16 changed files
- Comments generated: 0
- Review effort level: Balanced
(Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> # Conflicts: # src/vs/platform/agentHost/node/agentService.ts
roblourens
marked this pull request as ready for review
August 20, 2026 23:32
roblourens
enabled auto-merge (squash)
August 20, 2026 23:32
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: TylerLeonhardtMatched files:
|
roblourens
marked this pull request as draft
August 20, 2026 23:34
auto-merge was automatically disabled
August 20, 2026 23:34
Pull request was converted to draft
Keep the AgentService DI refactor focused by leaving the existing Claude SDK environment setup unchanged. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
marked this pull request as ready for review
August 20, 2026 23:41
roblourens
enabled auto-merge (squash)
August 20, 2026 23:41
Connor Peet (connor4312)
approved these changes
Aug 20, 2026
roblourens
deleted the
roblou/agents/refactor-agentservice-instantiation
branch
August 20, 2026 23:59
Comment on lines
+484
to
498
| private _sideEffects!: AgentSideEffects; | ||
| private _agentMergeController!: AgentMergeController; | ||
| /** Owns static / per-turn changeset compute, publish, persist, restore. */ | ||
| private readonly _changesets: IAgentHostChangesetService; | ||
| private _changesets!: IAgentHostChangesetService; | ||
| /** Shared active changeset subscription registry. */ | ||
| private readonly _changesetSubscriptions: IAgentHostChangesetSubscriptionService; | ||
| /** Owns changeset operation contributions and handler activation. */ | ||
| private readonly _changesetOperationService: IAgentHostChangesetOperationService; | ||
| private readonly _reviewService: IAgentHostReviewService; | ||
| private _changesetOperationService!: IAgentHostChangesetOperationService; | ||
| private _reviewService!: IAgentHostReviewService; | ||
| /** Owns AgentService-side orchestration of the changeset feature. */ | ||
| private readonly _changesetCoordinator: AgentHostChangesetCoordinator; | ||
| private _changesetCoordinator!: AgentHostChangesetCoordinator; | ||
| /** Owns session git-state probing and git-backed catalogue decoration. */ | ||
| private readonly _gitStateService: IAgentHostGitStateService; | ||
| private _gitStateService!: IAgentHostGitStateService; | ||
| /** Manages PTY-backed terminals for the agent host protocol. */ | ||
| private readonly _terminalManager: AgentHostTerminalManager; | ||
| private _terminalManager!: AgentHostTerminalManager; | ||
| /** Persists host-injected `/rename` / `!command` turns for restore & fork/truncate. */ |
Member
Author
There was a problem hiding this comment.
Yeah, all these will go away with the next round or two
TylerLeonhardt
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentServicethrough dependency injection in one strict Agent Host service scopecreateAgentHostRuntimecomposition function that always builds the same complete shared service graphagentServiceComposition.ts;AgentServicehas no service collection, instantiation service,services.set,createInstance, or service-class constructionAgentServicerunWithFakedTimersValidation
npm run typecheck-clientnpm run core-cinpm run valid-layers-checknpm run compile(Written by Copilot)