Skip to content

fix(ai-adapters): strip tool_choice when no OpenAI tools are attached#889

Merged
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:fix/openai-remove-tool-choice-without-tools
May 26, 2026
Merged

fix(ai-adapters): strip tool_choice when no OpenAI tools are attached#889
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:fix/openai-remove-tool-choice-without-tools

Conversation

@bobleer
Copy link
Copy Markdown
Collaborator

@bobleer bobleer commented May 26, 2026

Summary

  • Remove stale tool_choice from OpenAI request bodies when no tools are attached (tools absent or empty array).
  • Prevents OpenAI API rejections that occur when tool_choice is present without a corresponding tools array.
  • Add unit tests covering the no-tools, empty-tools, and explicit-tool-choice-with-tools cases.

Test plan

  • cargo test -p bitfun-ai-adapters attach_tools -- --nocapture

OpenAI rejects requests that include tool_choice without a tools array.
Remove stale tool_choice from the request body when tools are absent or empty.
@bobleer bobleer merged commit 51dfa35 into GCWing:main May 26, 2026
1 check passed
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