# Deep Agents

Return a compiled Deep Agents graph from the entrypoint while Tanomis owns the model route, checkpoints, and the workspace.

With the Deep Agents harness your entrypoint returns a compiled LangGraph graph built by
`create_deep_agent`. Tanomis resolves the tenant-approved model before the graph is created,
roots the checkpointer and filesystem backend in the session workspace, and turns the manifest's
approval list into tool interrupts.

- Scaffold with `tanomis agent new NAME --harness deepagents`.
- Pass `context.runtime_context.model` to `create_deep_agent` unchanged; it is already the
  resolved, provider-routed model.
- Keep the generated dependencies: Deep Agents, the workspace SQLite checkpointer, and the
  provider adapters the managed route needs.
- Tools named in `policy.approval_required_tools` become interrupts; approve, reject, and
  answers are supported, edited arguments are not.

## Scaffold

```bash title="Terminal"
tanomis agent new research-assistant --harness deepagents --agents-root ./agents
```

## The entrypoint

```python title="agents/research-assistant/agent.py"
from __future__ import annotations

def create_agent(input_payload, context):
    from deepagents import create_deep_agent

    def classify_request(text: str) -> str:
        """Classify a request as question, incident, or feedback."""
        normalized = text.lower()
        if "error" in normalized or "failed" in normalized:
            return "incident"
        if "?" in text:
            return "question"
        return "feedback"

    return create_deep_agent(
        model=context.runtime_context.model,
        tools=[classify_request],
        system_prompt=(
            "Classify the request, explain the evidence, and recommend one next action."
        ),
    )
```

Import `deepagents` inside the callable so the module imports without the SDK, which is what the
generated contract test relies on. Pass `context.runtime_context.model` through unchanged.

## Keep the generated dependencies

The scaffold pins Deep Agents, the workspace SQLite checkpointer, and the provider adapters the
managed model route requires. Do not remove an adapter because the manifest's model name looks like
a different provider; the gateway may route it there. Lock before you deploy:

```bash title="Terminal"
cd agents/research-assistant
uv sync --frozen
uv lock --locked
```

## Who owns what

| Concern | Owner |
|---|---|
| Tools, system prompt, middleware, structured output, subagents | You |
| Workspace root and the runtime session or thread ID | Runtime |
| Default checkpointer and persistent store | Runtime |
| Resolved model and provider credentials | Runtime |
| Filesystem backend root and platform deny rules | Runtime |
| Additional in-workspace backend routes | You, within manifest policy |
| Tool interrupts | Composed from the manifest's approvals and your configuration |

The generated manifest uses `workspace-sqlite` checkpointing and the workspace-composite backend.
Keep those defaults for the first deployment.

## Approval-aware tools

```yaml title="agent.yaml"
policy:
  approval_required_tools:
    - execute
  enable_ask_user: true
```

The runtime combines that list with your own `interrupt_on` configuration. The approval surface
supports approve, reject, and user answers; do not design a tool that needs edited arguments as an
approval outcome.

## Where to go next

- [Write your agent](/guides/build/write-your-agent): the contract every harness shares.
- [Manifest essentials](/guides/build/manifest-essentials): models, tools, hosts, limits.
- [Approval-required actions](/guides/run/approval-required-actions): what a paused run looks
  like from your application.
