Skip to content

OpenAI endpoint required toolchoice - #930

Closed
bearsyankees wants to merge 4 commits into
mainfrom
devin/1785295649-openai-endpoint-required-toolchoice
Closed

OpenAI endpoint required toolchoice#930
bearsyankees wants to merge 4 commits into
mainfrom
devin/1785295649-openai-endpoint-required-toolchoice

Conversation

@bearsyankees

Copy link
Copy Markdown
Collaborator

No description provided.

…stom endpoints

Reasoning models on OpenAI-compatible custom endpoints (e.g. GLM / Kimi)
often reason and reply with prose instead of emitting native tool calls
under the default auto tool choice, stalling the tool-driven scan loop
while burning tokens. Default force_required_tool_choice to auto (None):
enable tool_choice=required when an api_base is set (still gated to
models that accept it), off otherwise. Explicit 0/1 overrides.
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR automatically requires tool calls for OpenAI-compatible custom endpoints and preserves provider-reported OpenRouter streaming costs.

  • Changes the required-tool-choice setting to support automatic, enabled, and disabled modes.
  • Threads custom API-base detection into model settings.
  • Captures OpenRouter stream costs by response ID and prioritizes them over estimated costs.
  • Adds coverage for tool-choice resolution, streamed cost recovery, and runner settings.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code defect identified.

The endpoint-aware tool-choice behavior preserves explicit overrides and provider filtering, while the OpenRouter integration retains existing stream parsing and safely correlates exact costs under a lock.

Important Files Changed

Filename Overview
strix/config/models.py Installs a LiteLLM OpenRouter streaming-handler subclass that captures provider-reported cost without changing current parsing behavior.
strix/config/settings.py Makes required tool choice tri-state so an unset value can activate endpoint-aware defaults.
strix/core/inputs.py Resolves automatic required tool choice for supported OpenAI-style models using custom API endpoints while preserving explicit overrides.
strix/core/runner.py Threads the presence of a configured API base into model-setting construction.
strix/report/state.py Adds synchronized response-ID cost correlation and consumes exact streamed OpenRouter costs before falling back to estimation.
tests/test_cost_tracking.py Covers OpenRouter cost extraction, stream correlation, cleanup, precedence, and LiteLLM provider resolution.
tests/test_inputs.py Covers automatic and explicitly overridden required-tool-choice behavior across endpoint and provider combinations.

Reviews (1): Last reviewed commit: "fix(toolchoice): default required tool c..." | Re-trigger Greptile

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