Skip to content

Wire up SDK autopilot and plan modes via MessageOptions.Mode#186

Merged
PureWeen merged 4 commits intomainfrom
feat/wire-autopilot-mode
Feb 23, 2026
Merged

Wire up SDK autopilot and plan modes via MessageOptions.Mode#186
PureWeen merged 4 commits intomainfrom
feat/wire-autopilot-mode

Conversation

@PureWeen
Copy link
Owner

Summary

Previously, autopilot and plan modes only prepended [[AUTOPILOT]] or [[PLAN]] text to the prompt. Now the SDK's MessageOptions.Mode property is set to the correct agent mode string, letting the Copilot backend handle mode switching natively.

Changes

Core wiring

  • CopilotService.SendPromptAsync: Added agentMode parameter, sets MessageOptions.Mode when specified
  • Dashboard.razor: Maps UI input mode (GetInputMode()) to SDK agent mode string instead of text prefix
  • BridgeMessages.cs: Added AgentMode field to SendMessagePayload (backward-compatible — null for old clients)
  • WsBridgeServer/Client/Interface: Pass agentMode through the bridge protocol

Queue preservation (review finding)

  • Added _queuedAgentModes parallel tracking dictionary (same pattern as _queuedImagePaths)
  • Agent mode survives message queuing when session is busy, correctly passed on drain
  • Cleanup in all paths: abort, clear, close, rename

Tests

  • 7 new tests in AgentModeTests.cs: serialization, round-trip, backward compatibility
  • All 1152 tests pass

SDK Mode Values

MessageOptions.Mode accepts: "interactive", "plan", "autopilot", "shell"

Review

Multi-model code review (Opus 4.6, Sonnet 4.6, Codex 5.3) found the queued-message mode loss — fixed in commit 2.

@PureWeen PureWeen force-pushed the feat/wire-autopilot-mode branch from 9a1cda4 to ec8d8aa Compare February 23, 2026 16:28
PureWeen and others added 3 commits February 23, 2026 12:18
Previously, autopilot and plan modes only prepended [[AUTOPILOT]] or
[[PLAN]] text to the prompt. Now the SDK's MessageOptions.Mode property
is set to the correct agent mode string ('autopilot', 'plan', etc.),
letting the Copilot backend handle mode switching natively.

Changes:
- CopilotService.SendPromptAsync: add agentMode parameter, set Mode on MessageOptions
- Dashboard.razor: map input mode to SDK agentMode instead of text prefix
- BridgeMessages.cs: add AgentMode to SendMessagePayload (backward-compatible)
- WsBridgeServer/Client: pass agentMode through bridge protocol
- IWsBridgeClient: updated interface signature
- AgentModeTests: 7 tests covering serialization, round-trip, backward compat

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Code review found that agentMode was lost when messages were queued
(session busy). Added _queuedAgentModes parallel tracking dictionary
(same pattern as _queuedImagePaths) so plan/autopilot mode survives
queuing and is passed through to SendPromptAsync on drain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gnment

Round 2 multi-model review (Opus, Sonnet, Codex) found 3 issues:

1. _queuedAgentModes inner List<string?> had no lock protection unlike
   _queuedImagePaths. Now all mutations are under _imageQueueLock.

2. Remote-mode EnqueueMessage silently dropped agentMode. Added AgentMode
   to QueueMessagePayload and wired through client/server/interface.

3. Re-queue on failure only re-inserted non-null modes, causing alignment
   drift with the prompt list. Now always re-inserts when a mode queue
   exists for the session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen force-pushed the feat/wire-autopilot-mode branch from ec8d8aa to fb28c4c Compare February 23, 2026 18:20
…sistency

1. Evaluator async dispatch path (Events.cs:1079) now consumes
   _queuedAgentModes to maintain alignment and passes agentMode
   to SendPromptAsync.

2. Reconnect retry path now sets MessageOptions.Mode on the retry
   MessageOptions, preserving autopilot/plan mode across reconnects.

3. ClearQueue and RenameSession now access _queuedAgentModes under
   _imageQueueLock for consistent lock discipline.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen PureWeen merged commit 016ea71 into main Feb 23, 2026
@PureWeen PureWeen deleted the feat/wire-autopilot-mode branch February 23, 2026 18:34
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.

1 participant