Let agent host sessions tolerate hosts that differ from the client - #332456
Merged
Osvaldo Ortega (osortega) merged 4 commits intoAug 25, 2026
Merged
Conversation
Three ways a session against a host that is older than, or shaped differently from, the client would fail outright. Customizations changed from an `enabled` boolean to list-shaped `enablement` in protocol 0.8.0. A host below that version expects the superseded shape and rejects the whole request with `invalid params: missing field 'enabled'`, which fails `createSession` and leaves no session at all. Client-published customizations are now dropped for such a host, degrading to a session without them. The gate is applied on both paths that publish an active client, since reconciliation republishes it after creation. A host can also address only certain working directory schemes. A remote workspace may be the repository itself (`https://github.com/owner/repo`) while the agent runs against a checkout on its own disk, and sending the remote URI fails `createSession` with `unsupported scheme 'https'; expected 'file'`. Working directories the host cannot address are now dropped, falling back to letting it choose its own. The host's reported `defaultDirectory` names the scheme it can address, so this adapts per host rather than hardcoding one. Finally, a session the host has never heard of rendered "Couldn't open session". A provider can legitimately address a session id before the host knows it, with `createSession` bringing it into being, so the banner is now suppressed for `NotFound` specifically. Genuine open failures still render, which a test covers directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Osvaldo Ortega (osortega)
force-pushed
the
osortega/agenthost-tolerate-divergent-hosts
branch
from
August 25, 2026 00:11
28a5396 to
6b14e70
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Agent Host compatibility with older or differently shaped hosts.
Changes:
- Gates customization payloads by protocol version.
- Filters unsupported working-directory schemes.
- Suppresses expected pre-creation
NotFounderrors and adds tests.
Show a summary per file
| File | Description |
|---|---|
agentHostSessionHandler.ts |
Adds compatibility handling for customizations, directories, and missing sessions. |
agentHostChatContribution.test.ts |
Adds compatibility regression tests. |
sessionProtocol.ts |
Exposes the generic AHP NotFound code. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts:5605
computeWorkingDirectoriesguarantees that index 0 is the primary directory. In a mixed-scheme multi-root workspace, filtering can remove that primary while retaining a later entry, silently promoting the secondary to the host's working directory instead of letting the host choose its default. Preserve the primary-first invariant: if the primary is not addressable, returnundefined; only filter secondary entries when the primary remains.
return addressable.length > 0 ? addressable : undefined;
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Balanced
Remote folders travel as `vscode-agent-host:` wrappers on the client and are unwrapped by `createSession` before being sent, so comparing the wrapper scheme against the host's `defaultDirectory` dropped SSH and tunnel working directories the host addresses perfectly well. Compare the unwrapped scheme instead, which is what the host actually receives. Also covers the reconciliation republish path, which had no test even though an ungated republish is enough for an older host to reject the update. Both tests were checked against the bugs they describe by reverting each fix and confirming the matching test fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The gate only exists because reachable hosts still speak 0.7.0, and a host on that version silently loses its client customizations. Nothing in the code said when it should go, so it would outlive the reason for it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Osvaldo Ortega (osortega)
marked this pull request as ready for review
August 25, 2026 03:43
Osvaldo Ortega (osortega)
enabled auto-merge (squash)
August 25, 2026 03:44
Joaquín Ruales (jruales)
approved these changes
Aug 25, 2026
Osvaldo Ortega (osortega)
deleted the
osortega/agenthost-tolerate-divergent-hosts
branch
August 25, 2026 06:45
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.
Three ways a session against a host that is older than, or shaped differently from, the client would fail outright. All three surfaced against a remote host running an older
copilotd, but none of the fixes are specific to it —AgentHostSessionHandlerserves local, SSH and tunnel sessions too.1. Customization shape skew
Customizations moved from an
enabledboolean to list-shapedenablementin protocol 0.8.0. A host below that version expects the superseded shape and rejects the whole request withinvalid params: missing field "enabled", failingcreateSessionand leaving no session at all.Client-published customizations are now dropped for such a host, degrading to a session without them — which is what that host would have made of them anyway; the alternative is no session.
The gate is applied on both paths that publish an active client. Reconciliation republishes it after creation, so gating only
createSessionleaves the second path broken.Worth noting for reviewers: the version registry has exhaustive, compile-enforced maps for actions and notifications, but nothing for field-level shape changes like this one, so the version constant here is hand-maintained.
2. Working directories the host cannot address
A workspace may be the repository itself (
https://github.com/owner/repo) while the agent runs against a checkout on the host’s own disk. Sending the remote URI failscreateSessionwithunsupported scheme "https"; expected "file".Directories the host cannot address are now dropped, falling back to
undefinedso it chooses its own. The host’s reporteddefaultDirectorynames the scheme it can address, so this adapts per host rather than hardcodingfile. Hosts that report no default are left alone.3. "Couldn’t open session" for a session that does not exist yet
A provider can legitimately address a session id before the host knows it, with
createSessionbringing it into being. Subscribing first fails withNotFound, which rendered a failure banner that the very next step resolved.The banner is suppressed for
NotFoundspecifically — a genuine open failure still renders, which a test covers directly so the suppression cannot quietly widen.Risk
All three are no-ops for a current host with matching schemes: the version gate passes, every directory is addressable, and sessions resolve. The blast radius is wider than the case that motivated them, so the no-op paths are the ones worth checking.
Validation
npm run typecheck-client./scripts/test.sh --glob "**/agentHostChatContribution.test.js"— 328 passing, including 6 new tests covering both sides of each fix (drops and keeps, suppresses and still renders).Note on the
NotFoundsuppressionThe suppression is deliberately broad: it covers every AHP
NotFound, not only a session the client minted and expects to create on first send.This costs a notice, not a capability. A session the host does not know is unreadable either way and is recreated on the next send in both cases, so the only difference is that "Couldn't open session" no longer appears. Cloud sandbox sessions are unaffected entirely, since Mission Control mirrors their history at
/eventsand a dormant environment opens read-only from that rather than reaching this path.The remaining case — a persisted local/SSH/tunnel session the host has lost — is also short-lived, because
_refreshSessionsevicts any cached session the host does not list. Narrowing the suppression would need a positive provider-level signal that the client minted the id; not worth the API surface for a missing notice in that window.