fix: Use tool_name from ToolMeta instead of Ruby class name in RubyLLM tools#17
Merged
Conversation
…M tools RubyLLM::Tool#name generates names from Ruby class names (e.g. Tools::CreativeUpdate -> 'tools--creative_update'), which doesn't match the tool_name defined via ToolMeta (e.g. 'creative_update_service'). Override the name method in dynamically generated tool classes to return the original tool_name from the schema, ensuring consistent naming across the system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RubyLLM::Tool#namegenerates tool names from Ruby class names:Tools::CreativeUpdate→tools--creative_updateBut
ToolMetadefines explicit tool names (e.g.creative_update_service). This mismatch causes issues when external systems (like approval flows) try to look up tools by name.Solution
Override the
namemethod in dynamically generated RubyLLM tool classes to return thetool_namefrom ToolMeta schema, ensuring consistent naming.Changes
ruby_llm_factory.rbdefine_method(:name) { tool_name }overridetool_schema_test.rbTests
8 runs, 26 assertions, 0 failures ✅