Skip to content

Tool configuration

This shows how to configure tools for SWE-agent.

sweagent.tools.tools.ToolConfig pydantic-model

Bases: BaseModel

Fields:

bundles pydantic-field

bundles: list[Bundle]

command_docs pydantic-field

command_docs: str = None

commands pydantic-field

commands: list[Command]

Read command files and return parsed command objects

enable_bash_tool pydantic-field

enable_bash_tool: bool = True

env_variables pydantic-field

env_variables: dict[str, Any] = {}

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

execution_timeout pydantic-field

execution_timeout: int = 30

Timeout for executing commands in the environment

filter pydantic-field

format_error_template pydantic-field

format_error_template: str = None

Defaults to format_error_template in ParseFunction

install_timeout pydantic-field

install_timeout: int = 300

Timeout used for each of the installation commands

multi_line_command_endings pydantic-field

multi_line_command_endings: dict[str, str] = {}

parse_function pydantic-field

parse_function: ParseFunction

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.

state_commands pydantic-field

state_commands: list[str]

submit_command pydantic-field

submit_command: str = 'submit'

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.

tools pydantic-field

tools: list[dict]

use_function_calling pydantic-field

use_function_calling: bool

sweagent.tools.tools.ToolFilterConfig pydantic-model

Bases: BaseModel

Fields:

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 regexes unless it also matches the regex

blocklist pydantic-field

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

Block any command that starts with one of these

blocklist_error_template pydantic-field

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

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

sweagent.tools.bundle.Bundle pydantic-model

Bases: BaseModel

Fields:

Validators:

commands pydantic-field

commands: list[Command]

config pydantic-field

config: BundleConfig

hidden_tools pydantic-field

hidden_tools: list[str]

path pydantic-field

path: Path

state_command pydantic-field

state_command: str | None

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