fix: extract hardcoded tools list into overridable _tools() method - #905
Open
andrianbalanesq wants to merge 1 commit into
Open
fix: extract hardcoded tools list into overridable _tools() method#905andrianbalanesq wants to merge 1 commit into
andrianbalanesq wants to merge 1 commit into
Conversation
LitellmModel._query passed tools=[BASH_TOOL] as a literal, making it impossible to add custom tools without copying the entire method body into a subclass. Extract the tool list into a _tools() method that defaults to [BASH_TOOL], preserving existing behavior while allowing subclasses to override just the tool list. Closes SWE-agent#889
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
LitellmModel._querypassestools=[BASH_TOOL]as a literal, so the only way to give the model additional tools is to copy the entire_querybody into a subclass and keep that copy in sync on every release.This PR extracts the tool list into a
_tools()method that defaults to[BASH_TOOL], preserving existing behavior while allowing subclasses to override just the tool list.Changes
_tools()method toLitellmModelreturning[BASH_TOOL]by default_queryto callself._tools()instead of using the literaltest_tools_defaults_to_bash_tool— verifies the defaulttest_tools_override_changes_tools_passed_to_completion— verifies that overriding_tools()in a subclass changes what reacheslitellm.completionAll existing tests pass (the 4 pre-existing
portkey_aiimport failures are unrelated — missing optional dependency).Closes #889