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
(ToolFilterConfig
) -
bundles
(list[Bundle]
) -
propagate_env_variables
(list[str]
) -
env_variables
(dict[str, Any]
) -
registry_variables
(dict[str, Any]
) -
submit_command
(str
) -
parse_function
(ParseFunction
) -
enable_bash_tool
(bool
) -
format_error_template
(str
) -
command_docs
(str
) -
multi_line_command_endings
(dict[str, str]
) -
submit_command_end_name
(str | None
) -
reset_commands
(list[str | list[str]]
) -
execution_timeout
(int
) -
install_timeout
(int
) -
total_execution_timeout
(int
) -
max_consecutive_execution_timeouts
(int
)
filter
pydantic-field
filter: ToolFilterConfig
Filter out commands that are blocked by the environment
(for example interactive commands like vim
).
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
(str
) -
blocklist
(list[str]
) -
blocklist_standalone
(list[str]
) -
block_unless_regex
(dict[str, str]
)
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:
-
path
(Path
) -
hidden_tools
(list[str]
) -
_config
(BundleConfig
)
Validators:
path
pydantic-field
path: Path
hidden_tools
pydantic-field
hidden_tools: list[str]
state_command
property
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 |
|