> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-harris-1786029617-6b0a55e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Managed Deep Agents example project

> An annotated Managed Deep Agents project that uses tools, middleware, schedules, skills, and a sandbox.

This page walks through a complete Managed Deep Agents project: a customer-support agent that looks up data with a tool, redacts PII and logs an audit line with middleware, pauses for review before sensitive actions, runs a daily check-in on a schedule, loads a research skill on demand, and works in a managed sandbox. Use it as a reference for how the pieces fit together.

<Note>
  Managed Deep Agents is in **public [beta](/langsmith/release-stages)** and available on [LangSmith Cloud](/langsmith/cloud) in the US region only.
</Note>

## Project structure

Every capability lives in a file whose location determines its role:

```text theme={null}
support-agent/
  agent.py | agent.ts                  # Composes model, tools, middleware, interrupts
  instructions.md                      # Support-agent system prompt
  tools/query_db.py | query-db.ts      # Read-only database lookup tool
  middleware/audit.py | audit.ts       # Logs an audit line before each model call
  schedules/daily_check_in.py | daily-check-in.ts  # Daily 9am cron run
  skills/research/SKILL.md             # On-demand research procedure
  sandbox/index.ts | __init__.py       # Managed LangSmith sandbox
```

For the packaging rules behind this layout, see [Project structure](/langsmith/managed-deep-agents-project-structure).

## Compose the agent

The agent entry is the wiring diagram for the project. It imports the authored tool and middleware, then declares the model, middleware order, and which tools pause for human review. The managed runtime owns the backend, store, checkpointer, skills, and system prompt, so none are set here.

<CodeGroup>
  ```python agent.py theme={null}
  from managed_deepagents import define_deep_agent
  from langchain.agents.middleware import PIIMiddleware

  from middleware.audit import audit_middleware
  from tools.query_db import query_db

  agent = define_deep_agent(
      name="support-agent",
      model="openai:gpt-5.5",
      tools=[query_db],
      middleware=[
          PIIMiddleware("email", strategy="redact"),
          audit_middleware(),
      ],
      interrupt_on={"query_db": True},
  )
  ```

  ```ts agent.ts theme={null}
  import { defineDeepAgent } from "managed-deepagents";
  import { piiMiddleware } from "langchain";

  import { auditMiddleware } from "./middleware/audit";
  import { queryDB } from "./tools/query-db";

  export const agent = defineDeepAgent({
    name: "support-agent",
    model: "openai:gpt-5.5",
    tools: [queryDB],
    middleware: [
      piiMiddleware("email", { strategy: "redact" }),
      auditMiddleware(),
    ],
    interruptOn: {
      query_db: true,
    },
  });
  ```
</CodeGroup>

`interrupt_on` (Python) and `interruptOn` (TypeScript) pause the run before the `query_db` tool executes, so a human can approve the call. For decision types and how to respond to interrupts, see [Human-in-the-loop](/langsmith/managed-deep-agents-middleware#human-in-the-loop). For the core configuration fields, see [Agent definition](/langsmith/managed-deep-agents-agent-definition).

## Write the instructions

`instructions.md` holds the managed system prompt. It sets the agent's role and references its tools and sandbox workspace:

```markdown instructions.md theme={null}
# Support Agent

You are a helpful, careful customer-support Deep Agent.

## Role

- Answer customer questions about their account and orders.
- Use the `query_db` tool to look up data instead of guessing.

## Behavior

- Be concise and friendly.
- Never expose internal database identifiers to the customer.
- When an action would send an email, pause for human review before sending.
```

## Capabilities by file

Each project file maps to a feature guide. Follow the linked page for full examples and configuration options.

| File                                                 | Capability                       | Guide                                                                            |
| ---------------------------------------------------- | -------------------------------- | -------------------------------------------------------------------------------- |
| `tools/query_db.py` or `query-db.ts`                 | Read-only database lookup tool   | [Custom tools](/langsmith/managed-deep-agents-tools)                             |
| `middleware/audit.py` or `audit.ts`                  | Audit logging before model calls | [Custom middleware](/langsmith/managed-deep-agents-middleware)                   |
| `schedules/daily_check_in.py` or `daily-check-in.ts` | Daily 9am Pacific cron run       | [Schedules](/langsmith/managed-deep-agents-schedules)                            |
| `skills/research/SKILL.md`                           | On-demand research procedure     | [Skills](/langsmith/managed-deep-agents-skills)                                  |
| `sandbox/`                                           | Managed LangSmith sandbox        | [Configure a sandbox](/langsmith/managed-deep-agents-deploy#configure-a-sandbox) |

## Run and deploy the project

Test the project locally with [`mda dev`](/langsmith/managed-deep-agents-cli#develop-locally), then deploy it with [`mda deploy`](/langsmith/managed-deep-agents-deploy). Open deployment traces in LangSmith to inspect model calls, tool calls, errors, and latency.

`mda deploy` compiles the project, syncs instructions and skills to Context Hub, uploads the build, and reconciles the daily schedule once the deployment is live.

## See also

* [Quickstart](/langsmith/managed-deep-agents-quickstart): create and deploy a first agent.
* [Tutorial](/langsmith/managed-deep-agents-tutorial): build an agent step by step.

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/managed-deep-agents-examples.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
