feat: Allow instance-level customization of tool parameters#572
Open
psdaniel wants to merge 2 commits intocrmne:mainfrom
Open
feat: Allow instance-level customization of tool parameters#572psdaniel wants to merge 2 commits intocrmne:mainfrom
psdaniel wants to merge 2 commits intocrmne:mainfrom
Conversation
Add support for customizing tool description, parameters, and provider_params at the instance level, with fallback to class-level definitions when not overridden. - Add initialize method with optional description, parameters, and provider_params arguments - Modify instance getters to check instance values first, then fall back to class-level definitions - Add instance setters for post-initialization customization - Update params_schema to generate schema from instance parameters - Add comprehensive unit tests for instance-level customization - Add integration tests for customized tools with Chat Closes crmne#418
Allow users to explicitly set unique names for tool instances, solving the name collision issue where multiple instances of the same tool class would overwrite each other in the chat's tools hash. - Add name: parameter to Tool#initialize - Update name getter to check @instance_name first - Add name= setter for post-initialization customization - Add unit and integration tests - Document instance-level customization in tools.md
SpaYco
reviewed
Jan 26, 2026
Comment on lines
+260
to
+261
| berlin_weather = Weather.new(description: "Get current weather in Berlin") | ||
| paris_weather = Weather.new(description: "Get current weather in Paris") |
There was a problem hiding this comment.
With the current implementation, this would fail without giving a name, as both would have the same name and get overwritten.
I think the current name approach is great, as this won't break the overwriting functionality, but we need to be clear in the docs.
Comment on lines
+121
to
+125
| if @instance_parameters | ||
| return SchemaDefinition.from_parameters(@instance_parameters)&.json_schema if @instance_parameters.any? | ||
|
|
||
| return nil | ||
| end |
There was a problem hiding this comment.
Suggested change
| if @instance_parameters | |
| return SchemaDefinition.from_parameters(@instance_parameters)&.json_schema if @instance_parameters.any? | |
| return nil | |
| end | |
| if @instance_parameters | |
| return SchemaDefinition.from_parameters(@instance_parameters)&.json_schema | |
| end |
Line 122 in bd2bb14
SchemaDefinition.from_parameters would return nil if the value is nil or empty.
we can also just one line it
Suggested change
| if @instance_parameters | |
| return SchemaDefinition.from_parameters(@instance_parameters)&.json_schema if @instance_parameters.any? | |
| return nil | |
| end | |
| return SchemaDefinition.from_parameters(@instance_parameters)&.json_schema if @instance_parameters |
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.
Summary
Enable instance-level customization of tools, allowing different instances of the same tool class to have unique configurations:
name,description,parameters, andprovider_paramsat the instance levelMotivation
Closes #418
Currently, RubyLLM tools define descriptions and parameters at the class level only, meaning all instances share the same configuration. This limits flexibility for use cases like:
Usage
Test plan
initializewith optional parameters (name,description,parameters,provider_params)params_schemawith instance parameters