Skip to content

agentHost: open #chat chips on the connection that owns the chat - #341313

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/chat-chip-connection-authority
Oct 13, 2026
Merged

Sandeep Somavarapu (sandy081) merged 1 commit into
mainfrom
agents/chat-chip-connection-authority

Conversation

@sandy081

Copy link
Copy Markdown
Member

Goal

A #chat chip now opens the referenced chat on the agent host that owns it. Before this change, the chip's agent-host-session:// link had no connection authority:

  • A chip for a chat on a remote host could open as a local session, because provider-scheme owners were treated as local.
  • When a native session id existed on more than one connection, a chip could open the session on the wrong connection.

This was raised in a review of #341191 and tracked as a follow-up.

Changes

  • resolveAgentHostChatOwner returns the authority of the connection where it found the owner. The field is required.
    • Remote host: agentHostAuthority(address).
    • Local host: AMBIENT_AGENT_HOST_AUTHORITY (local), the same value the chat copy actions already use.
    • Bare session resource: undefined.
  • buildOpenSessionLinkForChat(owner, chat, defaultChat, connectionAuthority) takes the authority as a required parameter and passes it to buildOpenSessionLinkUri.
  • The chip passes the owner's authority.
  • These callers pass undefined:
    • host callers (chat attachment links, markdown plan links), because a host links its own sessions;
    • the sessions provider's session-comparison reference, which only the host's get_session_context tool reads.
  • No opener changes. Both openers already route connectionAuthority:
    • the editor window looks the session up by authority;
    • the Agents window filters on the session identity's authority.

Behavior notes

  • In the editor window, a local chip link (connectionAuthority=local) now resolves through the session registry, listing the local host's sessions on a miss, instead of building agent-host-<provider>:/id directly. This is the same path that local links from the chat copy actions already take.

How to test

  1. Connect a remote agent host whose sessions include a session id that also exists locally.
  2. In a chat input, add a #chat reference to a chat on the remote host, then click the chip. It opens on the remote host.
  3. Do the same for a local chat with the same native id. It opens the local session.

Validation

All on a clean tree at 8e5fac25ec9, based on main 3fd165bbb0d.

Command Result
npm run typecheck-client 0 errors
npm run eslint -- <10 changed files> clean
npm run valid-layers-check pass
npm run hygiene pass
./scripts/test.sh (chatReferenceAttachment, openSessionLink, editor-window and Agents-window openSessionLinkOpener, localAgentHostSessionsProvider) 507 passing, 11 pending (main: 504 / 11)
node test/unit/node/index.js (openSessionLink, agentSideEffects, chatContributions) 419 passing

New tests:

  • End-to-end from chip to opener, in both the editor window and the Agents window, with the same native id on the local and remote hosts. The remote chip opens the remote session and the local chip opens the local one.
  • buildOpenSessionLinkForChat with an authority.
  • The owner lookup returns the right authority on every path.

Each test was mutation-checked: dropping local, dropping the chip's authority, ignoring the authority in the link helper, or dropping it on the records path makes tests fail.

The chat chip resolved the owning session across the local and remote hosts
but dropped which host it found it on, so its `agent-host-session://` link
was unqualified: provider-scheme owners opened as local sessions and a native
session id shared by two hosts could open on the wrong one.

The owner lookup now returns the owning connection's authority (`local` for
the local host, the remote's agent host authority otherwise) and
`buildOpenSessionLinkForChat` takes a required connection authority that it
writes into the link. Host-built links (attachment links, plan rich links)
and the session-context reference pass `undefined`: they link the host's own
sessions.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 15:21
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.143.0 milestone Oct 13, 2026

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.

🟡 Changes recommended

Identical default-chat URIs on local and remote hosts still resolve to the local host because ownership lookup is local-first.

1 open finding
What changed in this PR

Routes #chat chips through the Agent Host connection that owns the referenced chat.

Changes:

  • Adds connection authority to chat-owner resolution and open-session links.
  • Updates host and Sessions callers.
  • Adds local/remote collision regression tests.
File Description
chatReferenceAttachment.test.ts Tests owner resolution and chip routing.
chatAttachmentWidgets.ts Passes owner authority into links.
agentHostChatOwner.ts Returns the owning connection authority.
localAgentHostSessionsProvider.test.ts Updates helper calls.
baseAgentHostSessionsProvider.ts Keeps host-consumed references unqualified.
openSessionLinkOpener.test.ts Tests Agents-window routing.
openSessionLink.test.ts Tests authority-qualified links.
markdownPlanRichLinksContribution.ts Updates host link creation.
agentSideEffects.ts Updates attachment link creation.
openSessionLink.ts Adds authority to chat-link construction.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sandy081
Sandeep Somavarapu (sandy081) merged commit d414bca into main Oct 13, 2026
55 of 57 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/chat-chip-connection-authority branch October 13, 2026 16:09
Don Jayamanne (DonJayamanne) added a commit that referenced this pull request Oct 13, 2026
…xploration-vscode

* origin/main: (40 commits)
  MSRC fixes (#341342)
  chat: render input attachments for the input model's session (#341350)
  chat: center subagent tool activity hooks (#341258)
  Manage Copilot plugin marketplaces through Agent Host (#341301)
  fix: linux setuid sandbox helper permissions (#341292)
  agentHost: resolve #chat chips on the host of the chat that shows them (#341332)
  [Perf] agentHost: limit archived sessions over Mission Control (#341327)
  Remember expanded state for "Other Models" in model picker (#341335)
  Offer Stop for copilot detached background shells  (#341310)
  agentHost: allow inherited peer chats to move workspaces (#341317)
  [Perf] agentHost: reduce Mission Control relay overhead (#341223)
  Fix Customizations modal spacing (#341144)
  Fix dependency cycle in QuickInputService and EditorResolverService (#341321)
  Fix Explorer refresh on restoring deleted workspace root folder (#341323)
  chat: Share and rate-limit core utility model requests (#340100)
  agentHost: open #chat chips on the connection that owns the chat (#341313)
  Fix flaky StorageMainService tests by awaiting storage warm-up (#341305)
  agentHost: record the default chat role instead of reading the default chat URI shape (#341293)
  welcome: preserve tab icon color with Modern Icons
  Fix flaky test in diskFileSystemProvider.test.ts (#341304)
  ...

# Conflicts:
#	src/vs/platform/agentHost/node/agentService.ts
#	src/vs/platform/agentHost/node/protocolServerHandler.ts
#	src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts
#	src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts
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