Skip to content

Support reasoning_effort in the OpenAI client#37428

Merged
abhishekkrthakur merged 2 commits into
masterfrom
add-reasoning-effort-option
Jul 20, 2026
Merged

Support reasoning_effort in the OpenAI client#37428
abhishekkrthakur merged 2 commits into
masterfrom
add-reasoning-effort-option

Conversation

@abhishekkrthakur

Copy link
Copy Markdown
Contributor

Why

Reasoning models (Gemini 2.5+/3.x, OpenAI o-series/gpt-5) count thinking tokens against max_completion_tokens, and some default to unbounded dynamic thinking. Through ai.vespa.llm.clients.OpenAI there is currently no way to control this: the client maps a fixed set of options and drops everything else, so callers can neither bound latency nor stop thinking from consuming the completion budget.

Observed concretely with Gemini via Vertex AI's OpenAI-compatible endpoint (from an LLM query-planning Searcher, where the call is on the query path): gemini-3.5-flash spends 5–9 s thinking per call, and with a small maxTokens the visible output is truncated mid-JSON because thinking consumed the budget.

What

  • InferenceParameters.OPTION_REASONING_EFFORT (reasoningEffort) + vespajlib abi-spec update
  • reasoningEffort string default="" in llm-client.def so it can be set per component; per-request option overrides it, matching the other options
  • Mapped in the OpenAI client via ReasoningEffort.of(...) — values pass through as-is, since accepted sets differ per provider (OpenAI: minimal|low|medium|high; Google's compat API also accepts none). openai-java 1.6.1 (already pinned) supports this; no dependency change.
  • Unit test covering unset (not sent), component config, and per-request override with a non-enum value. getChatCompletionCreateParams/prepareParameters made package-private for testing, consistent with the file's existing test seams.

mvn test for ai.vespa.llm.clients.*: 89 run, 0 failures.

🤖 Generated with Claude Code

Reasoning models count thinking tokens against max_completion_tokens and
some default to unbounded dynamic thinking, so without this option there
is no way to bound latency or keep thinking from consuming the completion
budget through OpenAI-compatible endpoints (observed with Gemini via
Vertex AI: 5-9s per call, or truncated JSON when capped by maxTokens).

Adds InferenceParameters.OPTION_REASONING_EFFORT and a reasoningEffort
config on llm-client, mapped to the chat completions reasoning_effort
field. Values pass through as-is since providers accept different sets
(OpenAI: minimal/low/medium/high; Google's compat API also takes none).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@abhishekkrthakur
abhishekkrthakur merged commit 296ccca into master Jul 20, 2026
3 checks passed
@abhishekkrthakur
abhishekkrthakur deleted the add-reasoning-effort-option branch July 20, 2026 14:32
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.

2 participants