Skip to content

Fix tool search failing with reasoning models#44

Merged
vl3c merged 1 commit intomainfrom
fix/tool-search-reasoning-model-compat
Feb 16, 2026
Merged

Fix tool search failing with reasoning models#44
vl3c merged 1 commit intomainfrom
fix/tool-search-reasoning-model-compat

Conversation

@vl3c
Copy link
Copy Markdown
Owner

@vl3c vl3c commented Feb 16, 2026

Summary

  • Tool search service inherits the user's active model. When that model is a reasoning model (o3, o4-mini, gpt-5*), the Chat Completions API call fails with max_tokens is not supported with this model
  • Additionally, reasoning models include internal reasoning tokens in the max_completion_tokens budget — 500 tokens may not leave enough room for the actual JSON output
  • Fix: for OpenAI reasoning models, automatically downgrade to gpt-4.1-mini for tool search — it's a lightweight classification task that doesn't benefit from reasoning, and this avoids both the parameter incompatibility and the token budget issue
  • Non-OpenAI providers (local models, Anthropic) are unaffected

Test plan

  • mypy passes on static/tool_search_service.py
  • All 67 tool search service tests pass
  • Manual: with a reasoning model active (e.g. o4-mini), ask the AI to "skew a triangle" — tool search should succeed and discover shear_object

🤖 Generated with Claude Code

Reasoning models (o3, o4-mini, gpt-5*) reject the max_tokens parameter
in the Chat Completions API and require max_completion_tokens instead.
When the user's active model is a reasoning model, the tool search
service inherits that model and the API call fails with a 400 error,
preventing tool discovery entirely.

Tool search is a lightweight classification task that doesn't benefit
from reasoning. For OpenAI reasoning models, automatically downgrade
to gpt-4.1-mini which is cheaper, faster, and uses the standard
max_tokens parameter without issues.
@vl3c vl3c force-pushed the fix/tool-search-reasoning-model-compat branch from 3c50ce3 to 331d70e Compare February 16, 2026 20:25
@vl3c vl3c merged commit 4b08c1c into main Feb 16, 2026
1 check passed
@vl3c vl3c deleted the fix/tool-search-reasoning-model-compat branch February 16, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant