Skip to content

fix: extract hardcoded tools list into overridable _tools() method - #905

Open
andrianbalanesq wants to merge 1 commit into
SWE-agent:mainfrom
andrianbalanesq:fix/extract-tools-method
Open

fix: extract hardcoded tools list into overridable _tools() method#905
andrianbalanesq wants to merge 1 commit into
SWE-agent:mainfrom
andrianbalanesq:fix/extract-tools-method

Conversation

@andrianbalanesq

Copy link
Copy Markdown

Summary

LitellmModel._query passes tools=[BASH_TOOL] as a literal, so the only way to give the model additional tools is to copy the entire _query body 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

  • Add _tools() method to LitellmModel returning [BASH_TOOL] by default
  • Update _query to call self._tools() instead of using the literal
  • Add test_tools_defaults_to_bash_tool — verifies the default
  • Add test_tools_override_changes_tools_passed_to_completion — verifies that overriding _tools() in a subclass changes what reaches litellm.completion

All existing tests pass (the 4 pre-existing portkey_ai import failures are unrelated — missing optional dependency).

Closes #889

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
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.

LitellmModel._query hardcodes tools=[BASH_TOOL] — no way to add tools without copying the whole method

2 participants