agentHost: chat-address the operational agent methods (collapse default/peer branches)#323967
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the agent-host “operational” IAgent.chats methods to be uniformly chat-addressed across the Copilot, Claude, and Codex harnesses, removing the prior branching between “default chat vs peer chat” and centralizing chat normalization + session derivation.
Changes:
- Copilot + Claude: introduce a uniform chat-normalization/context-resolution path (session URI ⇢ default chat URI, session derivation via chat URI, resolved default/peer lookup via the per-session chat map).
- Copilot + Claude: update
sendMessage/abort/changeModel/changeAgentto operate on the addressed chat with a consistent resolved-chat context (including unified peer/default model & agent change behavior where applicable). - Codex: resolve an addressed chat URI back to Codex’s single session and route existing operations through that mapping.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Normalizes chat addressing and routes operational chat methods through a single derived (session, resolved chat) context. |
| src/vs/platform/agentHost/node/claude/claudeAgent.ts | Mirrors Copilot’s chat-addressed operational surface and unifies default/peer handling via a resolved chat context. |
| src/vs/platform/agentHost/node/codex/codexAgent.ts | Adds chat→session resolution so Codex’s single-chat harness can accept chat-addressed calls. |
| src/vs/platform/agentHost/node/agentPeerChats.ts | Adds AgentSessionEntry.resolveChat() returning both resolved session instance and default/peer identity. |
| src/vs/platform/agentHost/MULTI_CHAT_ARCHITECTURE.md | Updates architecture docs to describe the new resolveChat()-based default/peer resolution approach. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Low
sandy081
marked this pull request as draft
July 1, 2026 23:23
auto-merge was automatically disabled
July 1, 2026 23:24
Pull request was converted to draft
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… CI) The chat-addressing refactor removed the agents' tolerance for addressing the default chat by its session URI (the AHP convention: default chat URI == session URI). This broke integration tests that address the default chat by the session URI (Malformed AHP chat URI) and restore via the mock agent (0 restored turns). - Claude/Copilot `_getChatContext`: accept either a chat channel URI or a bare session URI, normalizing to the default-chat URI in the single resolution chokepoint (not re-derived per operational method). Codex already tolerant. - MockAgent.getSessionMessages: normalize a default-chat channel URI back to the session URI, mirroring the real agents. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
onDidEndChat was declared by Claude and Copilot but never fired: a completed subagent chat stays live and is removed only on session teardown (via a direct removeChat), so subagent_completed intentionally has no end event. Remove the unused channel end-to-end — the agents' emitters, the optional IAgent.onDidEndChat member, the orchestrator subscription + _onChatEnded handler, and the synthetic test. onDidSpawnChat (which is fired) remains as a spawn-only membership channel. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address CCR feedback: `session` overwhelmingly means the owning session URI in this codebase, so `IResolvedAgentChat.session` (the resolved chat session instance) was easy to misread. Rename to `chatSession` and update the two call sites in claudeAgent.ts / copilotAgent.ts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sandy081
marked this pull request as ready for review
July 2, 2026 00:13
sandy081
enabled auto-merge (squash)
July 2, 2026 00:13
dmitrivMS
previously approved these changes
Jul 2, 2026
…s-chat-addressed-v2 # Conflicts: # src/vs/platform/agentHost/node/copilot/copilotAgent.ts
dmitrivMS
approved these changes
Jul 2, 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.
Follow-up to #323950. Addresses the Claude-agent owner's feedback that the operational IAgent methods branch on "default chat vs peer chat" (e.g.
_changeModelhaving two branches plus an optionalchat?).What
Makes the internal operational methods of all three harnesses uniformly chat-addressed:
sendMessage/abort/changeModel/changeAgentno longer take a separatesessionURI or an optionalchat?. They take the chat URI, normalize the default-chat URI once, derive the session from the chat URI, and resolve the live chat (default or peer) through the uniform per-session chat map.changeModel/changeAgent: the previous two-branch storage asymmetry (default chat writes the session metadata overlay; peer writes its own backing) is unified via a single resolved-chat context; peer model changes still update their backing/providerData.AgentSessionEntry.resolveChat()for the uniform default/peer lookup.Scope
IAgentChatsinterface changes.common/state/protocol/*untouched.Validation
scripts/test.sh --grep "AgentService|CopilotAgent|ClaudeAgent|CodexAgent|AgentSideEffects|AgentHostStateManager": 757 passing, 17 pendingCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com