> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Shell Tools

> Let an agent run shell commands to list directory contents with ShellTools.

`run_shell_command` executes an arbitrary command on the host OS. Under prompt injection that makes the agent an RCE sink, so this example gates the tool behind human-in-the-loop confirmation using the toolkit's `requires_confirmation_tools`.

```python shell_tools.py theme={null}
"""
Shell Tools
=============================

Demonstrates shell tools.

``run_shell_command`` executes an arbitrary command on the host OS. Under prompt
injection that makes the agent an RCE sink, so this example gates the tool behind
human-in-the-loop confirmation using the toolkit's ``requires_confirmation_tools``.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.shell import ShellTools

# ---------------------------------------------------------------------------
# Create Agent
#
# requires_confirmation_tools marks run_shell_command as needing human approval,
# so the run pauses before any command reaches the host.
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIResponses(id="gpt-5.5"),
    tools=[ShellTools(requires_confirmation_tools=["run_shell_command"])],
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    run_response = agent.run("List the files in the current directory")

    # run_shell_command is gated, so the run pauses for confirmation.
    if run_response.active_requirements:
        for requirement in run_response.active_requirements:
            if requirement.needs_confirmation:
                tool = requirement.tool_execution
                print(
                    f"Confirmation required for '{tool.tool_name}' with args: {tool.tool_args}"
                )
                answer = input("Approve? [y/N]: ").strip().lower()
                if answer == "y":
                    requirement.confirm()
                else:
                    requirement.reject()

        run_response = agent.continue_run(
            run_response, requirements=run_response.requirements
        )

    print(run_response.content)
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `shell_tools.py`, then run:

    ```bash theme={null}
    python shell_tools.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/shell\_tools.py](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/91_tools/shell_tools.py)
