ide на основе vs code
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
> Status: Cycles A–G + post-Cycle-F architectural cleanup (including the stateless-mapper follow-up) complete. > > Handoff plan — written to be executed by an agent with no prior conversation context. All file paths and line citations are verified against the workspace at synthesis time. Cross-reference roadmap.md before committing exact phase numbers.
Bring the shipped Claude IAgent surface (Phases 4–6) back into M1–M13 mapping conformance with CONTEXT.md. This is a drift-correction phase, not a feature phase — every change is a fix to existing code or to a doc bug in CONTEXT.md.
Phase 6.1 deliverable: the shipped Phase 4–6 surface (createSession, _materializeProvisional, sendMessage, mapper, descriptor, models observable, listSessions, sidecar) agrees with the M1, M8, M11, M12, and M13 portraits — verified by per-cycle unit tests and a single live smoke run.
Out of scope (deferred):
abortSession (claudeAgent.ts:801 throws TODO: Phase 9) — Phase 9.changeModel — Phase 9.resume: sessionId — Phase 6.5 (separate stacked PR).Exit criteria:
1. CONTEXT.md cites only methods that exist on IAgent (no setSessionConfigValues references). M11 and M12 invariants are internally consistent. 2. Both createSession and _materializeProvisional throw ProtocolError(AHP_AUTH_REQUIRED, …, this.getProtectedResources()) when called pre-auth — never plain Error. 3. The outbound SDKUserMessage from sendMessage carries uuid: effectiveTurnId. Turn.id ↔ SDKUserMessage.uuid invariant holds for every turn. 4. IAgentCreateSessionConfig.config flows from createSession → provisional record → sidecar → Options.* on the first query() call. First turn uses the requested model, permissionMode, and effort — SDK defaults never silently win. 5. permissionMode enum carries 6 values ('default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk' | 'auto'), matching the SDK's PermissionMode type and the M11 portrait. 6. IAgentDescriptor.displayName === 'Claude' (the user-facing brand for this provider; "Claude Code" is forbidden as a UI string). isClaudeModel
Findings cross-checked against CONTEXT.md and source by three independent reviewers (Opus, GPT, Gemini) plus a debate pass.
SDKUserMessage without uuid. M1 + Glossary mandate uuid = effectiveTurnId. Breaks Turn.id ↔ SDKUserMessage.uuid invariant; Phase 6.5 fork and Phase 13 replay cannot function.Options with no model, hardcoded permissionMode: 'default'. M11 says IAgentCreateSessionConfig.config MUST flow into Options.* on the first query() call. The provisional record IClaudeProvisionalSession (around line 92) also has no config field to carry the bag forward — structural gap._materializeProvisional) throws plain Error('Claude proxy is not running...'). CONTEXT.md:2247 says any lifecycle method that runs before authenticate() must throw ProtocolError(AHP_AUTH_REQUIRED, msg, this.getProtectedResources()).createSession at claudeAgent.ts:297 does NOT guard against unauthenticated state. CopilotAgent guards createSession directly at 'stream_event' | 'result' | default. The 'assistant' envelope (final canonical) is dropped. CONTEXT.md:875: "Partials are advisory; final SDKAssistantMessage is canonical." Phase 7 directly depends on this.permissionMode enum. CONTEXT.md:1962 specifies 5 (adds 'dontAsk'). The SDK typedef at sdk.d.ts:1560 actually exposes 6 (adds 'auto'). Cycle A ratifies whether 'auto' belongs in M11.displayName: 'Claude'. CONTEXT.md:1741 specifies 'Claude Code'.~~ Withdrawn during Cycle D — re-reading CONTEXT.md:1741 shows the doc already specifies 'Claude'; no drift exists. "Claude Code" is also forbidden as a user-facing brand string. Cycle D1 is therefore a no-op (no code change).isClaudeModel has 5 predicates. CONTEXT.md:1789-1795 specifies 3 (vendor, supported_endpoints, model_picker_enabled). Direction unratified — narrow impl OR document additions.toAgentModelInfoCONTEXT.md references setSessionConfigValues 4× (lines 1995, 1998, 2008, 2195). Method does NOT exist on IAgent (verified by grep across src/vs/platform/agentHost/common/). Definitive doc bug.permissionMode should be sessionMutable: true, but Q1's missing protocol method means there's no mechanism to perform the mutation post-creation. Self-contradiction. Resolution must accompany Q1.phase5-plan.md and phase6-plan.md describe pre-Phase-6.5 fork model.claudeMapSessionEvents.ts doesn't differentiate result.subtype error states for telemetry. Defer to Phase 14.abortSession at claudeAgent.ts:801 throws TODO: Phase 9 — defer.changeModel unimplemented — Phase 9.resume: sessionId for fork path — Phase 6.5.Order: A → B → C → E → D → F → G.
| Cycle | Scope | Files | |---|---|---| | A ✓ | Doc corrections (zero code) | CONTEXT.md | | B ✓ | Auth conformance (C3 + C4) | claudeAgent.ts | | C ✓ | Send-seam uuid (C1) | claudeAgent.ts | | E ✓ | Materialize + metadata coherence (C2 + I2 + I7 + I8) | claudeAgent.ts, claudeSessionConfigKeys.ts | | D ✓ | Catalog completeness (I3 + I4 + I5 + I6 + I9) | claudeAgent.ts | | F ✓ | Mapper widening: 'assistant' canonical (I1) | claudeMapSessionEvents.ts | | G | Stale phase-plan refresh (N1) | phase5-plan.md, phase6-plan.md, roadmap.md |
*Completed. See Implementation Notes for the decisions taken and the resulting CONTEXT.md changes.*
setSessionConfigValues (lines 1995, 1998, 2008, 2195) with the correct routing. Two options to choose from: 1. Reference IAgentCreateSessionConfig.config (create-time only) and remove sessionMutable: true from M11 (resolves Q2). 2. Mark as TODO: protocol surface for live config edits not yet defined and keep sessionMutable: true as a forward-looking marker.
'auto' belong in M11?).Acceptance: CONTEXT.md cites only methods that exist on IAgent; sessionMutable invariants are internally consistent.
Risk: None (doc-only). Decisions in this cycle constrain Cycles D and E.
*Completed. See Implementation Notes for the resulting code changes.*
Files: claudeAgent.ts, ../../test/node/claudeAgent.test.ts
ProtocolError, AHP_AUTH_REQUIRED (mirror imports already used by copilotAgent.ts).Error in _materializeProvisional (line 415) with ProtocolError(AHP_AUTH_REQUIRED, msg, this.getProtectedResources()).createSession (line 297). Mirror copilotAgent.ts:382-385.createSession-while-unauth.Acceptance: Both createSession and _materializeProvisional throw ProtocolError with code -32007 and data.resources populated when called pre-auth.
Risk: Test breakage (grep 'Claude proxy is not running'); workbench-side handlers matching the message.
*Completed. See Implementation Notes for the resulting code changes.*
Files: claudeAgent.ts, ../../test/node/claudeAgent.test.ts
uuid: effectiveTurnId as branded to the SDKUserMessage literal at lines 780–785. Branded type is the SDK's ` ${string}-${string}-${string}-${string}-${string} `.Acceptance: Yielded SDKUserMessage.uuid === effectiveTurnId.
Risk: Pre-existing transcripts have SDK-random uuids; one-time discontinuity. No callers depend on this yet (Phase 6.5 deferred).
*Completed. See Implementation Notes for the resulting code changes.*
The largest cycle. Unifying insight: provisional state, materialize-time config read, startup Options, and persisted session metadata all share the same data path.
Files: claudeAgent.ts, ../../common/claudeSessionConfigKeys.ts, ../../test/node/claudeAgent.test.ts
'dontAsk' (and per Cycle A ratification, possibly 'auto') to permissionMode enum + label/description.config?: Record<string, unknown> field to IClaudeProvisionalSession (around line 92) so the createSession config bag actually survives until materialize. Currently dropped on the floor.model (and per Cycle A ratification, permissionMode/effort) to sidecar at create + materialize. Mirror CopilotAgent's pattern at copilotAgent.ts:549-551, copilotAgent.ts:1532-1580. Update _writeSessionMetadata and _readSessionMetadata accordingly._materializeProvisional, read from sidecar for the latest config (not just from provisional.config). This matches CopilotAgent's pattern at copilotAgent.ts:771 and handles the case where session config was edited after createSession but before first sendMessage.Options.model from the resolved CCAModel.id. Verify SDK's Options.modelAcceptance: First turn uses requested model + permissionMode + effort (not SDK default). Round-trip: createSession({ model: 'claude-sonnet-4-5' }) → first turn runs that model → listSessions/getSessionMetadata (after Cycle D) reflect it.
Risk:
1. First-turn behavior change is user-visible (correct, but flag in PR). 2. Sidecar schema change requires migration story — set model: undefined for legacy sidecars; impl tolerates undefined. 3. Must verify CCAModel.id ↔ SDK Options.model format compatibility before landing. 4. Tests on the materialize Options shape break.
Files: claudeAgent.ts, ../../test/node/claudeAgent.test.ts, CONTEXT.md
getDescriptor.displayName: 'Claude Code' (was 'Claude').~~ No-op. Re-reading CONTEXT.md shows 'Claude' is already canonical; "Claude Code" is also forbidden as a user-facing brand. I3 was a misread of the doc; no code change needed. Cycle A's audit-row revision (in this Cycle D pass) corrects the audit table.toAgentModelInfo with configSchema (synth from CCAModel.capabilities.supports.{adaptive_thinking,min_thinking_budget,max_thinking_budget} — Anthropic models expose adaptive-thinking capability rather than supportedReasoningEfforts; mirror CopilotAgent's _createThinkingLevelConfigSchema shape but source the enum from the 5-value ClaudeEffortLevel union when the model supports adaptive thinking), policyState (from CCAModelPolicy.state), _meta.multiplierNumeric (from CCAModelBilling.multiplier).getSessionMetadata?(session) using SDK top-level getSessionInfo(sessionId) (sdk.d.ts:581 — verified to exist) joined with the _readSessionMetadata sidecar reader from Cycle E. Add a thin wrapper to IClaudeAgentSdkServiceAcceptance: Models observable carries configSchema for adaptive-thinking models, policyState, and _meta.multiplierNumeric; getSessionMetadata returns metadata for known sessions with model/customizationDirectory populated from sidecar and summary/cwd/timestamps from SDK; listSessions continues to surface all SDK-known sessions (sidecar-less ones too).
*Completed. See Implementation Notes for the resulting code changes.*
Risk:
1. ~~Verify IClaudeAgentSdkService.getSessionInfo exists (interface inspection).~~ Verified — sdk.d.ts:581 exposes getSessionInfo(sessionId, options?). Service interface needs a one-line wrapper addition. 2. ~~Verify CCAModel exposes thinking-capability data.~~ Verified — CCAModelSupports exposes min_thinking_budget/max_thinking_budget (types.d.ts:208-214). No supportedReasoningEfforts field on Anthropic CCAModel rows; D3 must synth the 5-value ClaudeEffortLevel enum directly when the model supports adaptive thinking. 3. Tests on the model filter shape may break (D2). — *No code change in D2; ignore.*
*Completed. See Implementation Notes for the resulting code changes.*
Files: claudeMapSessionEvents.ts, claudeAgentSession.ts (state shape only), ../../test/node/claudeMapSessionEvents.test.ts
case 'assistant' to mapSDKMessageToAgentSignals (line 54–66 switch).IClaudeMapperState to track per-block content if reconciliation requires it.SessionResponsePart MUST precede first delta for that part id (existing invariant).Acceptance: synthetic SDKAssistantMessage produces canonical response parts; deltas-followed-by-final test passes.
Risk: UI render glitches if reconciliation order is wrong. Phase 6's canUseTool: deny keeps 'assistant' messages text-only in practice — safer landing zone than Phase 7. Phase 7 directly depends on this fix.
Files: phase5-plan.md, phase6-plan.md, roadmap.md
Drift surface verified by a 3-reviewer council pass (Councillor-GPT / Opus / Gemini) on roadmap.md vs CONTEXT.md M1–M13. All three converged tightly on the same findings. Synthesized findings live at /memories/session/review.md; this cycle is the place they land.
#### G1 — Phase-plan stale fork narrative (original Cycle G scope)
#### G2 — Roadmap drift fixes (added from council review)
Each item below is a confirmed contradiction or staleness in roadmap.md relative to CONTEXT.md's locked M-mapping. Severity reflects implementation risk if a future phase consumes the roadmap as written.
| # | Phase | roadmap.md says | CONTEXT.md says | Fix in roadmap.md | Severity | |---|---|---|---|---|---| | G2.1 | 9 steering | Query.streamInput() for mid-turn injection (roadmap.md:687) | M10: zero callers of streamInput in reference; primitive is yielding SDKUserMessage with priority: 'now' into the existing prompt iterable (CONTEXT.md:1180-1257) | Replace streamInput language with prompt-iterable + priority: 'now' | HIGH | | G2.2 | 9 changeModel | Query.setModel() only (roadmap.md:689) | M11: bundle-atomic — ModelSelection.id + config.effort ⇒ setModel + applyFlagSettings({ effortLevel }) with 'max' → 'xhigh' clamp (CONTEXT.md:1614-1665) | Add effort fan-out, document the clamp | MED-HIGH | | G2.3 | 11 customizations | _pendingRestart (restart-on-toggle) (roadmap.md:735-737) | M11: reloadPlugins is defer-and-coalesce, not restart (CONTEXT.md:487, 710, 1544, 1585) | Reclassify as defer-and-coalesce with _pendingPluginReload flag drained at next yield boundary | HIGH | | G2.4 | 5 lifecycle | Allocate session + persist metadata immediately (roadmap.md:407-424) | M9: IAgentCreateSessionResult.provisional,
#### G3 — Compatible / no-change (council confirmed alignment)
truncateSession" — aligned with M10.abortSession mechanism (AbortController.abort(), not Query.interrupt()) — aligned with M4.Options.resume aligned with M9 (apart from G2.10 documentation gap).Acceptance: roadmap.md and the two phase-plans agree with the M1–M13 portraits in CONTEXT.md. The 9 council-confirmed drift items above are resolved by edits on the roadmap side (none require CONTEXT.md changes; CONTEXT is already correct).
Risk: None — doc-only.
#### Implementation notes (Cycle G — what landed)
Applied as in-place edits in this PR; no code changes.
getNextTurnEventId, JSONL walks, sdk.getSessionMessages) is marked historical and superseded by Phase 6.5's persisted-mapping contract; (b) the §B5 4-value permissionMode enum example is marked superseded by the 6-value canonical expanded in Cycle E1. The phase6-plan note covers the same fork-language drift in §1's createSession({ fork }) description. Body text is preserved as historical record; readers are pointed at roadmap.md, CONTEXT.md, and `claudeSessionConfigKeys.ts` for current contracts.IAgentCreateSessionResult.provisional / onDidMaterializeSession (G2.4); listSessions sidecar policy spelled out as best-effort enrichment, getSessionMetadata? named in scope (G2.5); resolveSessionConfig notes the M12 generic-live-edit-setter gap (G2.9 partial).onDidMaterializeSession eagerly because forkSession writes the file synchronously (G2.10).Map<tool_use_id, turnId> attribution model and the INTERACTIVE_CLAUDE_TOOLSAll drift items are resolved by edits on the roadmap / phase-plan side. CONTEXT.md was treated as the truth oracle and is unchanged.
| File | Cycles | What | |---|---|---| | CONTEXT.md | A | Mapping doc fixes; status updates | | claudeAgent.ts | B, C, D, E | Auth (createSession + materialize); uuid; toAgentModelInfo expansion; getSessionMetadata; permissionMode 5/6-value; sidecar with model; Options.model + permissionMode seeding; provisional.config; _toAgentSessionMetadata.model. D1 (displayName) and D5 (listSessions filter) reversed during Cycle D — no code change for those steps. | | claudeAgentSession.ts | F (state), E (optional E8) | Mapper state for reconciliation; bijective state for restart preservation | | claudeMapSessionEvents.ts | F | 'assistant' case + reconciliation | | ../../common/claudeSessionConfigKeys.ts | E1 | permissionMode enum expansion | | phase5-plan.md, phase6-plan.md, roadmap.md | G | Stale fork descriptions | | ../../test/node/claudeAgent.test.ts, ../../test/node/claudeMapSessionEvents.test.ts | All | Test coverage per cycle |
1. Test breakage at auth boundary — grep 'Claude proxy is not running'; coordinate with workbench if any consumer matches the message. 2. Transcript discontinuity at uuid fix — sessions written before Cycle C have SDK-random uuids; accept one-time discontinuity. 3. First-turn behavior change at startup-config seeding — user-visible but correct; flag in PR description. 4. Sidecar schema change — must tolerate legacy sidecars without model field (default to undefined). 5. CCAModel ↔ Options.model format compatibility — verify before Cycle E5 landing; fallback is a model-id-mapping helper. 6. ~~listSessions behavior change at D5 — sessions from other hosts disappear from the list. Document in PR.~~ Withdrawn — D5 reversed during Cycle D; no behavior change ships. 7. `IClaudeAgentSdkService.getSessionInfo` interface — Cycle D4 may need a one-line interface addition. 8. Mapper reconciliation correctness — Cycle F could double-emit text if not done carefully; test with synthetic messages.
Per cycle
npm run typecheck-client.npm run valid-layers-check.After all cycles — live smoke
1. Authenticate. 2. createSession({ config: { model: <non-default>, permissionMode: 'plan' } }). 3. First sendMessage. 4. Verify response renders. 5. Verify SDK Turn uuid matches protocol turnId in transcript. 6. Verify listSessions and getSessionMetadata return the chosen model.
This plan was synthesized from a 3-councillor council-plan run (Opus, GPT, Gemini) with a debate pass. The fan-out produced three independent drift audits; the synthesis preserved findings with at least 2/3 agreement; the debate pass added 4 items the synthesis missed (C4, I7, I8, I9) and promoted Q1 from open question to definitive doc bug. The order A → B → C → E → D → F → G reflects the post-debate consensus.
Decisions taken
| Question | Choice | Rationale | |---|---|---| | Q1 / Q2 — how to handle 4× setSessionConfigValues references | Option 2 (Forward-looking) — keep sessionMutable: true on permissionMode; keep the same-schema-serves-both framing (resolveSessionConfig reads at both creation and post-creation, IAgentCreateSessionConfig.config writes at creation); mark the generic post-creation setter (working name: setSessionConfigValues) as a TBD protocol surface; require any sessionMutable: true property without a covering changeModel/setCustomizationEnabled path to round-trip via createSession until the generic setter lands. | The schema's mutability flag is the read-side contract — permissionMode has a bijective SDK setter (Query.setPermissionMode), so it's correctly marked. The doc bug was citing a method that doesn't exist; the doc fix is to mark it TBD without erasing the design intent. | | I4 — isClaudeModel predicate count | Option A — document all 5 predicates in M12 with rationale. | Impl extras (tool_calls, tryParseClaudeModelId) have JSDoc-documented reasons (reference-extension parity, exclude synthetic ids like 'auto'). Narrowing the impl would be a regression. No code change needed in Cycle D2. | | I2 — does 'auto' belong in M11 enum? | Option Z — include 'auto'
Files changed
multi_replace_string_in_file, then 4 of them revised after reviewer pushback on the Q1/Q2 framing: 1. M12 isClaudeModel filter prose (around line 1786) — three predicates AND'd together → 5 predicates with per-predicate rationale, citing impl JSDoc and reference-extension parity. *(Final.)* 2. M12 permissionMode bullet in resolveSessionConfig properties list (around line 1975) — documents the full 6-value SDK enum (including 'auto') and re-affirms sessionMutable: true (M11 hot-swap; Query.setPermissionMode() is bijective). *(Revised after pushback.)* 3. M12 Same schema serves creation *and* post-creation display subsection (around line 1996) — resolveSessionConfig is the read surface for both phases; IAgentCreateSessionConfig.config is the creation-time write bag; the generic post-creation setter is TBD; live edits to sessionMutable: true properties not covered by changeModel/setCustomizationEnabled round-trip via createSession until the generic setter lands. *(Revised after pushback.)* 4. M12 resolveSessionConfig is the schema source for runtime mutations too invariant (around line 2192) — schema and implementation must agree (matching M11 hot-swap path required for any sessionMutable: true property); the future generic live-edit setter is the protocol conduit; restart-via-createSession is the interim fallback. *(Revised after pushback.)* 5. M13 AHP_AUTH_REQUIRED throw row (around line 2247) — — see open mapping question below
Verification
grep setSessionConfigValues CONTEXT.md — 4 matches remaining, all correctly framed as the TBD generic post-creation setter per Option 2. No prescriptive citations of a non-existent shipped method.grep "five-value\|five values" CONTEXT.md — 0 matches. All permissionMode enum mentions reflect the 6-value ratification.grep "see open mapping question below" CONTEXT.md — 0 matches. Dangling reference resolved.Deviations from plan
IAgentCreateSessionConfig.config is the creation-time write, resolveSessionConfig is the read surface for both creation and post-creation — not "creation-only." Three of the five edits were re-done to land on Option 2 (Forward-looking) instead. Cycle A's net behaviour is therefore: doc fixes the broken setSessionConfigValues citations by labelling them TBD, preserves the design intent of sessionMutable: true on permissionMode, and surfaces 'auto' per I2.Notes for downstream cycles
permissionMode enum ('dontAsk' and 'auto'), not one. Final enum is 6 values matching SDK PermissionMode type.isClaudeModel — the impl's 5 predicates are ratified as canonical. Still need D1 (displayName), D3 (toAgentModelInfo), D4 (getSessionMetadata), D5 (listSessions filter).permissionMode as sessionMutable: true in the resolveSessionConfig schema. Until the generic live-edit setter lands as a protocol surface, the implementation may either (a) implement permissionMode edits via a Claude-specific path, or (b) leave the live edit unsupported with the round-trip-via-createSession fallback documented for clients. Either is acceptable for Phase 6.1; designing the generic setter is out of scope.Code changes
import { AHP_AUTH_REQUIRED, ProtocolError } from '../../common/state/sessionProtocol.js';._ensureAuthenticated(): IClaudeProxyHandle — returns the live _proxyHandle or throws ProtocolError(AHP_AUTH_REQUIRED, 'Authentication is required to use Claude', this.getProtectedResources()).createSession calls this._ensureAuthenticated() at the head (before fork-branch), so a pre-auth createSession is rejected as AHP_AUTH_REQUIRED with the protected-resources hint instead of silently minting a provisional record._materializeProvisional replaces the plain Error('Claude proxy is not running...') with const proxyHandle = this._ensureAuthenticated();. The materialize path is now defense-in-depth (C4 makes the bare-public-API path unreachable), but stays in place for completeness and to keep both call sites symmetrical.Tests
'createSession before authenticate throws ProtocolError(AHP_AUTH_REQUIRED) with protected resources'. Verifies code === AHP_AUTH_REQUIRED, message === 'Authentication is required to use Claude', and data is the getProtectedResources() array.createSession-using tests updated to call await agent.authenticate(GITHUB_COPILOT_PROTECTED_RESOURCE.resource, 'tok') first (lines 922, 958, 978, 1851, 1878, 2074 in claudeAgent.test.ts). The fork-rejection test still asserts /Phase 6\.5/ because auth now succeeds before the fork branch is reached.claudeAgent.integrationTest.ts) was already authenticating first; no change required.Verification
grep "Claude proxy is not running" across the workspace — 0 hits in non-plan code, confirming no workbench-side handler depends on the old error message.get_errors on both touched files — 0 errors.Deviations from plan
_ensureAuthenticated() helper to (a) keep both error throws byte-identical and (b) return the handle so _materializeProvisional can keep its narrowed IClaudeProxyHandle type without a non-null assertion. Net behaviour identical; readability improved.Notes for downstream cycles
_proxyHandle outside authenticate/shutdown) should funnel through _ensureAuthenticated() to inherit the auth-conformance error contract for free.AgentService already maps ProtocolError(AHP_AUTH_REQUIRED, …, [resources]) to its sign-in flow (CopilotAgent has the matching shape at copilotAgent.ts:384); no Claude-specific surfacing work expected.Code changes
sendMessage SDK-prompt-literal site (lines ~787–795 post-edit): added uuid: effectiveTurnId as \${string}-${string}-${string}-${string}-${string}\` to the SDKUserMessage literal. The brand cast at the boundary mirrors the reference extension at [claudeCodeAgent.ts:585](../../../../../../extensions/copilot/src/extension/chatSessions/claude/node/claudeCodeAgent.ts#L585) and the doc snippet at [CONTEXT.md:1272](./CONTEXT.md#L1272). One-line JSDoc cites the M1 / Glossary invariant (Turn.id ↔ SDKUserMessage.uuid`) so future readers don't unwind the brand cast as cosmetic.Tests
'sendMessage tags SDKUserMessage.uuid with the effective turn id (M1 / Turn.id ↔ uuid invariant)'. Stages a single turn with explicit turnId: 'turn-explicit', drains the prompt iterable, asserts drained[0].uuid === 'turn-explicit'. Test-suite count: 47 pass / 0 fail (was 46 → +1 new).turnId ?? generateUuid() fallback path across two turns. The two-turn shape requires queryAdvance gating to keep the SDK transcript aligned per turn (mirroring the test at line 1100), which expanded the test outside Cycle C's scope. Reduced to a single-turn assertion — the fallback path is structurally trivial (turnId ?? generateUuid(), one line) and already exercised by every other sendMessage test in the suite that omits the turnId argument.Verification
uuid: undefined (matching the C1 finding); green after one-line fix.get_errors on both touched files — 0 errors.Deviations from plan
as branded with the SDK's \${string}-${string}-${string}-${string}-${string}\`` shape; that's exactly what landed.Notes for downstream cycles
SDKUserMessage.uuid as authoritative for turn-id lookup; the persisted-mapping-table contract from roadmap.md populates from this same value.SDKUserMessageReplay.uuid (whose type makes uuid required, not optional) will round-trip through the same id.Code changes
ClaudePermissionMode union widened from 4 to 6 values ('default' | 'acceptEdits' | 'bypassPermissions' | 'plan' | 'dontAsk' | 'auto'); JSDoc updated to cite sdk.d.ts:1560 and the I2 ratification.resolveSessionConfig permissionMode schema gains 'dontAsk' + 'auto' enum values, with matching localized enumLabels + enumDescriptions.IClaudeProvisionalSession extended with readonly model: ModelSelection | undefined and readonly config: Record<string, unknown> | undefined. createSession now seeds both fields from the inbound IAgentCreateSessionConfig instead of dropping them.Options.model = provisional.model?.id and Options.permissionMode = this._resolvePermissionMode(provisional.config) (was hardcoded 'default' with no model). The provisional record is the source of truth for these values at materialize — see deviations below for why E4's sidecar-priority read was reverted.Tests
Two new tests added to `claudeAgent.test.ts`, one pre-existing test updated:
'resolveSessionConfig returns Claude-native permissionMode + reused Permissions schema' (line ~2208) — permissionModeEnum snapshot expanded from 4 → 6 values; JSDoc updated to cite sdk.d.ts:1560 and the Cycle A ratification.'createSession config.model + config.config.permissionMode flow into Options on first send (M11 / Phase 6.1 C2)' — round-trip test asserting Options.model === created-time model.id and Options.permissionMode === created-time permissionMode after the first sendMessage.'createSession.model round-trips through the per-session DB to listSessions[].model (Phase 6.1 I8 + I7 + C2)' — full round-trip: createSession({ model }) → sendMessage materializes (writes sidecar via _writeSessionMetadata) → sdk.sessionList = [...] → listSessions surfaces model on the entry's IAgentSessionMetadata.Effort addendum — Options.effort wired separately after the model + permissionMode work landed:
CLAUDE_THINKING_LEVEL_KEY = 'thinkingLevel' — the ModelSelection.config sub-key carrying the picker's effort pick. Mirrors CopilotAgent's ThinkingLevelConfigKey (copilotAgent.ts:83) so a single picker contract spans both providers.ClaudeEffortLevel type — hand-rolled 5-value union ('low' | 'medium' | 'high' | 'xhigh' | 'max') structurally identical to the SDK's EffortLevel (sdk.d.ts:443) but defined in common/ so the layer stays SDK-free.resolveClaudeEffort(model) — pure narrowing function mirroring CopilotAgent's _getReasoningEffort (copilotAgent.ts:487). Pulled out of ClaudeAgent so the narrow can be exercised directly without standing up the full agent fixture.Options.effort = resolveClaudeEffort(provisional.model). No private _resolveEffort method, no _CLAUDE_THINKING_LEVEL_KEY constant on the class, no EffortLevel SDK import — the structural assignment from ClaudeEffortLevel to Options.effort is checked by TS without a cast.Test-suite count: 52 pass / 0 fail (was 47 → +5 new + 1 updated).
Verification
get_errors on both modified files at each step — 0 errors.Deviations from plan
_materializeProvisional to read the sidecar via _readSessionMetadata and prefer those values over provisional.*, citing copilotAgent.ts:771 as the matching pattern. Investigation showed that line is the *provisional initialization site*, not a sidecar read — CopilotAgent's actual materialize-time pattern (copilotAgent.ts:777-783) reads provisional.model directly and reads the *live* session config via IAgentConfigurationService.getSessionConfigValues(sessionUri), not from the per-session DB. The DB sidecar in CopilotAgent is for durability across restarts (listSessions, _resumeSession), not as the materialize-time source of truth. In Phase 6.1, ClaudeAgent has no changeModel (deferred to Phase 9 per E8) and no IAgentConfigurationService integration (deferred to Phase 7), so there is no mutation channel between createSession and the first sendMessage that could write to the sidecar; an "E4 sidecar wins" branch would be dead code at this phase and would diverge from CopilotAgent's pattern. Resolution: materialize uses provisional.model?.id and _resolvePermissionMode(provisional.config) directly; sidecar persistence (E3) and Notes for downstream cycles
_readSessionMetadata directly — the plan's D4 ("joined with the sidecar reader from Cycle E") references this helper. Cycle D should compose _readSessionMetadata(session) with IClaudeAgentSdkService.getSessionInfo(id) and pipe the result through _toAgentSessionMetadata.permissionMode (and any other mutable session-config) edits. Mirror CopilotAgent's _materializeProvisional pattern (copilotAgent.ts:777-783): inject IAgentConfigurationService and call getSessionConfigValues(sessionUri.toString()) at materialize. The sidecar persist on materialize stays (so post-restart cold reads via listSessions/getSessionMetadata still work); the live read replaces the materialize-time read of provisional.config, it does not stack with a sidecar read.changeModel (copilotAgent.ts:1212-1224): mutate provisional.model while still provisional, RPC the live SDK after materialize, and then persist via _writeSessionMetadata so the sidecar reflects the new state for the next cold read.Code changes
createClaudeThinkingLevelSchema(supportedEfforts: readonly ClaudeEffortLevel[]) returning a ConfigSchema whose thinkingLevel.enum is sourced from each model's own reasoning_effort list (different Claude models support different subsets, e.g. ['low','medium','high'], ['high'], []). Mirror of CopilotAgent's _createThinkingLevelConfigSchema(supportedReasoningEfforts, defaultReasoningEffort) at copilotAgent.ts:457 — same per-model variation, same matching-enumLabels shape. Returns undefined for an empty list so the picker renders no thinkingLevel control for that model. Also exports isClaudeEffortLevel(value): value is ClaudeEffortLevel for callers that need to narrow runtime strings into the SDK's EffortLevel shape; claudeAgent.ts filters the per-model reasoning_effort array through it.toAgentModelInfo(m, provider) expanded with three optional fields:configSchema = createClaudeThinkingLevelSchema(supportedEfforts) where supportedEfforts = (supports.reasoning_effort ?? []).filter(isClaudeEffortLevel). Reads the per-model list off the runtime CAPI Tests
Two new tests added to `claudeAgent.test.ts`, one pre-existing test updated, two test doubles extended, plus a makeSupports test helper:
'authenticate populates models filtered to Claude family' — model snapshot expanded to include policyState: 'enabled' and _meta: { multiplierNumeric: 1 } from the default makeModel fixture (policy.state + billing.multiplier were already on the fixture; D3 makes them visible on IAgentModelInfo).'authenticate sources configSchema enum from each model\'s reasoning_effort list (Phase 6.1 / Cycle D3 / I5)' — five-model fixture exercising every per-model variation in one assertion: full ['low','medium','high'], single-value ['high'], empty [] (no schema), unknown values filtered out (['low','bogus','high'] → ['low','high']), and missing field (no schema). Snapshot is { modelId: configSchema | undefined } so the per-model variation is the contract.'getSessionMetadata joins SDK info with sidecar overlay, returns SDK-only fields for external sessions, and undefined for unknown ids (Phase 6.1 / Cycle D4 / I7)' — three-call assertion in one test (sidecar + external + unknown) snapshotting the joined output, plus the SDK-lookup-call list to lock the call shape.makeSupports({ adaptive_thinking, reasoning_effort }) test helper — narrows the augmented runtime shape through one widening cast at the test boundary (mirror of the prod-side IClaudeModelSupports); tests then build per-model fixtures via spread without escape-hatch casts at every fixture site.Deviation note (D3 — corrected mid-cycle)
The first D3 implementation used a static 5-value ClaudeEffortLevel union for *any* adaptive-thinking model, gated on the presence of min_thinking_budget + max_thinking_budget on CCAModelSupports. That was wrong: per-model variation is the contract. Different Claude models expose different effort subsets at runtime (the extension's `pickReasoningEffort` at line 208 reads endpoint.supportsReasoningEffort per-endpoint, e.g. ['low','medium','high'], ['high'], or []). The corrected approach reads the runtime reasoning_effort field via a local IClaudeModelSupports type augmentation at the read boundary; SDK-type drift tracked at microsoft/vscode-capi#85.
Verification
get_errors on all modified files at each step — 0 errors.Deviations from plan
CCAModel.capabilities.supports.{adaptive_thinking,min_thinking_budget,max_thinking_budget}". The shipped CCAModel typedef (types.d.ts:207–208) has no adaptive_thinking field — only the two budget bounds. Resolution: detect adaptive thinking via min_thinking_budget !== undefined && max_thinking_budget !== undefined, source the enum from the static ClaudeEffortLevel union (the picker-emit side already uses it; the materialize-narrow side already accepts it). Diverges from CopilotAgent's supportedReasoningEfforts-driven shape but is the only correct path for Anthropic models.getSessionMetadata (copilotAgent.ts:560-590) returns undefined when there's no stored sidecar — every Copilot session is born inside VS Code, so the sidecar is a sound presence test. Claude cannot inherit that pattern: the same external-CLI carve-out that drives the listSessions D5 reversal also applies here. Resolution: use _sdkService.getSessionInfo(sessionId) as the existence test (SDK miss ⇒ undefined) and treat the overlay as decoration only.configSchema, policyState, _meta) were already optional on the interface (agentService.ts:269-271); D3 only fills them in for the Claude provider. CopilotAgent's _listModels already surfaces all three (copilotAgent.ts:600-610).Notes for downstream cycles
createClaudeThinkingLevelSchema helper to advertise the picker contract on a per-model basis after live model swaps; no new helper needed.multiplierNumeric key under Claude's _meta. Matches CopilotAgent's existing _meta.multiplierNumeric (verified at copilotAgent.ts:608); clients reading either provider's models can index this slot uniformly.Three small drift-free extensions to D3 landed between Cycle D close and Cycle F start, all within Cycle D's already-listed file scope. Captured here so the plan doesn't lie about what shipped.
resolveClaudeEffort (2 tests), isClaudeEffortLevel (1), and createClaudeThinkingLevelSchema (3 — variation snapshot, default-rule, aliasing safety). 5 tests total. The shipped claudeAgent.test.ts already exercises the helpers end-to-end through toAgentModelInfo, but direct tests pin the picker-emit / materialize-narrow contract independent of the agent boundary.createClaudeThinkingLevelSchema now emits default: 'high' when (and only when) 'high' is in the model's supportedEfforts list; no default otherwise. Mirrors the extension's canonical rule at `claudeCodeModels.ts:230`. Surfaces through IConfigSchema.properties[key].default so the JSON-schema-driven picker pre-selects 'high' on a fresh session for any model that supports it._refreshModels now stable-sorts all.filter(isClaudeModel) by is_chat_default descending before mapping through toAgentModelInfo. The IAgentModelInfo protocol carries no isDefault bit; the workbench picker uses models[0]Code changes
case 'assistant': to the top-level mapSDKMessageToAgentSignals switch, dispatching to a new private mapAssistantCanonical(message, logService) helper.mapAssistantCanonical deliberately returns [] for text/thinking content. The reducer at `reducers.ts:338-356` is append-only — there is no SessionResponsePart replacement action. Because Options.includePartialMessages: true (Phase 6 §3.4) drives the partials to produce the same content the canonical message carries, re-emitting on the canonical envelope would duplicate, not reconcile, the activeTurn responseParts list.message.message.content for tool_use blocks and warns each one with the id/name. Mirrors the existing content_block_start tool_use warn-and-drop at claudeMapSessionEvents.ts:163-167. Both warns lift in Phase 7 once tool calls are wired through.includePartialMessages: true is "drop".Tests
Two new tests in `claudeAgent.test.ts`, one new builder, one extension to createTestContext, and a small log-capturing fake:
makeAssistantMessage(sessionId, content) builds an SDKAssistantMessage envelope (type: 'assistant') with the SDK's full Anthropic.Messages.Message shape. Sits next to the existing make* builders. Uses 'fake-assistant-id' etc. as static fixtures since these IDs aren't asserted by any test.CapturingLogService — minimal ILogService test double that records warn(message) calls into a warns: string[] array for assertions. Other methods are no-ops. Plumbed via a new optional logService field on createTestContext's options bag (defaults to NullLogService); the option flows through to the fake IClaudeProxyService (whose stale token logging path wants a real-ish log service in the test).'canonical SDKAssistantMessage with tool_use content fires defense-in-depth warning (Phase 6.1 / Cycle F)'. Stages a system:init, a canonical SDKAssistantMessage carrying a tool_use content block, and a result:success. Asserts responsePartCount === 0 and logService.warnsVerification
default arm — tool_use warning test failed (no case 'assistant' arm meant message.message.content was never inspected). Green after adding the case to the switch and the helper.get_errors on both touched files — 0 errors.Deviations from plan
IClaudeMapperState to track per-block content if reconciliation requires it." Reconciliation does NOT require it: under append-only-reducer + includePartialMessages: true, the canonical message's correct action is "drop, with a defense-in-depth scan." No state extension shipped; claudeAgentSession.ts untouched.'text content_block emits SessionResponsePart(Markdown) before SessionDelta' family of tests). Adding a standalone file would duplicate the harness for no gain. The new tests were added to claudeAgent.test.ts next to its peers.SessionResponsePart MUST precede first delta for that part id." Cycle F adds zero new emissions in the canonical text path, so the invariant cannot regress. The existing tests at `claudeAgent.test.ts:1369` and `:1444` continue to lock the invariant for the stream_event-driven path.Notes for downstream cycles
tool_use warn lifts in Phase 7. The mapper will then emit SessionToolCallStart from the canonical envelope's tool_use blocks (alongside the matching emissions already planned for stream_event partials). The mapAssistantCanonical helper is the dispatch site for that work.SDKAssistantMessages only — there are no stream_event partials in JSONL transcripts. mapAssistantCanonical is therefore the *only* path that emits text response parts in replay, so its body must grow from "drop" to "emit canonical parts" before replay ships. Until then, the stub at `claudeAgent.ts:598-605` keeps replay off.'result' (the existing code path); canonical 'assistant' deliberately does NOT close the turn. M8 boundary contract intact.Two follow-up refactors that came out of the post-Cycle-F architectural review. Both are pure debt reduction — no behavior change, no protocol change, no new tests for cycles A–F's behavior. Phase 7 readiness is the underlying motivator: the mapper grows, so the seam needs to grow with it instead of the call sites.
1. Encapsulate mapper state as an opaque `ClaudeMapperState` class
export interface IClaudeMapperState { readonly currentBlockParts: Map<number, string>; } with export class ClaudeMapperState. The class exposes 4 named operations — resetMessage(), allocPart(index, partId), getPart(index), dropPart(index) — backed by a private _blockParts: Map<number, string>. The lifecycle invariant ("clear on message_start, allocate on content_block_start, look up on content_block_delta, drop on content_block_stop") now lives behind those names.mapSDKMessageToAgentSignals, internal mapStreamEvent) take state: ClaudeMapperState instead of state: IClaudeMapperState. The four internal call sites (message_start → state.resetMessage(), content_block_start text/thinking → state.allocPart(index, partId) ×2, content_block_delta → state.getPart(event.index), content_block_stop2. Direct mapper unit tests at the function seam
ClaudeMapperState per scenario. Cases: 1. message_start clears state and emits no signals (verified by post-reset delta resolving to []). 2. text content block: start emits SessionResponsePart(Markdown), deltas emit SessionDelta with the same partId, stop drops the part (post-stop delta at the same index emits []). 3. thinking content block: start emits SessionResponsePart(Reasoning), delta emits SessionReasoning. 4. streamed tool_use content block at content_block_start is dropped with a warn log (defense-in-depth). 5. canonical 'assistant' envelope drops tool_use blocks with a warn log and emits nothing. 6. canonical 'assistant' envelope without tool_use emits nothing and does not warn. 7. result success emits SessionUsage (with model from modelUsage) followed by SessionTurnComplete. 8. result success with empty modelUsage omits the model field on SessionUsage. 9.
claudeAgent.test.ts (makeSystemInitMessage, makeResultSuccess, makeStreamEvent, makeMessageStart, makeContentBlockStart{Text,Thinking,ToolUse}, make{Text,Thinking}Delta, makeContentBlockStop, makeMessageStop, makeAssistantMessage, makeNonNullableUsage, TEST_UUID) plus their type aliases (BetaRaw*Event, BetaContentBlock). One new builder added: makeContentBlockStartToolUse(index, id, name) for the new direct test of defense-in-depth.CapturingLogService test double *inside* the agent harness file. Each new mapper test before this refactor cost ~50 lines of agent harness setup. With the seam at the function level, the new tests cost a fresh ClaudeMapperState() each. The 11 cases above all fit inside 280 lines including imports.Test count after architectural cleanup: agentHost claude suite is now 72 pass / 0 fail across claudeAgent.test.ts (55) + claudeMapSessionEvents.test.ts (11 new) + claudeModelConfig.test.ts (6). No regressions.
3. Stateless mapper (follow-up to #1)
After landing #1, an empirical re-read of BetaRawContentBlockStartEvent.index (`node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts:1123`) and the SDK's own accumulator (`node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js:476`) showed index is the position within the *current message's* content[] — the SDK accumulator does snapshot.content.push(event.content_block) on content_block_start and snapshot.content.at(event.index) on content_block_delta with no bounds checking. Phase 6 sets canUseTool: deny, so a turn is exactly one assistant message and index is therefore monotonic within a turn. That removes the only reason ClaudeMapperState existed.
ClaudeMapperState class. mapSDKMessageToAgentSignals and the internal mapStreamEvent no longer take a state parameter. content_block_start text/thinking emits SessionResponsePart with id: \${turnId}#${event.index}\` directly. content_block_delta emits with the same string formula — no map lookup, no orphan-delta guard. message_start, content_block_stop, message_delta, message_stop all become return [] no-ops. generateUuid` import removed._mapperState field and its ClaudeMapperState import; the call to mapSDKMessageToAgentSignals no longer passes a state argument.freshState() helper and ClaudeMapperState import. Re-purposed the message_start test to "emits no signals" (no state to clear). Dropped the post-stop "leak" assertion from the text-block test (stop is now a no-op; the SDK protocol guarantees no out-of-order deltas). Deleted the orphan-delta test — a toAgentModelInfoconfigSchemapolicyState_metagetSessionMetadata?listSessionsclaudeMapSessionEvents.ts'assistant'SDKMessage'stream_event''result'phase5-plan.mdphase6-plan.mdroadmap.mdcreateSession_materializeProvisionalErrorsendMessageconfigSchemaCCAModel.capabilities.supports.thinkingpolicyState_metagetSessionMetadata? not implemented on claudeAgent.ts. CONTEXT.md:1880-1900: "should also implement for parity with CopilotAgent."claude.customizationDirectory. CopilotAgent's sidecar at copilotAgent.ts:1532-1580 carries model. Without sidecar persistence of model, listSessions/getSessionMetadata cannot satisfy CONTEXT.md:1896._toAgentSessionMetadata doesn't include model field at all.listSessions returns SDK-only sessions when no sidecar exists. CONTEXT.md:2124 specifies Claude should follow Copilot's "drop sessions without sidecar" filter pattern.~~ Withdrawn during Cycle D — the directive itself is wrong: dropping sidecar-less sessions in Claude erases sessions created by the external Claude CLI (an explicit Phase-5 exit criterion). The SDK is the source of truth for the session list; the sidecar is an enrichment overlay. CONTEXT.md is the doc bug, not claudeAgent.ts. Plan correction lands in Cycle D; D5 becomes a no-op (no code change).sdk.d.ts:OptionspermissionMode: 'default' at line 449 with the resolved value._toAgentSessionMetadata (lines 655–662) to include model field from sidecar (I8 fix)._currentModel, _currentPermissionMode, _currentEffort on ClaudeAgentSession for "Restart preserves bijective state." Defer if changeModel (Phase 9) isn't shipping yet.listSessions to drop sessions without sidecar, mirroring CopilotAgent's pattern.~~ No-op. External Claude CLI sessions have no sidecar and MUST surface (Phase-5 exit criterion); the shipped code at claudeAgent.ts:761-797 already does the right thing. The plan's directive was a misread of conformance — Copilot can drop because every Copilot session is born inside VS Code; Claude cannot drop because external CLI sessions are first-class. CONTEXT.md correction (line ~1888 + line ~2159 table cell) lands in this cycle.onDidMaterializeSessionsessionAddedonDidMaterializeSessiongetSessionMetadata?getSessionMetadata?Map<tool_use_id, turnId>canUseToolrespondToPermissionRequestINTERACTIVE_CLAUDE_TOOLS'AskUserQuestion' \| 'ExitPlanMode'respondToUserInputRequestOptions.onElicitationExitPlanModerespondToPermissionRequestrespondToUserInputRequestAskUserQuestiononElicitationsetMcpServersSDKControlMcpSetServersRequestcreateSdkMcpServersetMcpServerssetPermissionModepermissionModesessionMutable: truepermissionModecreateSessionOptions.resumeonDidMaterializeSessionforkSessioncanUseToolQuery.streamInput with prompt-iterable priority: 'now' yield + IAgentSteeringConsumedSignal semantics (G2.1); changeModel made bundle-atomic with setModel + applyFlagSettings({ effortLevel }) fan-out and the 'max' → 'xhigh' clamp documented (G2.2); setPermissionMode paragraph notes the protocol-surface gap (G2.9).createSdkMcpServer + Options.mcpServers, restart-required) from external MCP servers (Query.setMcpServers, hot-swap) (G2.7).setCustomizationEnabled from _pendingRestart to defer-and-coalesce via _pendingPluginReload + Query.reloadPlugins, with the tool-set-divergence case kept as the narrow restart-required fallback (G2.3).PermissionMode— to be corrected in Phase 6.1 Cycle B (see [phase6.1-plan.md](phase6.1-plan.md))sessionConfigCompletionsstatic five-value enumstatic six-value enum_writeCustomizationDirectory(session, workingDirectory) → _writeSessionMetadata(session, { customizationDirectory?, model?, permissionMode? }). Single openDatabase ref, Promise.all batched writes, only-write-on-defined; mirrors CopilotAgent's _storeSessionMetadata shape (copilotAgent.ts:1532)._readSessionMetadata(session): Promise<{ customizationDirectory?, model?, permissionMode? }> mirroring copilotAgent.ts:1559. Uses tryOpenDatabase so missing DB is not an error._serializeModelSelection (JSON.stringify) and _parseModelSelection (object-shape narrowing with legacy plain-string fallback) mirroring copilotAgent.ts:492-522. Added _narrowPermissionMode for the read-side type guard. Added _resolvePermissionMode(config) for the create-time bag → SDK enum coercion (used at materialize to resolve the provisional.config bag)._toAgentSessionMetadata overlay arg widened to { customizationDirectory?, model? } and emits model on IAgentSessionMetadata. listSessions overlay reader replaced with a single _readSessionMetadata call; the per-key tryOpenDatabase + getMetadata block is gone (deduplicated through the new helper)._META_MODEL = 'claude.model' and _META_PERMISSION_MODE = 'claude.permissionMode' constants alongside the existing _META_CUSTOMIZATION_DIRECTORY.ModelSelection.config.thinkingLevel_META_EFFORT_writeSessionMetadataresolveSessionConfigOptions.effort (sdk.d.ts:1214) accepts the full 5-value EffortLevel union. The live hot-swap path applyFlagSettings({ effortLevel }) (sdk.d.ts:4292) only accepts a 4-value subset that omits 'max'; that clamp lives in Phase 9, not here.resolveClaudeEffort helper. One test covers all 5 accepted strings → SDK enum values; one covers the 5 degrade-to-undefined failure modes (no model, no config bag, empty config bag, unrelated config key, unrecognized value).'createSession model.config.thinkingLevel flows into Options.effort on first send (M11 / Phase 6.1 C2)' — full round-trip wiring assertion that Options.effort === 'high' after createSession({ model: { id, config: { thinkingLevel: 'high' } } }) + sendMessage._readSessionMetadatalistSessionschangeModel_writeSessionMetadata (singular) and the read helper _readSessionMetadata. CopilotAgent's reference uses _storeSessionMetadata for the write. We chose _writeSessionMetadata for symmetry with the read helper and the plan's wording.CCAModel.id ↔ Options.model format compatibility ("verify before landing; fallback is a model-id-mapping helper"). Verified: SDK Options.model is string (sdk.d.ts:1289), and CCAModel.id is also a flat string identifier — no translation needed. The brand cast at the persist boundary (_serializeModelSelection) is JSON-only, not format-translation._currentModel/_currentPermissionMode/_currentEffort on ClaudeAgentSession for "Restart preserves bijective state") deferred to Phase 9 (changeModel) per the plan's own "(optional, M11 invariant). … Defer if changeModel (Phase 9) isn't shipping yet."permissionMode as sessionMutable: true" — sessionMutable: true was already present on permissionMode in the schema before this cycle (verified during E1). No additional change needed.claude.customizationDirectory. _readSessionMetadata returns model: undefined and permissionMode: undefined for those rows — listSessions surfaces model: undefined on those entries (acceptable; the SDK row still appears) and the _parseModelSelection legacy-plain-string branch covers any older schema attempts.phase5-plan.md/phase6-plan.md references to the 4-value permissionMode enum to the 6-value canonical./modelsreasoning_effort: string[]adaptive_thinking: booleancapabilities.supportsIClaudeModelSupports@vscode/copilot-apiIChatModelCapabilitiesIClaudeModelSupportspolicyState = m.policy?.state as PolicyState | undefined — propagates CCAModelPolicy.state straight through to clients so the picker can grey-out disabled rows._meta = { multiplierNumeric: m.billing?.multiplier } (only when multiplier is a number) — surfaces CCAModelBilling.multiplier under the _meta side-channel slot per IAgentModelInfo._meta (agentService.ts:271). Spread-only-when-defined so non-multiplied models stay clean.getSessionMetadata(session: URI): Promise<IAgentSessionMetadata | undefined> mirroring IAgent.getSessionMetadata? (agentService.ts:477). Composes _sdkService.getSessionInfo(id) (SDK is the source of truth for existence) with _readSessionMetadata(session) (overlay), pipes through _toAgentSessionMetadata. Crucially does NOT gate on the sidecar — external Claude CLI sessions have no DB but must hydrate (Phase-5 exit criterion + the D5 reversal). Overlay read failures are caught and logged so a single corrupt DB cannot lose the SDK-supplied summary/cwd; SDK lookup failures propagate so the caller learns the SDK module is broken.getSessionInfo(sessionId): Promise<SDKSessionInfo | undefined> to the IClaudeAgentSdkService interface and the IClaudeSdkBindings structural slice, plus the production passthrough on ClaudeAgentSdkService (one-line await this._getSdk(); return sdk.getSessionInfo(sessionId)). Keeps the SDK module behind the service boundary so the agent's getSessionMetadata doesn't reach into @anthropic-ai/claude-agent-sdk directly.FakeClaudeAgentSdkService.getSessionInfo — searches sessionList by id by default; getSessionInfoOverride hook for "session moved off disk" tests; getSessionInfoCalls records ids for call-shape assertions.ProxyRoundTripSdkService (integration test) — added getSessionInfo(): Promise<undefined> stub to satisfy the interface; the integration suite never exercises the lookup so the stub is unconditional.claudeModelConfig.test.ts still 2/2)._selectedModel ?? models[0]'authenticate surfaces the CAPI chat-default model first; ties preserve insertion order'IAgentModelInfoclaudeAgent.test.ts: 54 → 55; claudeModelConfig.test.ts: 0 → 5; claudeAgent.integrationTest.ts: unchanged).tool_use'canonical SDKAssistantMessage with text content does not double-emit signals already produced by stream_event partials (Phase 6.1 / Cycle F)'. Stages the canonical no-double-emit scenario: system:init → stream_event(message_start, content_block_start, text_delta='hello', content_block_stop, message_stop) → canonical SDKAssistantMessage([{type:'text', text:'hello'}]) → result:success. Asserts exactly 1 SessionResponsePart and exactly 1 SessionDelta (with content === 'hello') — no duplication from the canonical envelope.claudeModelConfig.test.ts still 5/5 — total agentHost claude suite 66 pass.state.dropPart(event.index)private readonly _mapperState: IClaudeMapperState = { currentBlockParts: new Map<number, string>() }; becomes private readonly _mapperState: ClaudeMapperState = new ClaudeMapperState();. Import updated. No other call sites — _mapperState is only ever passed to mapSDKMessageToAgentSignals.tool_use_id) and the lifecycle for those is *not* "drop on message_start" — it's "drop on tool_result envelope or terminal result." Encoding the per-message vs. cross-message lifecycle distinction in a Map<number, string> literal at the call site would have meant a breaking change in Phase 7. Encoding it in resetMessage() (per-message fields drop here; cross-message fields explicitly excluded) localizes that change to one method body.interface IClaudeMapperState { readonly currentBlockParts: Map<number, string>; } had readonly on the *field reference* but not on the *Map's mutation surface*; callers could (and did) call .set / .get / .delete / .clear directly. A class with private state and a method-only surface fixes that without Readonly<...> wrappers that wouldn't have made the Map's mutators inaccessible anyway.message_stop[]content_block_delta[]SessionDeltapartIdcontent_block_start strictly before any delta at the same index; an out-of-protocol delta with no preceding start is silently dropped by updateResponsePart because if (!found) return state;. Removing the state class therefore changes zero observable behavior under the SDK contract and one cosmetic behavior (a malformed orphan delta would now hit the reducer no-op instead of a mapper no-op).index per message — the content_block_start push-then-at(index) pattern in BetaMessageStream.js proves it, since each message_start builds a fresh snapshot. That collision lands in Phase 7, not Phase 6. The fix at that point is to mix message.id (or an equivalent per-message counter) into the partId formula: ${turnId}#${messageId}#${index}. Phase 7's plan should reintroduce the minimum state needed for that — likely a single _currentMessageId: string | undefined field, set on message_start from event.message.id — alongside the tool-call tracking maps it already requires. The phase-7-plan.md IClaudeMapperState design predates this refactor and should be re-derived from the new shape.