Skip to content

Commit 24e660a

Browse files
fix: disable Anthropic thinking to fix tool chain crash (#415)
* fix: disable Anthropic thinking to fix tool chain crash Anthropic's API rejects requests that combine extended thinking with forced tool_choice. The ToolLoopAgent enables thinking globally, and prepareStep forces toolChoice for every tool chain step (create_new_artist, create_release_report). This causes "Thinking may not be enabled when tool_choice forces tool use" on any Anthropic model. The Vercel AI SDK does not support overriding providerOptions per-step (open issue vercel/ai#11761), so the fix must be at the constructor level. Disables Anthropic thinking until the SDK adds per-step providerOptions support or an alternative approach is implemented. Made-with: Cursor * fix: use fallback model for tool chain steps to avoid Anthropic thinking conflict Instead of disabling Anthropic thinking globally, tool chain steps now switch to openai/gpt-5-mini (via TOOL_CHAIN_FALLBACK_MODEL) when no specific model is mapped in TOOL_MODEL_MAP. This preserves extended thinking for regular Anthropic conversations while ensuring forced toolChoice works during tool chain execution. Made-with: Cursor * chore: use openai/gpt-5.4-mini as tool chain fallback model Made-with: Cursor * style: fix prettier formatting on import Made-with: Cursor * refactor: remove TOOL_CHAIN_FALLBACK_MODEL, use TOOL_MODEL_MAP for all chain tools Addresses code review feedback — use existing TOOL_MODEL_MAP pattern instead of a separate fallback constant. All tool chain tools now have explicit model entries in TOOL_MODEL_MAP. Made-with: Cursor --------- Co-authored-by: sswift <159544713+sswiftdrtv@users.noreply.github.com>
1 parent fe1e264 commit 24e660a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/chat/toolChains/getPrepareStepResult.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const getPrepareStepResult = (options: PrepareStepOptions): PrepareStepResult |
5757
result.messages = options.messages.concat(nextToolItem.messages);
5858
}
5959

60-
// Add model if specified for this tool
6160
const model = TOOL_MODEL_MAP[nextToolItem.toolName];
6261
if (model) {
6362
result.model = model;

lib/chat/toolChains/toolChains.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ export type PrepareStepResult = {
1515
messages?: ModelMessage[];
1616
};
1717

18-
// Map specific tools to their required models
18+
// Forced toolChoice is incompatible with Anthropic extended thinking.
19+
// Every tool used in a chain must have a model here to avoid the conflict.
1920
export const TOOL_MODEL_MAP: Record<string, LanguageModel> = {
2021
update_account_info: "gemini-2.5-pro",
21-
// Add other tools that need specific models here
22-
// e.g., create_segments: "gpt-4-turbo",
22+
get_spotify_search: "openai/gpt-5.4-mini",
23+
update_artist_socials: "openai/gpt-5.4-mini",
24+
artist_deep_research: "openai/gpt-5.4-mini",
25+
spotify_deep_research: "openai/gpt-5.4-mini",
26+
get_artist_socials: "openai/gpt-5.4-mini",
27+
get_spotify_artist_top_tracks: "openai/gpt-5.4-mini",
28+
get_spotify_artist_albums: "openai/gpt-5.4-mini",
29+
get_spotify_album: "openai/gpt-5.4-mini",
30+
search_web: "openai/gpt-5.4-mini",
31+
generate_txt_file: "openai/gpt-5.4-mini",
32+
create_segments: "openai/gpt-5.4-mini",
33+
youtube_login: "openai/gpt-5.4-mini",
34+
web_deep_research: "openai/gpt-5.4-mini",
35+
create_knowledge_base: "openai/gpt-5.4-mini",
36+
send_email: "openai/gpt-5.4-mini",
2337
};
2438

2539
// Map trigger tool -> sequence AFTER trigger

0 commit comments

Comments
 (0)