Skip to content

Tool configuration

This shows how to configure tools for SWE-agent.

Tool configuration

This is the page for configuring tools for SWE-agent, not for setting up the tools that are being used for the agent. For the latter, see tool bundles.

sweagent.tools.tools.ToolConfig pydantic-model

Bases: BaseModel

Configuration for the tools that are made available to the agent.

Fields:

filter pydantic-field

Filter out commands that are blocked by the environment (for example interactive commands like vim).

bundles pydantic-field

bundles: list[Bundle]

The tool bundles to load.

propagate_env_variables pydantic-field

propagate_env_variables: list[str] = []

Environment variables to propagate to the environment. This is useful if you want to propagate API keys or similar from your own environment to the environment in which the tools run. IMPORTANT NOTE: The value of the environment variables can be read in debug log files, so be careful with your API keys!

env_variables pydantic-field

env_variables: dict[str, Any] = {'PAGER': 'cat', 'MANPAGER': 'cat', 'LESS': '-R', 'PIP_PROGRESS_BAR': 'off', 'TQDM_DISABLE': '1', 'GIT_PAGER': 'cat'}

Shorthand to set environment variables for the tools, effectively equivalent to adding export VARNAME=value to the reset_commands.

registry_variables pydantic-field

registry_variables: dict[str, Any] = {}

Populate the registry with these variables. Will be written out as json in the registry file.

submit_command pydantic-field

submit_command: str = 'submit'

The command/tool to use to submit the solution.

parse_function pydantic-field

parse_function: ParseFunction

The action parser that is responsible for parsing the model output into a thought and action.

enable_bash_tool pydantic-field

enable_bash_tool: bool = True

Whether to enable the bash tool in addition to the other tools specified in bundles.

format_error_template pydantic-field

format_error_template: str = None

Defaults to format_error_template in ParseFunction

command_docs pydantic-field

command_docs: str = None

Automatically generated documentation generated based on the loaded tool bundles.

multi_line_command_endings pydantic-field

multi_line_command_endings: dict[str, str] = {}

submit_command_end_name pydantic-field

submit_command_end_name: str | None = None

Commands to install dependencies and tools. These commands are executed in a subprocess and are not part of the environment state.

reset_commands pydantic-field

reset_commands: list[str | list[str]] = []

Commands to reset the environment. They will also be called when we start the environment. Unlike install_commands, these commands are part of the environment state.

execution_timeout pydantic-field

execution_timeout: int = 30

Timeout for executing commands in the environment

install_timeout pydantic-field

install_timeout: int = 300

Timeout used for each of the installation commands

total_execution_timeout pydantic-field

total_execution_timeout: int = 1800

Timeout for executing all commands in the environment. Note: Does not interrupt running commands, but will stop the agent for the next step.

max_consecutive_execution_timeouts pydantic-field

max_consecutive_execution_timeouts: int = 3

Maximum number of consecutive execution timeouts before the agent exits.

use_function_calling cached property

use_function_calling: bool

state_commands cached property

state_commands: list[str]

This property returns the state commands from all bundles. State commands are commands that are used to get the state of the environment (e.g., the current working directory).

commands cached property

commands: list[Command]

Read command files and return parsed command objects

tools cached property

tools: list[dict]

sweagent.tools.tools.ToolFilterConfig pydantic-model

Bases: BaseModel

Filter out commands that are blocked by the environment (for example interactive commands like vim).

Fields:

blocklist_error_template pydantic-field

blocklist_error_template: str = "Operation '{{action}}' is not supported by this environment."

The error template to use when a command is blocked.

blocklist pydantic-field

blocklist: list[str] = ['vim', 'vi', 'emacs', 'nano', 'nohup', 'gdb', 'less', 'tail -f', 'python -m venv', 'make']

Block any command that starts with one of these

blocklist_standalone pydantic-field

blocklist_standalone: list[str] = ['python', 'python3', 'ipython', 'bash', 'sh', '/bin/bash', '/bin/sh', 'nohup', 'vi', 'vim', 'emacs', 'nano', 'su']

Block any command that matches one of these exactly

block_unless_regex pydantic-field

block_unless_regex: dict[str, str] = {'radare2': '\\b(?:radare2)\\b.*\\s+-c\\s+.*', 'r2': '\\b(?:radare2)\\b.*\\s+-c\\s+.*'}

Block any command that matches one of these names unless it also matches the regex

sweagent.tools.bundle.Bundle pydantic-model

Bases: BaseModel

Fields:

Validators:

path pydantic-field

path: Path

hidden_tools pydantic-field

hidden_tools: list[str]

state_command property

state_command: str | None

config property

config: BundleConfig

commands property

commands: list[Command]

validate_tools pydantic-validator

validate_tools()
Source code in sweagent/tools/bundle.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
@model_validator(mode="after")
def validate_tools(self):
    self.path = _convert_path_to_abspath(self.path)
    if not self.path.exists():
        msg = f"Bundle path '{self.path}' does not exist."
        raise ValueError(msg)

    config_path = self.path / "config.yaml"
    if not config_path.exists():
        msg = f"Bundle config file '{config_path}' does not exist."
        raise ValueError(msg)

    config_data = yaml.safe_load(config_path.read_text())
    self._config = BundleConfig(**config_data)

    invalid_hidden_tools = set(self.hidden_tools) - set(self._config.tools.keys())
    if invalid_hidden_tools:
        msg = f"Hidden tools {invalid_hidden_tools} do not exist in available tools"
        raise ValueError(msg)
    return self