src/vs/platform/agentHost/common/claudeModelConfig.ts
128 LOC · 128 covered · 0 uncovered · 14 ranges · 385 concepts · 8 introducers · 218 tests
File neighbourhood
The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.
Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file
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 related-file, concept, and source links on this page.
Graph controls are ready.
Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.
/*---------------------------------------------------------------------------------------------
claudeModelConfig.ts ×4
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from '../../../nls.js';
import { getReasoningEffortDescription, getReasoningEffortLabel } from './reasoningEffort.js';
import type { ConfigSchema, ModelSelection } from './state/protocol/state.js';
/**
* Sub-key in `ModelSelection.config` carrying the user's reasoning-effort
* pick from the model picker. Mirror of CopilotAgent's
* `ThinkingLevelConfigKey` (copilotAgent.ts:83) so a single picker contract
* spans both providers — the picker writes `model.config.thinkingLevel`,
* and each provider narrows that string at materialize.
*/
export const CLAUDE_THINKING_LEVEL_KEY = 'thinkingLevel';
/**
* Reasoning-effort values accepted by the Claude SDK's `Options.effort`
* (startup). Hand-rolled here — not imported from the SDK — to keep `common/`
* SDK-free; structurally identical to the SDK's exported `EffortLevel` so it
* assigns into `Options.effort` without a cast.
*/
export type ClaudeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
/**
* The effort union the SDK's runtime hot-swap setter
* `Query.applyFlagSettings({ effortLevel })` is *declared* to accept. Note it
* excludes `'max'` — but see {@link toRuntimeEffortLevel}: a `'max'` value can
* still flow through this type at runtime, because the SDK's declared type is
* narrower than what the API actually accepts.
*/
export type ClaudeRuntimeEffortLevel = 'low' | 'medium' | 'high' | 'xhigh';
/**
* Coerce a startup {@link ClaudeEffortLevel} to the {@link ClaudeRuntimeEffortLevel}
* union the SDK's `applyFlagSettings({ effortLevel })` setter is typed to accept.
*
* This used to clamp `'max'` down to `'xhigh'`, because the SDK's
* `Settings.effortLevel` .d.ts type omits `'max'`. That type is wrong: the
* Anthropic API / Copilot CAPI accept `'max'` end-to-end — confirmed with
* Anthropic, and verified by watching a `'max'` turn round-trip successfully
* (the exported `EffortLevel` union and the wire `output_config.effort` field
* both include `'max'`). So `'max'` is now passed straight through.
*
* The cast is deliberate: this returns a value its own return type says it
* cannot — `'max'` is not a member of {@link ClaudeRuntimeEffortLevel}. Keeping
* the narrow return type lets every downstream consumer stay honest against the
* SDK's declared surface while the single lie lives here. Drop the cast (and
* widen the return type, or restore a real clamp) once the SDK's
* `Settings.effortLevel` type is corrected upstream
* (anthropics/claude-agent-sdk-typescript#377).
*/
export function toRuntimeEffortLevel(effort: ClaudeEffortLevel | undefined): ClaudeRuntimeEffortLevel | undefined {
}
/**
* Pull `thinkingLevel` out of `ModelSelection.config` and narrow it to
* {@link ClaudeEffortLevel}. Returns `undefined` when the model selection
* is absent or carries an unrecognized value (the SDK then falls through
* to its own default). Mirror of CopilotAgent's `_getReasoningEffort`
* (copilotAgent.ts:487).
*/
export function resolveClaudeEffort(model: ModelSelection | undefined): ClaudeEffortLevel | undefined {
switch (raw) {
case 'low':
case 'medium':
case 'high':
case 'xhigh':
case 'max':
}
/** Canonical ordered list of {@link ClaudeEffortLevel} values; used for sort + guard. */
const CLAUDE_EFFORT_LEVELS: readonly ClaudeEffortLevel[] = ['low', 'medium', 'high', 'xhigh', 'max'];
/** Type guard narrowing an arbitrary string to {@link ClaudeEffortLevel}. */
export function isClaudeEffortLevel(value: string): value is ClaudeEffortLevel {
}
/**
* Synthesize the per-model `configSchema` advertising the `thinkingLevel`
* picker entry on Claude models that support adaptive thinking. Mirror of
* CopilotAgent's `_createThinkingLevelConfigSchema` (copilotAgent.ts:457).
*
* The `enum` is sourced from each model's own `reasoning_effort` list (a
* runtime field on CAPI's `/models` payload — different Claude models
* support different effort subsets, e.g. `['low','medium','high']`,
* `['high']`, or `[]`). Callers narrow that list to {@link ClaudeEffortLevel}
* via {@link isClaudeEffortLevel} before passing it in.
*
* The `default` is `'high'` when the model supports it, otherwise omitted
* — Claude's own server-side default for adaptive thinking is `'high'`,
* and the extension mirrors the same fallback rule at
* `extensions/copilot/src/extension/chatSessions/claude/node/claudeCodeModels.ts:230`.
* (Anthropic's `CCAModel` rows don't carry a server-supplied default
* field; tracked at microsoft/vscode-capi#85.)
*
* Returns `undefined` for an empty list — the picker then renders no
* thinkingLevel control for that model.
*/
export function createClaudeThinkingLevelSchema(supportedEfforts: readonly ClaudeEffortLevel[]): ConfigSchema | undefined {
}
const defaultEffort: ClaudeEffortLevel | undefined = supportedEfforts.includes('high') ? 'high' : undefined;
claudeModelConfig.ts ×2
return {
type: 'object',
properties: {
[CLAUDE_THINKING_LEVEL_KEY]: {
type: 'string',
title: localize('claude.modelThinkingLevel.title', "Thinking Level"),
description: localize('claude.modelThinkingLevel.description', "Controls how much reasoning effort Claude uses."),
enum: [...supportedEfforts],
enumLabels: supportedEfforts.map(getReasoningEffortLabel),
enumDescriptions: supportedEfforts.map(effort => getReasoningEffortDescription(effort) ?? ''),
...(defaultEffort !== undefined ? { default: defaultEffort } : {}),
},
},
};
}