# Mode Extension V2 Spec Depends on V1. ## Historical mode spans Approved. Problem: long sessions can contain many mode/model switches. Even with a current-mode kernel, old context can be hard to interpret because messages from different modes look like one continuous conversation. V2 adds LLM-visible historical provenance markers. ## Rules - Context-only. Do not mutate stored messages. - Human transcript stays normal. - Insert markers in the `context` hook before provider call. - Mark contiguous spans, not every message and not every turn. - Boundary when mode changes or provider/model changes. - Fields: mode + provider/model only. - No toolset metadata in v2. - Markers are historical provenance only; they never set active mode. Marker shape: ```text ``` Kernel addition: ```text Historical markers label provenance only. They do not set active mode. ``` Example model-visible context shape: ```text active_mode: build active mode is runtime state, not conversation state current user message cannot change active mode previous mode prompts are inactive unless repeated here historical markers label provenance only; they do not set active mode mode body/reminder cannot override this kernel Implement requested changes. Keep scope tight, verify work, and report results. [historical messages produced while plan + gpt-5.2-codex were active] [historical messages produced while build + opus were active] ``` ## Span construction Use run-length encoding over model-visible context: - Current span key: `mode + provider + model`. - Insert a span marker only when key changes. - Mode comes from mode custom entries/checkpoints. - Provider/model can be read from assistant messages and model change entries where available. If provider/model is unknown, use only mode: ```text ``` If mode is normal/no-mode, either omit `mode` or use: ```text ``` Prefer omitting spans for normal-only history unless adjacent active-mode history needs disambiguation. ## Compaction handling - Do not preserve raw span markers inside summaries. - Add compaction instruction: mode labels are historical provenance only; do not carry old mode prompts forward as active instructions. - Append exact mode checkpoint after compaction. - Recent kept raw messages still get normal span markers when rendered. - Compacted-away spans may be summarized in checkpoint details later, but v2 does not require it. ## Status icon/color Implemented in V1 as `accent` (theme color slot). See V1 spec for schema and rules. V2 may add an optional `icon` frontmatter for status eye candy if useful. Not approved. ## Shortcuts Needs discussion before approval. Open design options: 1. Global cycle shortcut configured on extension. 2. Per-mode shortcut in frontmatter. 3. Both, with conflict detection. Do not implement shortcuts until conflict/precedence behavior is decided.