Skip to content

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

Description

@albertovasquez

LitellmModel._query passes tools=[BASH_TOOL] as a literal, so the only way to give the
model any other tool is to copy the whole _query body into a subclass and keep that copy
in sync on every release. I've been doing that in a wrapper for a while, and it's the one
override that breaks quietly when the method changes underneath me.

The fix is small: move the tool list into a _tools() method that defaults to [BASH_TOOL].

Today, in src/minisweagent/models/litellm_model.py:

def _query(self, messages: list[dict[str, str]], **kwargs):
    try:
        return litellm.completion(
            model=self.config.model_name,
            messages=messages,
            tools=[BASH_TOOL],          # hardcoded — this is the whole problem
            **(self.config.model_kwargs | kwargs),
        )
    except litellm.exceptions.AuthenticationError as e:
        e.message += " You can permanently set your API key with `mini-extra config set KEY VALUE`."
        raise e

Because the list lives inside the method, overriding it means dragging along the
litellm.completion(...) call and the auth-error handling too — and re-pinning all of it
whenever upstream touches _query.

Proposed:

def _tools(self) -> list[dict]:
    """Tool schemas offered to the model. Override to expose more than bash."""
    return [BASH_TOOL]

def _query(self, messages: list[dict[str, str]], **kwargs):
    try:
        return litellm.completion(
            model=self.config.model_name,
            messages=messages,
            tools=self._tools(),
            **(self.config.model_kwargs | kwargs),
        )
    except litellm.exceptions.AuthenticationError as e:
        e.message += " You can permanently set your API key with `mini-extra config set KEY VALUE`."
        raise e

BASH_TOOL stays the default, so existing runs are unchanged. The single-tool default is
fine and I'm not proposing to touch it — I just want the list to be overridable without
forking the method. A couple of older threads circled this same need (#470, #563) without
landing on a clean way to do it.

Happy to open the PR: the change plus a test that _tools() defaults to [BASH_TOOL] and
that overriding it changes what reaches litellm.completion. Filing first in case you'd
prefer a different shape — a config field rather than a method, say.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions