diff --git a/src/modules/aix/server/dispatch/chatGenerate/chatGenerate.dispatch.ts b/src/modules/aix/server/dispatch/chatGenerate/chatGenerate.dispatch.ts index 1c4390804..d7d1d5b30 100644 --- a/src/modules/aix/server/dispatch/chatGenerate/chatGenerate.dispatch.ts +++ b/src/modules/aix/server/dispatch/chatGenerate/chatGenerate.dispatch.ts @@ -49,14 +49,24 @@ export function createChatGenerateDispatch(access: AixAPI_Access, model: AixAPI_ const { dialect } = access; switch (dialect) { case 'anthropic': { + + // [Anthropic, 2025-11-24] Detect if any tool uses Programmatic Tool Calling features (allowed_callers, input_examples) + const usesProgrammaticToolCalling = chatGenerate.tools?.some(tool => + tool.type === 'function_call' && ( + tool.function_call.allowed_callers?.includes('code_execution') || + (tool.function_call.input_examples && tool.function_call.input_examples.length > 0) + ), + ) ?? false; + const anthropicRequest = anthropicAccess(access, '/v1/messages', { modelIdForBetaFeatures: model.id, vndAntWebFetch: model.vndAntWebFetch === 'auto', vndAnt1MContext: model.vndAnt1MContext === true, vndAntEffort: !!model.vndAntEffort, enableSkills: !!model.vndAntSkills, - enableToolSearch: !!model.vndAntToolSearch, enableStrictOutputs: !!model.strictJsonOutput || !!model.strictToolInvocations, // [Anthropic, 2025-11-13] for both JSON output and grammar-constrained tool invocations inputs + enableToolSearch: !!model.vndAntToolSearch, + enableProgrammaticToolCalling: usesProgrammaticToolCalling, // enableCodeExecution: ... }); diff --git a/src/modules/llms/server/anthropic/anthropic.access.ts b/src/modules/llms/server/anthropic/anthropic.access.ts index e2b362247..00160241e 100644 --- a/src/modules/llms/server/anthropic/anthropic.access.ts +++ b/src/modules/llms/server/anthropic/anthropic.access.ts @@ -77,8 +77,9 @@ export type AnthropicHeaderOptions = { vndAntEffort?: boolean; // [Anthropic, effort-2025-11-24] enableSkills?: boolean; enableCodeExecution?: boolean; - enableToolSearch?: boolean; // [Anthropic, 2025-11-24] Tool Search Tool enableStrictOutputs?: boolean; // [Anthropic, 2025-11-13] Structured Outputs (JSON outputs & strict tool use) + enableToolSearch?: boolean; // [Anthropic, 2025-11-24] Tool Search Tool + enableProgrammaticToolCalling?: boolean; // [Anthropic, 2025-11-24] Programmatic Tool Calling (allowed_callers, input_examples) clientSideFetch?: boolean; // whether the request will be made from client-side (browser) - adds CORS header }; @@ -163,8 +164,9 @@ function _anthropicHeaders(options?: AnthropicHeaderOptions): Record