# AutoModeHITLMiddleware

> **Class** in `deepagents_code`

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

Apply deterministic policy, classifier review, and HITL fallback.

## Signature

```python
AutoModeHITLMiddleware(
    self,
    interrupt_on: Mapping[str, bool | InterruptOnConfig],
    *,
    worktree_root: str | Path,
    shell_allow_list: Sequence[str] = (),
    classifier_timeout_seconds: float = _CLASSIFIER_TIMEOUT_SECONDS,
    classifier_construction_timeout_seconds: float = _CLASSIFIER_CONSTRUCTION_TIMEOUT_SECONDS,
    classifier_model: str | BaseChatModel | None = None,
    cli_max_retries: int | None = None,
    environ: Mapping[str, str] | None = None,
    trusted_ask_user_tool: BaseTool | None = None,
    trusted_compaction_tool: BaseTool | None = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `interrupt_on` | `Mapping[str, bool \| InterruptOnConfig]` | Yes | Shared Manual interrupt map. |
| `worktree_root` | `str \| Path` | Yes | Trusted repository boundary for deterministic writes. |
| `shell_allow_list` | `Sequence[str]` | No | Restrictive configured shell entries. (default: `()`) |
| `classifier_timeout_seconds` | `float` | No | Timeout for one structured decision batch. (default: `_CLASSIFIER_TIMEOUT_SECONDS`) |
| `classifier_construction_timeout_seconds` | `float` | No | Separate timeout for lazily building a configured classifier model, so a cold provider import does not consume the inference budget. (default: `_CLASSIFIER_CONSTRUCTION_TIMEOUT_SECONDS`) |
| `classifier_model` | `str \| BaseChatModel \| None` | No | Model the authorization classifier reviews with.  A `provider:model` spec is resolved lazily (and cached) on the first review; a chat model instance is used as-is. `None` inherits the main agent model, which is the default. A per-run `classifier_model` on the runtime context wins over this value. (default: `None`) |
| `cli_max_retries` | `int \| None` | No | Explicit `--max-retries` value to retain when a distinct classifier model is constructed. (default: `None`) |
| `environ` | `Mapping[str, str] \| None` | No | Workspace environment retained for lazy model construction. (default: `None`) |
| `trusted_ask_user_tool` | `BaseTool \| None` | No | Built-in tool allowed to create consent receipts. (default: `None`) |
| `trusted_compaction_tool` | `BaseTool \| None` | No | Built-in tool that performs conversation compaction. (default: `None`) |

## Extends

- `HumanInTheLoopMiddleware[AutoModeState, Any, Any]`

## Constructors

```python
__init__(
    self,
    interrupt_on: Mapping[str, bool | InterruptOnConfig],
    *,
    worktree_root: str | Path,
    shell_allow_list: Sequence[str] = (),
    classifier_timeout_seconds: float = _CLASSIFIER_TIMEOUT_SECONDS,
    classifier_construction_timeout_seconds: float = _CLASSIFIER_CONSTRUCTION_TIMEOUT_SECONDS,
    classifier_model: str | BaseChatModel | None = None,
    cli_max_retries: int | None = None,
    environ: Mapping[str, str] | None = None,
    trusted_ask_user_tool: BaseTool | None = None,
    trusted_compaction_tool: BaseTool | None = None,
) -> None
```

| Name | Type |
|------|------|
| `interrupt_on` | `Mapping[str, bool \| InterruptOnConfig]` |
| `worktree_root` | `str \| Path` |
| `shell_allow_list` | `Sequence[str]` |
| `classifier_timeout_seconds` | `float` |
| `classifier_construction_timeout_seconds` | `float` |
| `classifier_model` | `str \| BaseChatModel \| None` |
| `cli_max_retries` | `int \| None` |
| `environ` | `Mapping[str, str] \| None` |
| `trusted_ask_user_tool` | `BaseTool \| None` |
| `trusted_compaction_tool` | `BaseTool \| None` |


## Properties

- `trace_policy`
- `state_schema`
- `name`
- `tools`

## Methods

- [`wrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/auto_mode/AutoModeHITLMiddleware/wrap_tool_call)
- [`awrap_tool_call()`](https://reference.langchain.com/python/deepagents-code/auto_mode/AutoModeHITLMiddleware/awrap_tool_call)
- [`awrap_model_call()`](https://reference.langchain.com/python/deepagents-code/auto_mode/AutoModeHITLMiddleware/awrap_model_call)
- [`aafter_model()`](https://reference.langchain.com/python/deepagents-code/auto_mode/AutoModeHITLMiddleware/aafter_model)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e4c1ffe9ee63d7854147de490ca27495ef157a7b/libs/code/deepagents_code/auto_mode.py#L2370)