Skip to content

agentHost/claude: Phase 6.1 — auth, model config, mapper, lifecycle, doc alignment#315136

Merged
TylerLeonhardt merged 2 commits into
mainfrom
tyler/military-bass
May 8, 2026
Merged

agentHost/claude: Phase 6.1 — auth, model config, mapper, lifecycle, doc alignment#315136
TylerLeonhardt merged 2 commits into
mainfrom
tyler/military-bass

Conversation

@TylerLeonhardt
Copy link
Copy Markdown
Member

@TylerLeonhardt TylerLeonhardt commented May 7, 2026

Phase 6.1 lands the architectural follow-ups identified after Phase 6's
sendMessage shipped. Eight tightly-scoped cycles (A–G) plus a stateless-mapper
cleanup, all backed by an exhaustive M1–M13 mapping of the IAgent ↔ Claude SDK
surface in CONTEXT.md.

tl;dr... this includes:

  • A new section in CONTEXT.md that maps AHP to Claude SDK
  • any changes to drift us back into shape
  • better handling of models and their effort

Cycle summary

  • A: CONTEXT.md mapping doc — the M1–M13 portrait of IAgent ↔ Claude SDK.
  • B: Auth — createSession / _materializeProvisional throw
    ProtocolError(AHP_AUTH_REQUIRED, …, getProtectedResources()) instead of a
    plain Error, so the workbench surfaces the sign-in flow (mirrors
    copilotAgent.ts:382-385).
  • C: Turn.id = SDK uuid invariant — the host yields SDKUserMessage.uuid = effectiveTurnId, single-namespace contract documented as a glossary entry.
  • D: getSessionMetadata? per-session lookup; listSessions overlay read
    refactored onto _readSessionMetadata.
  • E: Permission-mode enum widened from 4-value to 6-value canonical (adds
    dontAsk, auto); Options.model / Options.permissionMode / effort flow
    through to the first query(); _writeSessionMetadata persists model +
    permission mode alongside the customization-directory key.
  • F: Mapper widening — 'assistant' is canonical at the SDK seam, with
    reconciliation against stream_event partials so deltas + final message no
    longer double-emit. tool_use blocks on the canonical envelope warn through
    defense-in-depth instead of silently leaking.
  • E2/E5/E6 + C2: IClaudeModelConfig (createClaudeThinkingLevelSchema,
    isClaudeEffortLevel, resolveClaudeEffort) — pulled out as a stateless
    helper so the mapper / agent / model picker share one effort-level vocabulary.
  • G: Doc-alignment pass on roadmap.md, phase5-plan.md, phase6-plan.md
    driven by a 3-reviewer council pass. Resolves 10 drift items (see CONTEXT
    ai-customization / Phase 6.1 plan §"Cycle G — Stale phase-plan + roadmap
    refresh"); CONTEXT.md is the truth oracle and is unchanged.

Files

  • New helpers + tests:
    src/vs/platform/agentHost/common/claudeModelConfig.ts,
    src/vs/platform/agentHost/test/common/claudeModelConfig.test.ts,
    src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts,
    src/vs/platform/agentHost/test/node/claudeMapSessionEventsTestUtils.ts.
  • Plans: phase6.1-plan.md (the executed plan), phase7-plan.md (the next
    phase, drafted; not landing in this PR).
  • Touched code: claudeAgent.ts, claudeAgentSdkService.ts,
    claudeAgentSession.ts, claudeMapSessionEvents.ts,
    claudeSessionConfigKeys.ts.
  • Touched docs: CONTEXT.md (new — full M1–M13 mapping), roadmap.md,
    phase5-plan.md, phase6-plan.md.

Verification

  • npm run compile-check-ts-native: 0 errors.
  • Affected test suites: 72/72 pass (claudeAgent.test.ts +
    claudeModelConfig.test.ts + claudeMapSessionEvents.test.ts).

Risk

  • Sidecar schema change: legacy sidecars without the model field default to
    undefined; tolerated.
  • Transcript discontinuity at Cycle C: sessions written before this PR have
    SDK-random uuids; one-time discontinuity expected, no migration.
  • Permission-mode enum widening: existing 'default' / 'acceptEdits' / 'bypassPermissions' / 'plan' values remain valid; new values are additive.
  • Doc-only Cycle G changes carry no behavioral risk.

Phase 7 (tools / permission / user input) and Phase 6.5 (fork) are not in this
PR. See the in-tree plans.

…doc alignment

Phase 6.1 lands the architectural follow-ups identified after Phase 6's
sendMessage shipped. Eight tightly-scoped cycles (A–G) plus a stateless-mapper
cleanup, all backed by an exhaustive M1–M13 mapping of the IAgent ↔ Claude SDK
surface in CONTEXT.md.

Cycle summary
-------------
- A: CONTEXT.md mapping doc — the M1–M13 portrait of IAgent ↔ Claude SDK.
- B: Auth — `createSession` / `_materializeProvisional` throw
  `ProtocolError(AHP_AUTH_REQUIRED, …, getProtectedResources())` instead of a
  plain `Error`, so the workbench surfaces the sign-in flow (mirrors
  `copilotAgent.ts:382-385`).
- C: Turn.id = SDK uuid invariant — the host yields `SDKUserMessage.uuid =
  effectiveTurnId`, single-namespace contract documented as a glossary entry.
- D: `getSessionMetadata?` per-session lookup; `listSessions` overlay read
  refactored onto `_readSessionMetadata`.
- E: Permission-mode enum widened from 4-value to 6-value canonical (adds
  `dontAsk`, `auto`); `Options.model` / `Options.permissionMode` / effort flow
  through to the first `query()`; `_writeSessionMetadata` persists model +
  permission mode alongside the customization-directory key.
- F: Mapper widening — `'assistant'` is canonical at the SDK seam, with
  reconciliation against `stream_event` partials so deltas + final message no
  longer double-emit. `tool_use` blocks on the canonical envelope warn through
  defense-in-depth instead of silently leaking.
- E2/E5/E6 + C2: `IClaudeModelConfig` (`createClaudeThinkingLevelSchema`,
  `isClaudeEffortLevel`, `resolveClaudeEffort`) — pulled out as a stateless
  helper so the mapper / agent / model picker share one effort-level vocabulary.
- G: Doc-alignment pass on `roadmap.md`, `phase5-plan.md`, `phase6-plan.md`
  driven by a 3-reviewer council pass. Resolves 10 drift items (see CONTEXT
  `ai-customization` / Phase 6.1 plan §"Cycle G — Stale phase-plan + roadmap
  refresh"); CONTEXT.md is the truth oracle and is unchanged.

Files
-----
- New helpers + tests:
  `src/vs/platform/agentHost/common/claudeModelConfig.ts`,
  `src/vs/platform/agentHost/test/common/claudeModelConfig.test.ts`,
  `src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts`,
  `src/vs/platform/agentHost/test/node/claudeMapSessionEventsTestUtils.ts`.
- Plans: `phase6.1-plan.md` (the executed plan), `phase7-plan.md` (the next
  phase, drafted; not landing in this PR).
- Touched code: `claudeAgent.ts`, `claudeAgentSdkService.ts`,
  `claudeAgentSession.ts`, `claudeMapSessionEvents.ts`,
  `claudeSessionConfigKeys.ts`.
- Touched docs: `CONTEXT.md` (new — full M1–M13 mapping), `roadmap.md`,
  `phase5-plan.md`, `phase6-plan.md`.

Verification
------------
- `npm run compile-check-ts-native`: 0 errors.
- Affected test suites: 72/72 pass (`claudeAgent.test.ts` +
  `claudeModelConfig.test.ts` + `claudeMapSessionEvents.test.ts`).

Risk
----
- Sidecar schema change: legacy sidecars without the `model` field default to
  `undefined`; tolerated.
- Transcript discontinuity at Cycle C: sessions written before this PR have
  SDK-random uuids; one-time discontinuity expected, no migration.
- Permission-mode enum widening: existing `'default' / 'acceptEdits' /
  'bypassPermissions' / 'plan'` values remain valid; new values are additive.
- Doc-only Cycle G changes carry no behavioral risk.

Phase 7 (tools / permission / user input) and Phase 6.5 (fork) are not in this
PR. See the in-tree plans.
Copilot AI review requested due to automatic review settings May 7, 2026 23:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances the VS Code agentHost Claude provider (Phases 4–6) toward the documented IAgent ↔ Claude SDK mapping by tightening auth error semantics, flowing model/config into the first SDK query, widening the mapper to handle canonical SDK envelopes, and aligning in-tree planning/roadmap docs. It also adds/updates a substantial set of unit tests to lock these contracts.

Changes:

  • Enforce auth-required via ProtocolError(AHP_AUTH_REQUIRED, …) for Claude lifecycle entrypoints, and add per-session metadata lookup (getSessionMetadata) backed by SDK getSessionInfo.
  • Propagate model, permissionMode, and thinkingLevel/effort into the first query() Options, persist/read model + permission mode in the per-session DB, and widen the advertised permission-mode enum to 6 values.
  • Update SDK-event mapping to recognize canonical 'assistant' envelopes, add direct mapper unit tests + fixtures, and refresh roadmap/phase plan docs.
Show a summary per file
File Description
src/vs/platform/agentHost/node/claude/claudeAgent.ts Auth gating, model/config → Options plumbing, sidecar metadata read/write, model sorting, getSessionMetadata, permissionMode schema updates.
src/vs/platform/agentHost/node/claude/claudeAgentSdkService.ts Extend SDK service boundary with getSessionInfo.
src/vs/platform/agentHost/node/claude/claudeAgentSession.ts Adjust mapper callsite after mapper API change (no external state passed).
src/vs/platform/agentHost/node/claude/claudeMapSessionEvents.ts Handle canonical 'assistant' envelope; simplify streaming mapping to stateless part-id derivation.
src/vs/platform/agentHost/common/claudeSessionConfigKeys.ts Widen ClaudePermissionMode union to 6 values.
src/vs/platform/agentHost/common/claudeModelConfig.ts New shared helper for thinking-level schema + effort resolution utilities.
src/vs/platform/agentHost/test/node/claudeAgent.test.ts Expand coverage for auth, config propagation, model schema sourcing, canonical assistant behavior, metadata round-trips.
src/vs/platform/agentHost/test/node/claudeAgent.integrationTest.ts Update SDK service test double for new getSessionInfo method.
src/vs/platform/agentHost/test/node/claudeMapSessionEvents.test.ts New direct unit tests for mapSDKMessageToAgentSignals.
src/vs/platform/agentHost/test/node/claudeMapSessionEventsTestUtils.ts New shared fixtures/builders for mapper and agent tests.
src/vs/platform/agentHost/test/common/claudeModelConfig.test.ts New tests for resolveClaudeEffort, isClaudeEffortLevel, createClaudeThinkingLevelSchema.
src/vs/platform/agentHost/node/claude/roadmap.md Roadmap alignment with the mapping/taxonomy and deferred fork plan.
src/vs/platform/agentHost/node/claude/phase5-plan.md Doc alignment/status notes for fork + permission-mode evolution (contains a mismatch noted in review).
src/vs/platform/agentHost/node/claude/phase6-plan.md Doc alignment/status notes for deferred fork approach.
src/vs/platform/agentHost/node/claude/phase6.1-plan.md New/updated executed plan documenting cycles and decisions.
src/vs/platform/agentHost/node/claude/phase7-plan.md New Phase 7 implementation plan doc.

Copilot's findings

  • Files reviewed: 16/17 changed files
  • Comments generated: 1

Comment thread src/vs/platform/agentHost/node/claude/phase5-plan.md Outdated
Fix the Cycle G status note: the enum is 'default' | 'acceptEdits' |
'bypassPermissions' | 'plan' | 'dontAsk' | 'auto' (matching ClaudePermissionMode
in claudeSessionConfigKeys.ts and the SDK's PermissionMode typedef), not the
'acceptAll' / 'denyAll' values previously listed. Addresses Copilot review
comment on PR #315136.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Screenshot Changes

Base: b0651040 Current: 0dc965e1

Changed (24)

agentSessionsViewer/CompletedRead/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Light
Before After
before after
agentSessionsViewer/CompletedUnread/Dark
Before After
before after
agentSessionsViewer/CompletedUnread/Light
Before After
before after
agentSessionsViewer/FailedWithDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithDuration/Light
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Light
Before After
before after
agentSessionsViewer/WithDiffChanges/Dark
Before After
before after
agentSessionsViewer/WithDiffChanges/Light
Before After
before after
agentSessionsViewer/WithFileChangesList/Dark
Before After
before after
agentSessionsViewer/WithFileChangesList/Light
Before After
before after
agentSessionsViewer/WithBadge/Dark
Before After
before after
agentSessionsViewer/WithBadge/Light
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Dark
Before After
before after
agentSessionsViewer/WithMarkdownBadge/Light
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Dark
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Light
Before After
before after
agentSessionsViewer/CloudProvider/Dark
Before After
before after
agentSessionsViewer/CloudProvider/Light
Before After
before after
agentSessionsViewer/BackgroundProvider/Dark
Before After
before after
agentSessionsViewer/BackgroundProvider/Light
Before After
before after
agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

@TylerLeonhardt TylerLeonhardt marked this pull request as ready for review May 8, 2026 00:29
@TylerLeonhardt TylerLeonhardt enabled auto-merge (squash) May 8, 2026 00:29
@TylerLeonhardt TylerLeonhardt merged commit 9c6da38 into main May 8, 2026
26 checks passed
@TylerLeonhardt TylerLeonhardt deleted the tyler/military-bass branch May 8, 2026 00:33
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 8, 2026
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.

3 participants