Skip to content

Agent Host: open canvases close when a send triggers a session configuration refresh #340508

Closed

Description

Does this issue occur when all extensions are disabled?: N/A (Agent Host core code path)

  • VS Code Version: Code - Insiders 1.142.0-insider (f4dfb91). The code path is unchanged on main at 38d9885.
  • OS Version: macOS 27.0.1 (arm64)

When a message send makes the Agent Host refresh a Copilot chat's session configuration, every canvas open in that chat closes in the Agents window and doesn't come back.

Steps to Reproduce:

  1. Enable chat.canvases.enabled and, in the Agents window, start a new local Copilot session in a new worktree.
  2. Have the agent open a canvas (open_canvas) in the first turn. It opens as a tab in the side pane.
  3. Send a follow-up message in the same chat.

Expected: The canvas stays open. At most it's briefly unavailable while its provider reconnects, as with an extension reload.

Actual: The canvas tab closes and doesn't reopen. The runtime still has the instance open: invoke_canvas_action calls on it keep succeeding, and calling open_canvas again with the same instanceId brings it back, as a new tab.

agenthost.log shows the send restarting the SDK session. The same pattern was observed in two chats:

11:01:11.457Z [Copilot:…] Session configuration changed, refreshing session: operation=sendMessage, …, reason=clientPluginsChanged
11:01:11.459Z [Copilot:…] SDK session disconnect RPC started …
11:01:11.514Z [Copilot:…] Preparing SDK session: kind=resume …

The Agents window's AHP log shows the host publishing an empty canvas list at the same instant:

11:01:11.459Z s2c chat/canvasesChanged   (no canvases)
11:01:11.459Z c2s unsubscribe ahp-canvas:/…

Root cause

  1. _refreshSessionConfiguration destroys the live SDK session and resumes it whenever the chat's configuration snapshot changed.
  2. destroySession calls _clearCanvasProjection, which publishes ChatCanvasesChanged with no canvases. The Agents window treats this as authoritative membership and closes the canvas editors.
  3. The replacement session's initializeSession adds every instance in wrapper.session.openCanvases to _ignoredRestoredCanvasInstanceIds, and projection starts out not ready, so the runtime's rehydration session.canvas.opened events are dropped. Nothing re-projects the canvas, even though the runtime still has it open.

This follows the documented contract ("A new SDK residency starts with an empty projected canvas collection and does not restore prior open canvases"), but a configuration refresh of a chat that's in use is currently treated as a new residency.

Why the refresh happens in this flow

Proposed fix

Hand the canvas projection over across a configuration refresh instead of clearing it:

  • Before destroying the live session for a refresh, capture its projected canvases, and don't publish an empty collection.
  • Keep each canvas resource stable per instanceId, so the Agents window keeps the same tab. Publish the carried state without a url (shown as temporarily unavailable) until the provider reconnects.
  • Resume with ResumeSessionConfig.openCanvases, and don't ignore carried instances in the replacement session.
    • Let session.canvas.opened publish the new URL.
    • Reconcile with openCanvases / rpc.canvas.list() once projection is ready, because rehydration can happen before that.
  • Drop carried canvases the runtime didn't restore. Publish an empty collection only if the resume fails.
  • Cold residencies (eviction, host restart) keep starting empty. Update the contract in AGENT_HOST_SESSIONS_PROVIDER.md accordingly.
  • Tests: a refresh keeps the canvas resource, never publishes an empty collection, and publishes the new URL without waiting for a user message.

Caveat: even with the hand-off, the refresh restarts the canvas extension process; the canvas URL changes. The canvas therefore reloads and loses any in-memory state. Avoiding that means avoiding the restart:

  • Don't restart when the bundle content is unchanged. Either make the bundle identity independent of the scope roots, or materialize bundles by content. This alone fixes the flow above.
  • Longer term, apply client customization changes to the live session, e.g. with session.plugins.reload({ reloadExtensions: false }) or session.options.update, instead of restarting. This still needs validation against the runtime.

Related

Activity

  1. added
    bug
    agent-host
    canvases
    on Oct 8, 2026
  2. added a commit that references this issue on Oct 14, 2026
    85f9801
  3. added
    unreleased
    on Oct 14, 2026
  4. added this to the 1.143.0 milestone on Oct 14, 2026
  5. added
    insiders-released
    and removed
    unreleased
    on Oct 14, 2026
  6. federicobrancasi commented on Oct 18, 2026

    @federicobrancasi
    Member

    🤖 How to verify: the video for this fix is in this comment, with related fixes. It walks through the steps in real VS Code Insiders, checking each result in the app.

  7. anthonykim1 commented on Oct 19, 2026

    @anthonykim1
    Contributor

    Verified on macOS 26.7.1 arm64 using VS Code Insiders 1.143.0-insider (a0c6520313624aceb3f3a80eff7932be6a00405a) with its bundled @github/copilot-sdk 1.0.23-preview.5.

    In the Agents window, I had a local Copilot session create a small project canvas (TPI Counter) and open it in the first turn. Before each follow-up I added a new workspace instructions file, so the send refreshed the session configuration with reason=clientPluginsChanged, the same reason as in the logs above. I polled the canvas tab about every 100 ms during each turn and checked the Agents window's AHP log.

    Verified:

    • Two follow-up sends that each logged Session configuration changed, refreshing session: operation=sendMessage … reason=clientPluginsChanged, then SDK session disconnect RPC started, Preparing SDK session: kind=resume and SDK resumeSession settled: outcome=success
    • The canvas tab and the message shown in it throughout each turn
    • The canvas traffic in the AHP log around each refresh
    • The new-worktree flow from the steps above

    Results:

    • The TPI Counter tab never closed. It was present in 2,870 of 2,870 samples in the first run and 230 of 230 in the second
    • During the restart the same tab showed "The canvas provider is temporarily unavailable.", then "Loading canvas…" under a second later, and the canvas reloaded in that tab
    • The host didn't publish an empty chat/canvasesChanged or unsubscribe the canvas. It sent canvas/stateChanged for the same instance without a URL right after the refresh, and with a URL once the resume finished (about 0.7 seconds)
    • In the new-worktree flow the canvas also stayed open, but in this build the follow-up send there no longer triggers a configuration refresh at all, which is why I forced one with the instructions file

    Open canvases no longer close when a send refreshes the session configuration in current Insiders.

    Agents window side pane before, during, and after a follow-up send that refreshed the session configuration: the TPI Counter canvas tab stays open, briefly shows "The canvas provider is temporarily unavailable.", then reloads, with the Agent Host and AHP log lines for the refresh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-hostbugcanvasesinsiders-releasedverified

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions