Deep Agents: LangChain/LangGraph Backend

The Deep Agents backend uses LangChain’s Deep Agents SDK (deepagents package) with the LangGraph runtime. It provides built-in planning, subagent delegation, filesystem tools, and access to any LLM provider supported by LangChain.

Overview

  • Status: Beta
  • Provider support: Anthropic, OpenAI, Google, Ollama, OpenRouter, OpenAI-compatible, LiteLLM
  • Built-in tools: write_todos, read_todos, task (subagents), ls, read_file, write_file
  • MCP support: Yes (via .mcp.json file discovery, supports stdio/SSE/HTTP transports)
  • ACP support: Yes (Agent Communication Protocol for IDE integration via deepagents-acp)
  • Session persistence: History injection (LangGraph checkpointing planned)

Configuration

Terminal window
export POCKETPAW_AGENT_BACKEND="deep_agents"
export POCKETPAW_DEEP_AGENTS_MODEL="anthropic:claude-sonnet-4-6"

Backend-Specific Settings

SettingEnv VariableDefaultDescription
deep_agents_modelPOCKETPAW_DEEP_AGENTS_MODELanthropic:claude-sonnet-4-6Model in provider:model format
deep_agents_max_turnsPOCKETPAW_DEEP_AGENTS_MAX_TURNS100Max tool-use turns per query (maps to LangGraph recursion limit)

Model Format

Deep Agents uses LangChain’s init_chat_model() which accepts a provider:model string. Set the model in the dashboard or via environment variable:

Terminal window
# Anthropic
export POCKETPAW_DEEP_AGENTS_MODEL="anthropic:claude-sonnet-4-6"
# OpenAI
export POCKETPAW_DEEP_AGENTS_MODEL="openai:gpt-4o"
# Google Gemini
export POCKETPAW_DEEP_AGENTS_MODEL="google_genai:gemini-2.0-flash"
# Ollama (local)
export POCKETPAW_DEEP_AGENTS_MODEL="ollama:llama3.2"

Using with Ollama

For free local inference, point to your Ollama instance:

Terminal window
export POCKETPAW_AGENT_BACKEND="deep_agents"
export POCKETPAW_DEEP_AGENTS_MODEL="ollama:llama3.2"
export POCKETPAW_OLLAMA_HOST="http://localhost:11434" # default

The backend passes the Ollama host as base_url to the LangChain model. Any model available in your Ollama instance can be used.

Using with OpenRouter

Access 100+ models through OpenRouter’s API:

Terminal window
export POCKETPAW_AGENT_BACKEND="deep_agents"
export POCKETPAW_DEEP_AGENTS_MODEL="openrouter:anthropic/claude-sonnet-4-6"
export POCKETPAW_OPENROUTER_API_KEY="sk-or-v1-..."

The backend routes OpenRouter through the OpenAI-compatible API with https://openrouter.ai/api/v1 as the base URL.

Using with LiteLLM

Route through a LiteLLM proxy for access to 100+ providers:

Terminal window
export POCKETPAW_AGENT_BACKEND="deep_agents"
export POCKETPAW_DEEP_AGENTS_MODEL="litellm:anthropic/claude-sonnet-4-6"
export POCKETPAW_LITELLM_API_BASE="http://localhost:4000"
export POCKETPAW_LITELLM_API_KEY="your-proxy-key" # optional

The backend routes LiteLLM through the OpenAI-compatible API pointed at your proxy URL. Use the provider/model format after litellm: (e.g., litellm:openai/gpt-4o, litellm:huggingface/meta-llama/Llama-3-70b).

Info

In the dashboard, when you type litellm:, ollama:, or openrouter: in the Model field, the relevant config fields (proxy URL, API key, host) appear inline automatically.

Using with OpenAI-Compatible Endpoints

Point to any OpenAI-compatible API:

Terminal window
export POCKETPAW_AGENT_BACKEND="deep_agents"
export POCKETPAW_DEEP_AGENTS_MODEL="openai_compatible:your-model-name"
export POCKETPAW_OPENAI_COMPATIBLE_BASE_URL="https://your-endpoint.com/v1"
export POCKETPAW_OPENAI_COMPATIBLE_API_KEY="your-key"

Built-in Tools

Deep Agents includes its own planning and filesystem tools alongside PocketPaw’s 50+ custom tools:

Deep Agents ToolDescriptionPolicy Mapping
write_todosTask planning and decomposition
read_todosRead current task list
taskSpawn subagents for isolated workshell
lsList directory contentsread_file
read_fileRead file contentsread_file
write_fileWrite/create fileswrite_file

PocketPaw’s custom tools (web_search, image_gen, memory, etc.) are registered as LangChain StructuredTool wrappers via the tool bridge.

MCP Tools

Deep Agents supports MCP (Model Context Protocol) servers via .mcp.json configuration files. This lets the agent access external tools like file systems, APIs, and databases.

Configuration Files

The SDK discovers .mcp.json files at three locations (highest precedence last):

  1. ~/.deepagents/.mcp.json — user-level (global defaults)
  2. <project>/.deepagents/.mcp.json — project subdirectory
  3. <project>/.mcp.json — project root (Claude Code compatible)

Supported Transports

stdio (spawns server as child process):

{
"servers": {
"my-server": {
"command": "/path/to/server",
"args": ["--arg1", "value"],
"env": { "API_KEY": "..." }
}
}
}

SSE (remote server):

{
"servers": {
"remote-sse": {
"type": "sse",
"url": "https://example.com/sse",
"headers": { "Authorization": "Bearer token" }
}
}
}

HTTP (remote server):

{
"servers": {
"remote-http": {
"type": "http",
"url": "https://example.com/api",
"headers": { "Authorization": "Bearer token" }
}
}
}
Info

The .mcp.json format at the project root is compatible with Claude Code’s MCP config, so existing MCP server configs carry over automatically.

Trust and Security

  • Project-level stdio servers: default-deny policy. The CLI prompts for approval using SHA-256 fingerprinting. In non-interactive mode, use --trust-project-mcp.
  • Remote servers (SSE/HTTP): always allowed since they don’t execute local code.
Warning

MCP support in Deep Agents currently works via file-based discovery (.mcp.json), not as a programmatic parameter to create_deep_agent(). PocketPaw’s MCP servers configured in the dashboard are not automatically passed to the Deep Agents backend. To use MCP with Deep Agents, configure servers in a .mcp.json file in your project root.

ACP (Agent Communication Protocol)

Deep Agents supports ACP for IDE integration (Zed, JetBrains, VS Code). ACP standardizes communication between coding agents and editors, allowing editors to provide project context while receiving rich updates.

Terminal window
pip install deepagents-acp

This is separate from PocketPaw’s integration and is primarily useful when running Deep Agents directly from an IDE.

How It Works

  1. PocketPaw calls create_deep_agent() with the LLM model, system prompt, and tools
  2. Messages stream via LangGraph’s astream() with stream_mode=["updates", "messages"]
  3. messages chunks yield token-by-token text to the chat
  4. updates chunks surface tool calls and results to the Activity panel
  5. The compiled LangGraph agent is cached across calls for performance
  6. Conversation history is injected as message context for multi-turn support

Installation

Terminal window
pip install pocketpaw[deep-agents]

This installs the deepagents package and its LangChain/LangGraph dependencies.