# ShellAllowListMiddleware

> **Class** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/agent/ShellAllowListMiddleware)

Validate shell commands against an allow-list without HITL interrupts.

When the agent invokes the `execute` shell tool, this middleware checks
the command against the configured allow-list **before execution**.
Rejected commands are returned as error `ToolMessage` objects — the
graph never pauses, so LangSmith traces stay as a single continuous
run.

Use this middleware in non-interactive mode to avoid the
interrupt/resume cycle that fragments traces.

## Signature

```python
ShellAllowListMiddleware(
    self,
    allow_list: list[str],
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `allow_list` | `list[str]` | Yes | Allowed command names (e.g. `["ls", "cat", "grep"]`). Must be a non-empty restrictive list — not `SHELL_ALLOW_ALL`. |

## Extends

- `AgentMiddleware`

## Constructors

```python
__init__(
    self,
    allow_list: list[str],
) -> None
```

| Name | Type |
|------|------|
| `allow_list` | `list[str]` |


## Methods

- [`wrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/agent/ShellAllowListMiddleware/wrap_tool_call)
- [`awrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/agent/ShellAllowListMiddleware/awrap_tool_call)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/0412009c5441bef8d75a427e1da8909e33ab5b56/libs/code/deepagents_code/agent.py#L105)