Skip to content

πŸŽ›οΈ fix: Forward Client tool_choice and parallel_tool_calls When Binding Tools - #734

Merged
berry-13 merged 2 commits into
mainfrom
berry-13/bug-17154-tool-choice
Nov 23, 2026
Merged

berry-13 merged 2 commits into
mainfrom
berry-13/bug-17154-tool-choice

Conversation

@berry-13

Copy link
Copy Markdown
Collaborator

Summary

ChatOpenAI only reads tool_choice and parallel_tool_calls from call options, never from constructor fields. initializeModel bound tools with bindTools(tools) and no options, so a host that set either value on OpenAI-compatible client options (LibreChat custom endpoint addParams) got a request without them, silently.

initializeModel now forwards both values to bindTools for OpenAI-like providers when tools are bound. Disabled tool calling (summaries) still sends tool_choice: 'none' and nothing else, so a configured required cannot override it. Tool-less calls (titles, labels) are unchanged, other provider families keep their current binding, and malformed values are ignored.

Related to LibreChat-AI/LibreChat#17154. LibreChat picks this up through a dependency bump after the next release.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • npx jest src/llm/init.test.ts: 16 passed. The two forwarding cases fail on main (both fields absent from the captured request body) and pass here; the disabled-tool-calling, tool-less, and malformed cases pass on both.
  • reviewctl precheck --local: typecheck, sort-imports, eslint, and the related Jest suites (2411 tests) pass.
  • src/llm/anthropic/llm.spec.ts needs a live Anthropic key and was not run.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

…Tools

ChatOpenAI reads tool_choice and parallel_tool_calls only from call
options, so values hosts set on OpenAI-compatible client options (for
example LibreChat custom endpoint addParams) never reached the request.
initializeModel now passes them to bindTools for OpenAI-like providers.
Disabled tool calling keeps tool_choice none, tool-less calls are
unchanged, and other provider families keep their current binding.
@berry-13 berry-13 added the bug Something isn't working label Nov 23, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: βœ… Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-11-23T08:07:58.452940Z 4fbe50a New commits
πŸ”’ Security Review βœ… Completed 2026-11-23T08:09:22.578328Z c0aee04 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

@berry-13
berry-13 merged commit 8bfd8de into main Nov 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant