Technical Guide

LangChain Deep Agents Guardrails: Built In vs Missing

Map each LangChain Deep Agents control to the surface it covers, find the gaps around subagents and shell commands, and avoid double approvals.

Published on

Subscribe to our newsletter

By submitting your email, you agree to our Privacy Policy and consent to receiving updates from us

LangChain Deep Agents Guardrails: What's Built In and What Production Still Needs

By Tahir Mahmood, Co-founder & CTO, OpenBox ยท Last updated 27 November 2026

In brief: LangChain Deep Agents is an agent harness for complex, multi-step work that adds planning, a virtual filesystem, subagent spawning and long-term memory on top of LangChain and LangGraph. LangChain Deep Agents guardrails cover filesystem permissions, interrupt_on human approval, PII middleware and sandboxes, and each control covers a specific surface.

Each control stops at a documented boundary: custom tools, shell commands run through a sandbox, and isolated subagents, which do not inherit custom middleware. OpenBox, an AI agent security and governance platform, adds middleware-level policy on model calls, tool calls and subagent task dispatch, and it sits alongside those controls rather than replacing them.

What guardrails do LangChain Deep Agents give you out of the box?

LangChain documents filesystem permissions, human approval through interrupt_on, PII middleware, sandboxes and fault-tolerance controls for Deep Agents. Its going-to-production page lists Permissions, Fault tolerance and Data privacy under Guardrails. Each control covers a specific surface: files, listed tool calls, text, or code execution.

One status note. The page names Managed Deep Agents as the recommended production path and describes it as in public beta. This article covers the SDK route, where you pass middleware to create_deep_agent yourself. We have not checked whether the OpenBox middleware runs on Managed Deep Agents.

How do Deep Agents permissions work?

Permissions are declarative allow and deny rules for files and directories. Rules are evaluated in declaration order, and the first matching rule wins. If no rule matches, the operation is allowed. Setting mode="interrupt" pauses for human approval instead, and needs deepagents 0.6.8 or later, per the permissions page read on 27 November 2026.

How does Deep Agents human approval work?

Setting interrupt_on adds HumanInTheLoopMiddleware, and tools you list pause for review by default, as the human-in-the-loop page describes. A checkpointer is required, and reviewers can approve, edit, reject or respond. LangChain's guardrails page describes human approval middleware as an effective guardrail for high-stakes decisions.

What PII controls do Deep Agents have?

PIIMiddleware supports four strategies: redact, mask, hash and block. Block raises an exception when PII is detected. The going-to-production page also says you can write custom detectors for domain-specific patterns.

How do Deep Agents handle code execution?

Sandboxes provide a filesystem and an execute tool for running shell commands inside an isolated container. The same page says FilesystemBackend and LocalShellBackend access the host directly, and tells you not to use them in deployed agents.

What is missing from LangChain Deep Agents guardrails for production?

Each built-in control stops at a documented boundary. Permissions skip custom tools, MCP tools and sandbox execute. interrupt_on gates the tools you list. Isolated subagents do not inherit custom middleware. Those boundaries are where you need your own checks or a runtime layer. That is our reading of LangChain's docs, not a list LangChain publishes.

LangChain does have guardrails, and the boundaries come from its own pages. On permissions, the docs say: "Custom tools and MCP tools that access the filesystem are not covered." On subagents, the subagents page says isolated subagents do not inherit the main agent's custom middleware, while forks inherit the custom middleware passed to the parent's create_deep_agent.

The table maps what LangChain documents, where each control stops, and what OpenBox's documentation says a runtime layer adds.

Surface

LangChain documents

You still have to cover (our reading)

What OpenBox's docs describe adding

Files

Permissions: allow, deny or interrupt rules on the built-in filesystem tools.

Custom tools and MCP tools that access the filesystem are not covered by permissions.

A policy or guardrail that matches tool_input.path on governed tools.

Human approval

interrupt_on for the tools you list. A checkpointer is required.

Choosing which tools to list, and running the pause and resume flow.

Policy-driven require_approval. The SDK polls OpenBox for the human decision.

PII and content

PIIMiddleware with redact, mask, hash and block strategies, plus custom detectors.

Selecting and configuring the detectors for your data.

Guardrails: PII Detection, Content Filtering, Toxicity and Ban Words, on input, output or both.

Shell commands

Sandboxes isolate execution. Permissions do not apply to sandbox backends.

Choosing and operating the sandbox. Command-level checks need another layer.

A policy that matches tool_input.command before a governed tool runs.

Subagents

Subagents inherit interrupt_on and permissions by default. Isolated subagents do not inherit custom middleware.

Per-subagent settings, and where your custom middleware sits.

The task dispatch is evaluated as a tool call, labelled a2a, and can be matched by subagent_name.

 

The right-hand column describes what OpenBox's documentation says it adds. It is not a measured comparison. OpenBox does not replace sandboxing or file permissions. For the case for enforcing policy at the action boundary, see Model Guardrails Aren't Enough to Govern AI Agents, and for the guardrail types, see the OpenBox guardrails docs.

How do approvals work with subagents in Deep Agents?

In LangChain, a subagent inherits the main agent's interrupt_on settings by default and can override them with its own. In the OpenBox SDK, a subagent is a task tool call: the SDK records subagent_type as subagent_name, labels it a2a, and the docs list matching on subagent_name or on all a2a dispatches for approval.

The event model describes the mechanics. The SDK reads tool_args["subagent_type"], falls back to "general-purpose" when it is missing, and adds __openbox metadata to activity_input. Set known_subagents to the names you pass to create_deep_agent, and include "general-purpose" while the default subagent is active, as the configuration docs explain.

Know the boundary. The SDK README says subagents run inside the task tool body, so governance sees the whole call as one unit and internal tool and LLM calls are not surfaced. LangChain separately says isolated subagents do not inherit custom middleware. We read the two together as one practical rule: treat the task dispatch as the governed boundary, and test what reaches OpenBox with OPENBOX_DEBUG=1. That is our recommendation, not a documented guarantee.

For the identity side of delegation, see Sub-Agent Authorisation. For handoffs between agents, see Govern the Handoffs Between Your AI Agents.

How do you avoid double approvals?

Pick one approval mechanism per tool. The OpenBox docs say to avoid enabling both DeepAgents interrupt_on and OpenBox approval for the same tool, because users can see confusing double pauses. Either remove the tool from interrupt_on and let OpenBox approve it, or remove the REQUIRE_APPROVAL policy for that tool in OpenBox.

The approvals and guardrails page recommends OpenBox approval policies for OpenBox-governed deployments, with matching tools removed from interrupt_on. The troubleshooting page lists both fixes. The snippet below is illustrative: the same tool is gated by one mechanism only.

agent = create_deep_agent(

    model=init_chat_model("openai:gpt-4o-mini"),

    tools=[search_web, write_report, export_data],

    middleware=[middleware],  # OpenBox policy approves export_data

    # interrupt_on={"export_data": True},  # leave out: OpenBox owns this approval

)

 

Tools that no OpenBox policy covers can keep their interrupt_on entries. Approval is not limited to the request: ToolCompleted and LLMCompleted can also return require_approval, so a policy can review output. At approval-capable boundaries, rejection or expiry halts the run, per the docs. For design patterns, see Human-in-the-Loop AI: 5 Approval Examples for AI Agents.

How do you block shell commands in a Deep Agent?

Treat it as two layers. LangChain's permissions do not apply to sandbox backends that run commands through the execute tool, and sandboxes isolate execution in a container. A policy that matches tool_input.command, which OpenBox docs list for banned shell commands, adds a check before a governed tool runs. It does not replace the sandbox.

OpenBox policies are stateless permission checks written in OPA Rego. Each evaluates a single input and does not track prior actions or session history, so a rule on one command is a per-call check, not a sequence check. The same docs page also lists tool_input.path, tool_input.query and tool_name as tool fields to match. For worked Rego examples, see OPA Rego for AI Agent Tool Calls.

We position this as an additional check alongside a sandbox, not as a substitute for one.

How do you log Deep Agent tool calls for audit?

LangChain and OpenBox keep different records. LangChain's page says checkpoints provide an audit trail for workflows involving payments or other irreversible actions, and points to LangSmith for debugging runs. The OpenBox SDK records tool name, input arguments, output, duration and governance decision for tool calls, shown in the dashboard's Event Log Timeline.

The Deep Agents SDK docs also list prompts, completions, model name, token counts and latency for model calls. These are records produced by different systems. We make no claim that either one satisfies an audit or compliance requirement. For how the two tools sit in a stack, see LangSmith vs OpenBox. For a long-running Deep Agents example, see Your agent ran two hours. Who was watching?

How do you add OpenBox middleware to a Deep Agent?

Create middleware with create_openbox_middleware() and pass it in the middleware list of create_deep_agent. Set known_subagents to match your subagents and choose on_api_error, which defaults to fail_open. Policies and guardrails are managed on the OpenBox platform, not in your code.

The example from the OpenBox getting started guide:

import os

from deepagents import create_deep_agent

from langchain.chat_models import init_chat_model

from openbox_deepagent import create_openbox_middleware

 

middleware = create_openbox_middleware(

    api_url=os.getenv("OPENBOX_URL"),

    api_key=os.getenv("OPENBOX_API_KEY"),

    agent_did=os.getenv("OPENBOX_AGENT_DID"),

    agent_private_key=os.getenv("OPENBOX_AGENT_PRIVATE_KEY"),

    agent_name="ResearchBot",

    known_subagents=["researcher", "writer", "general-purpose"],

)

 

agent = create_deep_agent(

    model=init_chat_model("openai:gpt-4o-mini"),

    tools=[search_web, write_report, export_data],

    subagents=[

        {"name": "researcher", "tools": [search_web]},

        {"name": "writer", "tools": [write_report]},

    ],

    middleware=[middleware],

)

 

Install openbox-deepagent-sdk-python, which requires Python 3.11 or later. api_url and api_key are required. Newly created OpenBox agents require DID signing by default, so also set agent_did and agent_private_key, or omit them if Require signing is disabled for the agent. agent_name should match the registered agent so policies resolve against the intended agent. The configuration docs list the middleware parameters.

Per the docs, the middleware's wrap_model_call hook runs prompt-side governance before an LLM call, and wrap_tool_call evaluates governance policy before a tool executes. Before the agent graph runs, the SDK also evaluates the last human message. Policy evaluation happens on the OpenBox platform, not in the SDK.

OpenBox returns one of five governance decisions (Governance Decisions): ALLOW, CONSTRAIN, REQUIRE_APPROVAL, BLOCK or HALT. The Deep Agents SDK pages document how the SDK enforces require_approval, block and halt, and those are the paths this article covers. The SDK raises GovernanceBlockedError when OpenBox returns block. It raises GovernanceHaltError on halt, and also when an approval is rejected or expires. The troubleshooting page treats a block as recoverable for the agent and a halt as terminal.

What we have not verified

The package is MIT-licensed according to its LICENSE file, and PyPI lists version 0.2.0, released 28 May 2026. Because that is a pre-1.0 version number, our suggestion is to pin the version. We have not checked whether the middleware runs on Managed Deep Agents, or what reaches OpenBox from forked subagents, which LangChain says inherit custom middleware.

Where to start with LangChain Deep Agents guardrails

List every tool your Deep Agent can call, then mark which LangChain control reaches it. Where none does, decide whether to write your own middleware or add a runtime layer. If you choose OpenBox, begin with the Deep Agents getting started guide. The same pattern is covered for LangGraph and for CrewAI.

