Skip to content

agentHost: chat-address the operational agent methods (collapse default/peer branches)#323967

Merged
sandy081 merged 6 commits into
mainfrom
agents/mc-chataddr-ops-chat-addressed-v2
Jul 2, 2026
Merged

agentHost: chat-address the operational agent methods (collapse default/peer branches)#323967
sandy081 merged 6 commits into
mainfrom
agents/mc-chataddr-ops-chat-addressed-v2

Conversation

@sandy081

@sandy081 sandy081 commented Jul 1, 2026

Copy link
Copy Markdown
Member

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. _changeModel having two branches plus an optional chat?).

What

Makes the internal operational methods of all three harnesses uniformly chat-addressed:

  • sendMessage / abort / changeModel / changeAgent no longer take a separate session URI or an optional chat?. 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.
  • Added AgentSessionEntry.resolveChat() for the uniform default/peer lookup.
  • Codex (single-chat) resolves the addressed chat to its single session.

Scope

  • Behavior-preserving: no persisted-format, wire-protocol, or IAgentChats interface changes. common/state/protocol/* untouched.
  • Session-lifecycle methods (createSession/disposeSession/listSessions/getSessionMetadata) are intentionally out of scope; that is a separate, larger architectural change.

Validation

  • transpile: pass
  • scripts/test.sh --grep "AgentService|CopilotAgent|ClaudeAgent|CodexAgent|AgentSideEffects|AgentHostStateManager": 757 passing, 17 pending
  • typecheck-client: pass
  • valid-layers-check: pass

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 23:18
@sandy081
sandy081 enabled auto-merge (squash) July 1, 2026 23:20

Copilot AI 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.

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 / changeAgent to 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

Comment thread src/vs/platform/agentHost/node/agentPeerChats.ts
@sandy081
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

sandy081 and others added 4 commits July 2, 2026 01:43
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
sandy081 marked this pull request as ready for review July 2, 2026 00:13
@sandy081
sandy081 enabled auto-merge (squash) July 2, 2026 00:13
dmitrivMS
dmitrivMS previously approved these changes Jul 2, 2026
…s-chat-addressed-v2

# Conflicts:
#	src/vs/platform/agentHost/node/copilot/copilotAgent.ts
@sandy081
sandy081 merged commit 9d557c6 into main Jul 2, 2026
29 checks passed
@sandy081
sandy081 deleted the agents/mc-chataddr-ops-chat-addressed-v2 branch July 2, 2026 01:49
@vs-code-engineering vs-code-engineering Bot added this to the 1.128.0 milestone Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants