Skip to content

Pass tool_choice to RubyLLM - #722

Merged
TonsOfFun merged 1 commit into
activeagents:mainfrom
pcbeingused333:fix/ruby-llm-tool-choice-required
Nov 19, 2026
Merged

TonsOfFun merged 1 commit into
activeagents:mainfrom
pcbeingused333:fix/ruby-llm-tool-choice-required

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

RubyLLMProvider read tool_choice only for ToolChoiceClearing (to drop it after the tool was used) and never put it in the provider.complete call. So tool_choice: "required", or a named tool, was silently ignored and a generation could finish without calling any tool even though the caller required one.

The adapter now sends it as RubyLLM's tool_prefs: { choice: } (:required, :auto, :none, or the tool name), only when the request has tools. Once ToolChoiceClearing has cleared it after the tool ran, later turns send nothing, so the tool loop still ends. RubyLLM 1.x and 2.x both accept tool_prefs.

Test: test/providers/ruby_llm/ruby_llm_provider_test.rb gets three cases (required, a named tool, none set); the first two fail on main with tool_prefs missing. The RubyLLM provider, wire-format and streaming test files pass on both ruby_llm_1 and ruby_llm_2 gemfiles. A CHANGELOG entry is included.

This change was made with Claude Code; the tests above were run on the branch.

🤖 Generated with Claude Code

The adapter read tool_choice only to clear it between turns and never
sent it, so tool_choice: "required" (or a named tool) was ignored and a
generation could end without any tool call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@TonsOfFun TonsOfFun added this to the 1.9.10 milestone Nov 19, 2026
@TonsOfFun
TonsOfFun merged commit a976deb into activeagents:main Nov 19, 2026
18 checks passed
yorzi pushed a commit to yorzi/activeagent that referenced this pull request Nov 19, 2026
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