Skip to content

chat: don't start new chats with a harness disabled by policy - #345207

Merged
Ross Wollman (rwoll) merged 5 commits into
mainfrom
agents/repro-claude-session-issue-ubuntu
Oct 30, 2026
Merged

Ross Wollman (rwoll) merged 5 commits into
mainfrom
agents/repro-claude-session-issue-ubuntu

Conversation

@rwoll

@rwoll Ross Wollman (rwoll) commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #345117

Problem

When org policy disables the Claude agent (Claude3PIntegration, e.g. via the account's preview-features setting), users who had previously chosen Claude could not start a usable chat. Chat view New Chat (+), New Chat Editor, a new window and the restored Chat view all opened an empty Claude chat that only showed:

Your organization has disabled this agent. This conversation is read-only. Continue in Copilot to copy the conversation and keep the original.

There was no chat input, and Continue in Copilot did nothing because the conversation was empty.

The new-chat harness resolver treated every Agent Host session type as usable when the Agent Host was enabled. A remembered (chat.userSelectedSessionType), current or explicit Claude/Codex type therefore kept winning even after policy disabled that provider. The resulting chat was immediately marked read-only.

The same happens with Codex (Codex3PIntegration) when chat.editor.codex.preferAgentHost is on (experiment-controlled in stable), which looks like #344867. Reproduced on main at c6315a9 in an Ubuntu desktop; with that setting off, main falls back to Local.

Fix

  • isNewChatSessionTypeUsable now treats a local Agent Host provider that policy disables (Claude or Codex) as unusable, so remembered and current choices fall back to the regular default (Local or Copilot).
  • An explicit request for a policy-disabled harness falls through to the regular resolution instead of opening an unusable chat.
  • The remembered choice is not cleared, so it applies again if the policy is lifted.
  • The fallback never picks Local when Local is unavailable: with managed policy requiring the Agent Host, the managed sandbox, chat.editor.preferCopilotHarness, or chat.editor.localAgent.enabled set to false, it resolves to the Copilot harness.
  • Empty untitled drafts of a disabled harness, persisted before the fix, are replaced on restore in the Chat view and in chat editors. Saved Claude chats with history stay readable as before.
  • Unsent prompts: the replacement chat gets the chat input's saved empty-chat draft. If the policy arrives while VS Code is open, the read-only draft is replaced with a Local chat that keeps the prompt. With several drafts across a restart, the replacement shows the most recently typed one (existing draft-memory behavior). No step waits on account policy or the network before you can type.

Before / after

Code - OSS built from source in a fresh Ubuntu 24.04 desktop, with the policy in /etc/vscode/policy.json and the user's earlier harness choice remembered. Captions come from checks of the live UI: red marks the read-only banner, green the working chat input.

Scenario Before (main @ c6315a9) After (this PR @ ee0b5bd, merged with main)
Claude disabled by policy, click New Chat (+) Before: New Chat (+) opens a read-only Claude chat with no input After: New Chat (+) opens a Local chat with a working input
Codex disabled by policy (chat.editor.codex.preferAgentHost on), click New Chat (+) Before: New Chat (+) opens a read-only Codex chat with no input After: New Chat (+) opens a Local chat with a working input
Policy applied while VS Code is open, with an unsent prompt in a new Claude chat Before: the draft turns into a read-only Claude chat and the prompt is gone After: the draft is replaced by a Local chat that keeps the prompt
Full annotated recording (all three scenarios; Claude also covers Continue in Copilot and New Chat Editor)
before.mp4
after.mp4

Workaround until this ships

  • Codex: set "chat.editor.codex.preferAgentHost": false in user settings and reload the window. The user setting overrides the experiment value.
  • Claude: no setting helps (chat.editor.localAgent.enabled and chat.defaultToCopilotHarness don't override the remembered choice). Reset the remembered harness instead: assign a keybinding to Chat: New Local Chat (workbench.action.chat.newLocalChat, hidden from the Command Palette but listed in Keyboard Shortcuts), use it to open a Local chat, then pick Local or Copilot in the harness picker under the chat input. Later New Chat (+) clicks then open that harness. Verified on main at c6315a9.

How to test

  1. Set the Claude3PIntegration policy to false (Linux: /etc/vscode/policy.json; macOS dev build: a defaults value for the product's darwinBundleIdentifier).
  2. Have chat.userSelectedSessionType remembered as agent-host-claude (for example, Claude was picked before the policy applied).
  3. Start VS Code, open the Chat view, click New Chat (+), and run Chat: New Chat Editor. Each should open a usable chat with an input, not the read-only banner.
  4. For Codex, repeat with Codex3PIntegration set to false, chat.editor.codex.preferAgentHost set to true and agent-host-codex remembered.

Validation

Run in the Ubuntu desktop:

  • At 8c78ba7: ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/common/constants.test.ts: passed (64 tests). The new "only the Copilot harness is allowed" test fails when the policy check is reverted: every case then resolves to the disabled Claude/Codex harness.
  • At 8c78ba7: npm run eslint -- src/vs/workbench/contrib/chat/test/common/constants.test.ts and npm run typecheck-client: passed.
  • At ee0b5bd (the code under test is unchanged since): ./scripts/test.sh --run src/vs/workbench/contrib/chat/test/common/constants.test.ts --run src/vs/workbench/contrib/chat/test/browser/widgetHosts/viewPane/chatViewPane.test.ts --run src/vs/workbench/contrib/chat/test/browser/widgetHosts/editor/chatEditorInput.test.ts: passed (145 tests). npm run eslint -- <the 6 changed files>: passed.

🤖 Authored with GitHub Copilot on behalf of Ross Wollman (@rwoll).

When policy disables the Claude or Codex Agent Host provider, a remembered,
current or explicit choice of that harness kept winning new-chat resolution.
New Chat, New Chat Editor and the restored Chat view then opened an empty
read-only chat with no input. Treat a policy-disabled provider as unusable for
new chats so resolution falls back to an allowed harness, without forgetting
the remembered choice, and replace empty drafts of it on restore.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 16:04

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

Unresolved draft-restoration issues can discard persisted unsent prompts or leave the Chat view without usable input when account policy settles late.

2 open issues
What changed in this PR

This PR updates chat session selection and restoration so organization policy disabling Claude or Codex does not leave users in an unusable new chat.

Changes:

  • Rejects policy-disabled local harnesses during new-chat resolution while preserving remembered preferences.
  • Adds fallback handling for restored untitled drafts in the Chat view and chat editors.
  • Adds tests for policy-aware selection and draft restoration.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​common/​constants.test.ts Tests disabled-provider fallback and preference preservation.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widgetHosts/​viewPane/​chatViewPane.test.ts Tests which restored drafts the Chat view skips.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​widgetHosts/​editor/​chatEditorInput.test.ts Tests editor fallback from a disabled-provider draft.
src/​vs/​workbench/​contrib/​chat/​common/​constants.ts Adds policy checks to new-chat harness selection.
src/​vs/​workbench/​contrib/​chat/​browser/​widgetHosts/​viewPane/​chatViewPane.ts Skips restored request-free drafts of disabled harnesses.
src/​vs/​workbench/​contrib/​chat/​browser/​widgetHosts/​editor/​chatEditorInput.ts Redirects disabled-harness untitled drafts to the default chat.

Review effort: Balanced

Ross Wollman (rwoll) and others added 4 commits October 30, 2026 10:29
…bled drafts

Replacing an empty draft of a policy-disabled harness dropped its unsent text and
attachments. Carry them into the new chat in the Chat view and in chat editors,
without the disabled harness's model, mode or permissions.

If account policy settles after the Chat view restored such a draft, replace it
once it is shown, and when availability changes, instead of waiting for account
policy before showing the input. Restoring never blocks on policy or the network.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
…ing disabled drafts"

This reverts commit a2f0b48.

Measured in a Code - OSS build on Ubuntu with Claude3PIntegration=false, the
follow-up did not change what users see and regressed chat editors:

- Restart with unsent drafts: the replacement chats already get the most
  recently typed draft from the chat input's saved empty-chat draft, with or
  without the follow-up. The Chat view does not reload the untitled draft.
- Restarting a chat editor on a disabled draft now waited about 1.6 s for the
  Agent Host to load that draft, then showed an empty input.
- Policy arriving while VS Code is open: the existing availability handler
  already replaces the read-only draft with a Local chat that keeps the prompt.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
Resolve the conflict in isNewChatSessionTypeUsable with #345156, which now also
rejects a remembered remote Agent Host type this window lacks. Keep that check
unchanged and add the policy check for local Claude/Codex harnesses.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
… Copilot is allowed

Cover remembered, current and explicit Claude/Codex choices that policy
disables while Local is unavailable through managed policy, the managed
sandbox, chat.editor.preferCopilotHarness or chat.editor.localAgent.enabled.
Each resolves to the Copilot harness. Without the fix they resolved to the
disabled harness, which opens a read-only chat.

*🤖 Authored with GitHub Copilot on behalf of @rwoll.*

Co-authored-by: Copilot <[email protected]>
@rwoll
Ross Wollman (rwoll) merged commit 35cce54 into main Oct 30, 2026
55 checks passed
@rwoll
Ross Wollman (rwoll) deleted the agents/repro-claude-session-issue-ubuntu branch October 30, 2026 20:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Oct 30, 2026
@rwoll Ross Wollman (rwoll) added bug Issue identified by VS Code Team member as probable bug chat on-testplan labels Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug chat on-testplan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat view "New Chat" always opens a read-only Claude session when the Claude agent is disabled by org policy

4 participants