Skip to content

Chat unexpectedly resets to Ask across harnesses during mode availability changes #338501

Open

Description

Summary

Users report that Chat unexpectedly resets to Ask in both the Local and Copilot/Agent Host harnesses. Managed-settings or harness-availability changes are suspected, including reports involving permissions.disableBypassPermissionsMode, but the triggering event and regression commit are not yet confirmed.

Code finding

There is a plausible persistence defect in the shared composer:

  1. Mode-list changes run validateCurrentChatMode() and then _restorePersistedCustomModeIfAvailable().
  2. Validation applies automatic Agent/Ask fallbacks through setChatMode() with its default storeSelection: true.
  3. setChatMode2() serializes that fallback into the session input state.
  4. Custom-mode restoration then reads the potentially overwritten state.

This can erase a preferred mode during temporary mode unavailability. However, it does not by itself explain an Ask transition: with chat.agent.enabled=true, a missing custom mode normally falls back to Agent. permissions.disableBypassPermissionsMode restricts auto-approval and does not directly disable Agent mode.

Expected

Temporary provider, harness, or mode unavailability should not permanently replace the user's selected mode. Restoration must also respect current policy and any explicit user mode change made while the preferred mode is unavailable.

History / attribution

Investigation needed

Capture the event sequence when the reset occurs:

  • session type / harness;
  • current UI mode and persisted input-state mode;
  • effective chat.agent.enabled value and policy source;
  • mode list before and after the reset;
  • managed-settings and provider/harness availability changes.

Add sequence-based coverage for:

  • custom mode disappearance and reappearance;
  • built-in Agent disable and re-enable;
  • persisted custom mode while Agent mode becomes policy-disabled;
  • explicit user selection while a preferred mode is unavailable;
  • unrelated input-state synchronization during the availability gap.

A simple storeSelection: false change in validation is insufficient: custom-mode restoration can immediately undo Agent disablement, built-in Agent is not restored after re-enable, and later input-state synchronization can still serialize the fallback mode.

Activity

  1. digitarald commented on Sep 29, 2026

    @digitarald
    ContributorAuthor

    New logs explain the previously missing Ask transition.

    During window/extension-host reload, the extension-provided tools agent is temporarily unavailable. ChatModes.getBuiltinModes() then omits Agent but retains Ask. validateCurrentChatMode() requests Agent because chat.agent.enabled=true, but setChatMode() cannot resolve Agent and silently falls through to ChatMode.Ask, persisting that fallback. When the tools agent returns, Ask is valid, so Agent is not restored.

    The captured sequence also confirms the availability gap repeats across reloads:

    • first extension host started at 18:12:05.453; managed settings applied at 18:12:15.957;
    • the workbench then reloaded and the Agent Host renderer client disconnected/reconnected;
    • the second extension host started at 18:12:27.630; managed settings applied at 18:12:30.313.

    AHP confirms this is UI-only: the session was created with mode: interactive, the backend schema allowed only interactive, plan, and autopilot, and ask never crossed the protocol.

    Suggested regression coverage: toggle hasToolsAgent true → false → true while an Agent Host chat is active and assert that both the visible mode and persisted input-state mode remain Agent.

    🤖 Posted by GitHub Copilot on Harald's behalf.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions