From aa697edb8ca111d61616747c8aa1acf3cdf4050e Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Fri, 6 Feb 2026 19:18:54 -0800 Subject: [PATCH] AIX: Anthropic: minor API changes --- src/modules/aix/server/api/aix.wiretypes.ts | 2 +- .../adapters/anthropic.messageCreate.ts | 7 +++++ .../llms/server/anthropic/anthropic.access.ts | 30 +++++-------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/modules/aix/server/api/aix.wiretypes.ts b/src/modules/aix/server/api/aix.wiretypes.ts index 310ebe0da..89b012fed 100644 --- a/src/modules/aix/server/api/aix.wiretypes.ts +++ b/src/modules/aix/server/api/aix.wiretypes.ts @@ -497,8 +497,8 @@ export namespace AixWire_API { */ userGeolocation: z.object({ city: z.string().optional(), // free text input for the city of the user, e.g. San Francisco. - country: z.string().optional(), // two-letter ISO country code of the user, e.g. US region: z.string().optional(), // free text input for the reg. of the user the user, e.g. California + country: z.string().optional(), // two-letter ISO country code of the user, e.g. US timezone: z.string().optional(), // IANA timezone of the user, e.g. America/Los_Angeles }).optional(), }); diff --git a/src/modules/aix/server/dispatch/chatGenerate/adapters/anthropic.messageCreate.ts b/src/modules/aix/server/dispatch/chatGenerate/adapters/anthropic.messageCreate.ts index 9958f0a74..4f7a56b3f 100644 --- a/src/modules/aix/server/dispatch/chatGenerate/adapters/anthropic.messageCreate.ts +++ b/src/modules/aix/server/dispatch/chatGenerate/adapters/anthropic.messageCreate.ts @@ -136,6 +136,9 @@ export function aixToAnthropicMessageCreate(model: AixAPI_Model, _chatGenerate: const areToolCallsRequired = payload.tool_choice && typeof payload.tool_choice === 'object' && (payload.tool_choice.type === 'any' || payload.tool_choice.type === 'tool'); const canUseThinking = !areToolCallsRequired || !hotFixDisableThinkingWhenToolsForced; if (model.vndAntThinkingBudget !== undefined && canUseThinking) { + // NOTE: We don't want to maintain patches here - so just FYI: budget_tokens is deprecated on Opus 4.6 in favor of adaptive thinking + // if (typeof model.vndAntThinkingBudget === 'number' && model.id.includes('opus-4-6')) + // console.warn('[Anthropic] budget_tokens is deprecated on Opus 4.6 - use adaptive thinking instead'); payload.thinking = model.vndAntThinkingBudget === 'adaptive' ? { type: 'adaptive', } : model.vndAntThinkingBudget !== null ? { @@ -187,6 +190,10 @@ export function aixToAnthropicMessageCreate(model: AixAPI_Model, _chatGenerate: type: 'web_search_20250305', name: 'web_search', max_uses: 10, // Allow up to 10 progressive searches // FIXME: HARDCODED + // Pass user geolocation for location-aware search results + ...(model.userGeolocation ? { + user_location: { type: 'approximate' as const, ...model.userGeolocation }, + } : {}), }); } diff --git a/src/modules/llms/server/anthropic/anthropic.access.ts b/src/modules/llms/server/anthropic/anthropic.access.ts index 107dc1ec1..4a115dc6a 100644 --- a/src/modules/llms/server/anthropic/anthropic.access.ts +++ b/src/modules/llms/server/anthropic/anthropic.access.ts @@ -52,29 +52,15 @@ const DEFAULT_ANTHROPIC_HEADERS = { const DEFAULT_ANTHROPIC_BETA_FEATURES: string[] = [ - // NOTE: undocumented: I wonder what this is for - // 'claude-code-20250219', + // Known SDK beta headers (for reference, not all used): + // prompt-caching-2024-07-31 -- GA: no longer needed + // pdfs-2024-09-25 -- GA: no longer needed + // token-efficient-tools-2025-02-19 -- not used; disabled for now as side-effects are untested + // extended-cache-ttl-2025-04-11 -- for 1h cache TTL; we support ttl:'1h' in wiretypes already + // interleaved-thinking-2025-05-14 -- for Claude 4/4.5 interleaved thinking (auto on Opus 4.6 adaptive) + // context-management-2025-06-27 -- for context_management edits (e.g. clear_tool_uses) + // model-context-window-exceeded-2025-08-26 -- Sonnet 4.5+ have this by default - // NOTE: disabled for now, as we don't have tested side-effects for this feature yet - // 'token-efficient-tools-2025-02-19', // https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use - - /** - * to use the prompt caching feature; adds to any API invocation: - * - message_start.message.usage.cache_creation_input_tokens: number - * - message_start.message.usage.cache_read_input_tokens: number - */ - 'prompt-caching-2024-07-31', - - /** - * Enables model_context_window_exceeded stop reason for models earlier than Sonnet 4.5 - * (Sonnet 4.5+ have this by default). This allows requesting max tokens without calculating - * input size, and the API will return as much as possible within the context window. - * https://docs.claude.com/en/api/handling-stop-reasons#model-context-window-exceeded - */ - // 'model-context-window-exceeded-2025-08-26', - - // now default - // 'messages-2023-12-15' ] as const; const PER_MODEL_BETA_FEATURES: { [modelId: string]: string[] } = {