claudeModelConfig.ts ×4

Frontier kind: Code frontier

unlabeled · c_1a84cc82fef9

218 tests · 3507 LOC · 20 files · introduces 0 tests · 93 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges93 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
486 ranges3507 lines · 20 files · Browse complete extent
All tests (intent)
218 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 93 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/common/claudeModelConfig.ts 93 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- claudeModelConfig.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { localize } from '../../../nls.js';
7 > import { getReasoningEffortDescription, getReasoningEffortLabel } from './reasoningEffort.js';
8 > import type { ConfigSchema, ModelSelection } from './state/protocol/state.js';
9 >
10 > /**
11 > * Sub-key in `ModelSelection.config` carrying the user's reasoning-effort
12 > * pick from the model picker. Mirror of CopilotAgent's
13 > * `ThinkingLevelConfigKey` (copilotAgent.ts:83) so a single picker contract
14 > * spans both providers — the picker writes `model.config.thinkingLevel`,
15 > * and each provider narrows that string at materialize.
16 > */
17 > export const CLAUDE_THINKING_LEVEL_KEY = 'thinkingLevel';
18 >
19 > /**
20 > * Reasoning-effort values accepted by the Claude SDK's `Options.effort`
21 > * (startup). Hand-rolled here — not imported from the SDK — to keep `common/`
22 > * SDK-free; structurally identical to the SDK's exported `EffortLevel` so it
23 > * assigns into `Options.effort` without a cast.
24 > */
25 > export type ClaudeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
26 >
27 > /**
28 > * The effort union the SDK's runtime hot-swap setter
29 > * `Query.applyFlagSettings({ effortLevel })` is *declared* to accept. Note it
30 > * excludes `'max'` — but see {@link toRuntimeEffortLevel}: a `'max'` value can
31 > * still flow through this type at runtime, because the SDK's declared type is
32 > * narrower than what the API actually accepts.
33 > */
34 > export type ClaudeRuntimeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh';
35 >
36 > /**
37 > * Coerce a startup {@link ClaudeEffortLevel} to the {@link ClaudeRuntimeEffortLevel}
38 > * union the SDK's `applyFlagSettings({ effortLevel })` setter is typed to accept.
39 > *
40 > * This used to clamp `'max'` down to `'xhigh'`, because the SDK's
41 > * `Settings.effortLevel` .d.ts type omits `'max'`. That type is wrong: the
42 > * Anthropic API / Copilot CAPI accept `'max'` end-to-end — confirmed with
43 > * Anthropic, and verified by watching a `'max'` turn round-trip successfully
44 > * (the exported `EffortLevel` union and the wire `output_config.effort` field
45 > * both include `'max'`). So `'max'` is now passed straight through.
46 > *
47 > * The cast is deliberate: this returns a value its own return type says it
48 > * cannot — `'max'` is not a member of {@link ClaudeRuntimeEffortLevel}. Keeping
49 > * the narrow return type lets every downstream consumer stay honest against the
50 > * SDK's declared surface while the single lie lives here. Drop the cast (and
51 > * widen the return type, or restore a real clamp) once the SDK's
52 > * `Settings.effortLevel` type is corrected upstream
53 > * (anthropics/claude-agent-sdk-typescript#377).
54 > */
55 > export function toRuntimeEffortLevel(effort: ClaudeEffortLevel | undefined): ClaudeRuntimeEffortLevel | undefined {
56 return effort as ClaudeRuntimeEffortLevel | undefined;
57 }
59 > /**
60 > * Pull `thinkingLevel` out of `ModelSelection.config` and narrow it to
61 > * {@link ClaudeEffortLevel}. Returns `undefined` when the model selection
62 > * is absent or carries an unrecognized value (the SDK then falls through
63 > * to its own default). Mirror of CopilotAgent's `_getReasoningEffort`
64 > * (copilotAgent.ts:487).
65 > */
66 > export function resolveClaudeEffort(model: ModelSelection | undefined): ClaudeEffortLevel | undefined {
67 const raw = model?.config?.[CLAUDE_THINKING_LEVEL_KEY];
68 switch (raw) {
77 }
78 }
80 > /** Canonical ordered list of {@link ClaudeEffortLevel} values; used for sort + guard. */
81 > const CLAUDE_EFFORT_LEVELS: readonly ClaudeEffortLevel[] = ['low', 'medium', 'high', 'xhigh', 'max'];
82 >
83 > /** Type guard narrowing an arbitrary string to {@link ClaudeEffortLevel}. */
84 > export function isClaudeEffortLevel(value: string): value is ClaudeEffortLevel {
85 return (CLAUDE_EFFORT_LEVELS as readonly string[]).includes(value);
86 }
88 > /**
89 > * Synthesize the per-model `configSchema` advertising the `thinkingLevel`
90 > * picker entry on Claude models that support adaptive thinking. Mirror of
91 > * CopilotAgent's `_createThinkingLevelConfigSchema` (copilotAgent.ts:457).
92 > *
93 > * The `enum` is sourced from each model's own `reasoning_effort` list (a
94 > * runtime field on CAPI's `/models` payload — different Claude models
95 > * support different effort subsets, e.g. `['low','medium','high']`,
96 > * `['high']`, or `[]`). Callers narrow that list to {@link ClaudeEffortLevel}
97 > * via {@link isClaudeEffortLevel} before passing it in.
98 > *
99 > * The `default` is `'high'` when the model supports it, otherwise omitted
100 > * — Claude's own server-side default for adaptive thinking is `'high'`,
101 > * and the extension mirrors the same fallback rule at
102 > * `extensions/copilot/src/extension/chatSessions/claude/node/claudeCodeModels.ts:230`.
103 > * (Anthropic's `CCAModel` rows don't carry a server-supplied default
104 > * field; tracked at microsoft/vscode-capi#85.)
105 > *
106 > * Returns `undefined` for an empty list — the picker then renders no
107 > * thinkingLevel control for that model.
108 > */
109 > export function createClaudeThinkingLevelSchema(supportedEfforts: readonly ClaudeEffortLevel[]): ConfigSchema | undefined {
110 if (supportedEfforts.length === 0) {
111 return undefined;