Skip to content

fix(py/openai): fail locally when tools are sent to reasoning models without reasoning_effort='none' - #271

Closed
pcbeingused33 wants to merge 1 commit into
genkit-ai:mainfrom
pcbeingused33:fix/openai-tools-reasoning-effort-c7927
Closed

pcbeingused33 wants to merge 1 commit into
genkit-ai:mainfrom
pcbeingused33:fix/openai-tools-reasoning-effort-c7927

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

Fixes #194

On Chat Completions, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, gpt-6-sol, gpt-6-luna and gpt-6.1-terra accept function tools only with reasoning_effort='none', and they do not default to it. Their catalog info advertises tools=True, so a call such as ai.generate(model=OpenAI.gpt('gpt-6-sol'), prompt='...', tools=['get_weather']) goes out with tools and no reasoning_effort, and the API answers with a 400.

This follows the proposal in #194. When the request has tools and the target is OpenAI's own endpoint, OpenAIModel raises GenkitError(INVALID_ARGUMENT) naming reasoning_effort='none' before the request is sent, the same way the GPT Image xhigh/max check works.

  • Applies only to those model ids and their dated snapshots (-YYYY-MM-DD), using the effective model (config.model / config.version / the model name).
  • Reads reasoning_effort from config and from extra. extra goes out as extra_body, which replaces the top-level field, so extra wins when both are set.
  • Skipped for OpenAICompatible and for Mistral, since other hosts may serve the same ids under different rules. OpenAI passes openai=True to OpenAIModel; everything else keeps the old behaviour.
  • Auto-sending reasoning_effort='none' was rejected in the issue because it changes reasoning without the user asking, so it is not done here.

Tests (openai_tools_reasoning_effort_test.py, 21 cases; the full OpenAI plugin suite passes, 1077 tests): four of the listed ids plus a dated snapshot, each with no config, a non-none effort in config, and a non-none effort in extra fails with INVALID_ARGUMENT and sends no request; none in config or extra goes through with tools and reasoning_effort='none'; extra overrides config; no tools, other models and OpenAICompatible are untouched.

AI assistance was used to prepare this change.

…without reasoning_effort='none'

gpt-5.6-{sol,terra,luna}, gpt-6-{sol,luna} and gpt-6.1-terra (and their dated
snapshots) accept function tools on Chat Completions only with
reasoning_effort='none'. Raise INVALID_ARGUMENT before the request when the
OpenAI plugin sends tools without it, reading config and extra. OpenAI-compatible
hosts are not checked.

Fixes genkit-ai#194
@genkit-bot

Copy link
Copy Markdown

Thanks for your interest in Genkit. We're closing this pull request because we can't accept it in its current form. If you'd like to contribute, please start a discussion with the maintainers on an issue first; see CONTRIBUTING.md.

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.

[py/openai] Fail locally when tools are sent to reasoning models without reasoning_effort='none'

3 participants