Frequently asked questions

Does LangChain Deep Agents have built-in human-in-the-loop?

Yes. Setting interrupt_on adds HumanInTheLoopMiddleware, and tools you list pause for review by default. A checkpointer is required, and reviewers can approve, edit, reject or respond. Permissions can also pause for approval with mode="interrupt", which needs deepagents 0.6.8 or later.

Does OpenBox see what a subagent does internally?

The SDK README says subagents run inside the task tool body, so governance sees the whole task call as one unit, and internal tool and LLM calls are not surfaced. Only the task dispatch is governed. Set OPENBOX_DEBUG=1 to check what reaches OpenBox in your own setup.

What happens if the OpenBox API is unreachable?

It depends on on_api_error. The default, fail_open, lets the operation proceed and logs a warning. fail_closed blocks the operation, and the docs show it for high-security environments. Choose the value that matches how you weigh availability against control for each agent.

  

Sources (accessed 27 November 2026)

LangChain: Deep Agents overview (Python). https://docs.langchain.com/oss/python/deepagents/overview

LangChain: Going to production (Deep Agents, Python). https://docs.langchain.com/oss/python/deepagents/going-to-production

LangChain: Permissions (Deep Agents). https://docs.langchain.com/oss/python/deepagents/permissions

LangChain: Human-in-the-loop (Deep Agents). https://docs.langchain.com/oss/python/deepagents/human-in-the-loop

LangChain: Subagents (Deep Agents). https://docs.langchain.com/oss/python/deepagents/subagents

LangChain: Customization (Deep Agents). https://docs.langchain.com/oss/python/deepagents/customization

LangChain: Guardrails (LangChain, Python). https://docs.langchain.com/oss/python/langchain/guardrails

OpenBox (docs.openbox.ai): Getting Started with Deep Agents. https://docs.openbox.ai/getting-started/deep-agents

OpenBox (docs.openbox.ai): Deep Agents SDK (Python). https://docs.openbox.ai/developer-guide/deep-agents

OpenBox (docs.openbox.ai): Deep Agents Configuration. https://docs.openbox.ai/developer-guide/deep-agents/configuration

OpenBox (docs.openbox.ai): Deep Agents Event Model. https://docs.openbox.ai/developer-guide/deep-agents/event-model

OpenBox (docs.openbox.ai): Deep Agents Approvals and Guardrails. https://docs.openbox.ai/developer-guide/deep-agents/approvals-and-guardrails

OpenBox (docs.openbox.ai): Deep Agents Troubleshooting. https://docs.openbox.ai/developer-guide/deep-agents/troubleshooting

OpenBox (docs.openbox.ai): Policies. https://docs.openbox.ai/trust-lifecycle/authorize/policies

OpenBox (docs.openbox.ai): Guardrails. https://docs.openbox.ai/trust-lifecycle/authorize/guardrails

OpenBox (docs.openbox.ai): Governance Decisions. https://docs.openbox.ai/core-concepts/governance-decisions

PyPI: openbox-deepagent-sdk-python. https://pypi.org/project/openbox-deepagent-sdk-python/

GitHub: OpenBox-AI/openbox-deepagent-sdk-python (README). https://github.com/OpenBox-AI/openbox-deepagent-sdk-python

GitHub: openbox-deepagent-sdk-python LICENSE. https://github.com/OpenBox-AI/openbox-deepagent-sdk-python/blob/main/LICENSE

Trustworthy AI
Starts Here

By submitting your email, you agree to our Privacy Policy and consent to receiving updates from us

Trustworthy AI
Starts Here

By submitting your email, you agree to our Privacy Policy and consent to receiving updates from us

Trustworthy AI
Starts Here

By submitting your email, you agree to our Privacy Policy and consent to receiving updates from us

Trustworthy AI
Starts Here

By submitting your email, you agree to our Privacy Policy and consent to receiving updates from us