Skip to content

Add built-in support for tool control parameters #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nwumnn
Copy link

@nwumnn nwumnn commented Aug 15, 2025

What this does

Adds tool choice and parallel tool calls options to the with_tool and with_tools method.

Users can now specify:

  • choice: control how the model should use tools (auto, none, any, or specific tool name)
  • parallel: boolean parameter to allow/disallow parallel tool calls
chat.with_tools(MyTool, choice: :any, parallel: false)
chat.with_tool(SpecificTool, choice: :specific_tool_name, parallel: false)

Also updates the handle_tool_calls method. With :any or specific tool choices, tool results are not automatically sent back to the model to prevent infinite loops.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Related issues

Fixes #343

nwumnn added 2 commits August 14, 2025 16:55
- Implement provider-specific tool choice handling
- Add InvalidToolChoiceError for validation
- Enhance tool execution flow to prevent infinite loops with non-auto choices
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.

[FEATURE] Add built-in support for tool control parameters
1 participant