Skip to content

ShellTool

autogen.beta.tools.builtin.shell.ShellTool #

ShellTool(*, environment=None)

Bases: Tool

Shell/bash execution tool.

Provider-specific mapping:

  • Anthropic — maps to bash_20250124. Claude calls the tool with a command or restart input; the application must execute it and return the result (client-side tool). environment is ignored for Anthropic.

  • OpenAI Responses API — maps to shell (gpt-5.4). Use environment to control where commands execute: ContainerAutoEnvironment, ContainerReferenceEnvironment, or LocalEnvironment. Omit environment for OpenAI's default behaviour.

See: - https://platform.claude.com/docs/en/agents-and-tools/tool-use/bash-tool - https://developers.openai.com/api/docs/guides/tools-shell

Source code in autogen/beta/tools/builtin/shell.py
def __init__(
    self,
    *,
    environment: ShellEnvironment | Variable | None = None,
) -> None:
    self._params: dict[str, object] = {}
    if environment is not None:
        self._params["environment"] = environment

schemas async #

schemas(context)
Source code in autogen/beta/tools/builtin/shell.py
async def schemas(self, context: "Context") -> list[ShellToolSchema]:
    resolved = {k: resolve_variable(v, context, param_name=k) for k, v in self._params.items()}
    return [ShellToolSchema(**resolved)]

register #

register(stack, context, *, middleware=())
Source code in autogen/beta/tools/builtin/shell.py
def register(
    self,
    stack: "ExitStack",
    context: "Context",
    *,
    middleware: Iterable["BaseMiddleware"] = (),
) -> None:
    pass