Deep
A production terminal AI coding agent built on LangChain's deepagents — adding the TUI, auth, model switching, extensions, background subagents, and everything else you need to actually use it.
What is Deep?
LangChain's deepagents gives you the architectural patterns behind tools like Claude Code and Deep Research — planning, filesystem abstractions, subagent spawning, persistent memory — packaged as a Python library.
What it doesn't give you is a way to actually use it. No terminal UI. No model switching. No way to plug in your Anthropic or Google credentials. No OAuth. No plugin system. No MCP integration.
Deep is everything that's missing. A full terminal interface and operability layer built on top of deepagents, turning it from a framework into a daily-driver coding agent. Inspired by pi-mono's approach to extensible agent tooling.
Clean dependency, not a fork
We don't fork or patch deepagents. We import it as a pip dependency and layer our code on top. When LangChain ships the next version, you bump the version number and our additions carry forward. The coupling is one file: agent.py.
The Two-Layer Architecture
Everything above the deepagents layer is this repo. Everything below is upstream. The coupling is intentionally narrow — one file (agent.py) calls create_deep_agent(), uses CompositeBackend, and wires in middleware. If LangChain changes those interfaces, you update one file.
What We Added (vs Upstream)
| Layer | What it does | Why it's needed |
|---|---|---|
| Terminal UI | Full Textual TUI — chat, streaming, tool approvals, slash commands, autocomplete | deepagents has no interface |
| Multi-provider auth | API keys + OAuth for OpenAI, Anthropic, Google | You wire up auth yourself in base deepagents |
| Model registry | Catalog with live switching, aliases, reasoning effort, service tiers | No built-in model management |
| Provider adapters | OpenAI Responses API, Anthropic Messages, Google Generative AI | deepagents is model-agnostic — you write the glue |
| OAuth support | Use your existing Claude Pro/Max or Google AI Studio subscription | Base library only supports API key env vars |
| Extensions | Plugin system for custom tools, middleware, subagents, hooks | deepagents is extendable but has no plugin architecture |
| MCP integration | Chrome DevTools, external tool servers via Model Context Protocol | Not in base deepagents |
| Background subagents | Non-blocking task execution with check_task/wait_for_task + live activity pill | Base flow blocks on subagent completion |
| Command system | /model, /assemble, /clear, /remember, /tokens | No CLI command framework upstream |
| Linear integration | /assemble pipeline: scout → planner → worker → reviewer | Domain-specific workflow |
| Session management | Thread persistence, checkpoint resumption, conversation history | Checkpointing primitives exist but no session UX |
What we didn't change: the base deepagents package. We call create_deep_agent(), use its CompositeBackend, MemoryMiddleware, SkillsMiddleware, and subagent system exactly as designed. No monkey-patching, no vendored copies.
How It Works
Install and launch
uv pip install -e .
deepagentsOn first launch, the model selector opens. Pick a provider, enter credentials, start working.
Talk to the agent
Type naturally or use slash commands. @ fuzzy-searches project files. / browses commands. The agent plans, executes tools, edits files, and streams results — all in your terminal.
Tools with safety gates
File operations, shell commands, subagent spawning — all visible and controllable. In default mode, destructive operations require approval. In --no-auto-approve mode, everything gets gated. Tool calls render inline with diffs and previews.
Background subagents
Long-running work spawns as non-blocking background tasks. The agent gets an immediate tracking ID and continues working. A live activity pill in the status bar shows running agent count. The agent checks results with check_task or wait_for_task when ready.
Sessions persist
Conversations checkpoint to SQLite. Close the terminal, come back, resume where you left off. Memory and skills accumulate across sessions per agent profile.
The Background Task System
This is one of the more interesting pieces. The base deepagents library blocks when a subagent runs — your main agent sits idle waiting for the result. We solved this without touching upstream:
task tool call
↓
BackgroundTaskMiddleware intercepts via awrap_tool_call
↓
Spawns as asyncio.Task via BackgroundTaskManager
↓
Returns immediate ToolMessage with tracking ID
↓
Agent continues working
↓
check_task(id) / wait_for_task(id) / list_background_tasks
↓
UI shows live agent pill + toast on completionThe middleware registers companion tools automatically — the framework picks them up via getattr(m, "tools", []). Zero changes to deepagents internals. HITL approval still fires before the middleware intercepts, so you still approve the launch.
Middleware as extension point
This pattern — intercepting tool calls via awrap_tool_call, spawning async work, and registering companion tools — is reusable for any non-blocking integration. The deepagents middleware system is more powerful than it looks.
Memory and Skills
Deep uses a layered filesystem approach for context — project-scoped overrides user-scoped:
~/.deepagents/<agent>/
AGENTS.md # Agent-level persistent context
<project>/.deepagents/
AGENTS.md # Project-scoped context (overrides)Memory accumulates across sessions. Use /remember to persist learnings. The MemoryMiddleware from deepagents handles injection into the agent's context window.
~/.deepagents/<agent>/skills/<skill>/
SKILL.md # Reusable skill definition
<project>/.deepagents/skills/<skill>/
SKILL.md # Project-specific skillsSkills are behavioural programs — system prompts that encode how to approach specific types of work. The SkillsMiddleware loads and injects them at agent creation.
~/.deepagents/<agent>/subagents/<n>/
AGENTS.md # Subagent system prompt
<project>/.deepagents/subagents/<n>/
AGENTS.md # Project-scoped overrideSubagent prompts support skill frontmatter:
---
skills:
- web-research
- code-review
---Only listed skills are exposed to that subagent.
Extensions
Extensions are Python modules that plug into the agent lifecycle:
# ~/.deepagents/extensions/my_ext.py
def register(ctx):
ctx.add_tool(my_custom_tool)
ctx.add_middleware(MyMiddleware())
ctx.add_command("/mycommand", handler)
ctx.on("tool_call", my_hook)Extensions can register tools, middleware, commands, subagent specs, and event hooks. They're discovered from ~/.deepagents/extensions/ and <project>/.deepagents/extensions/, or declared explicitly in settings.
Built-in: Linear (deepagents_cli.ext.linear) — powers the /assemble pipeline (scout → planner → worker → reviewer on Linear issues).
Model Configuration
~/.deepagents/models.json
{
"providers": {
"openai": {
"base_url": "https://api.openai.com/v1",
"api": "openai-responses",
"models": [
{ "id": "gpt-5.2", "alias": "primary", "reasoning": "high" }
]
},
"anthropic": {
"api": "anthropic-messages",
"models": [
{ "id": "claude-sonnet-4-5-20250929", "alias": "sonnet" }
]
}
}
}~/.deepagents/auth.json
{
"openai": { "type": "api_key", "key": "sk-..." },
"anthropic": { "type": "oauth", "access_token": "...", "refresh_token": "..." }
}OAuth lets you use your existing Claude Pro/Max or Google AI Studio subscription — no separate API billing.
~/.deepagents/settings.json
{
"model": {
"active": { "provider": "openai", "id": "gpt-4o" },
"reasoning": "high",
"service_tier": "priority"
}
}Project-level settings in <project>/.deepagents/settings.json override user defaults.
CLI Reference
deepagents # Interactive TUI
deepagents --agent mybot # Named agent profile
deepagents --model openai:gpt-5.2 # Override model
deepagents --reasoning medium # Override reasoning effort
deepagents --no-auto-approve # Require all tool approvals
deepagents --no-thread-lock # Disable session locking| Command | What it does |
|---|---|
/model | Open model selector |
/model my-alias | Switch to model by alias |
/debug model | Inspect resolved model config |
/assemble | Run Linear issue pipeline |
/clear | Clear chat, new session |
/remember | Persist learnings to memory |
/tokens | Show token usage |
/threads | Show session info |
Type @ to fuzzy-search project files. Type / to browse commands.
What Makes This Different
Framework, not a fork
Clean pip dependency on deepagents. One coupling file. Upgrades are version bumps, not merge conflicts.
Non-blocking subagents
Background task middleware that makes subagents async — without changing a single line of upstream code.
Multi-provider from day one
OpenAI, Anthropic, Google, Cerebras — with OAuth so you can use your existing subscriptions.
Extensible by design
Plugin system for tools, middleware, commands, and hooks. Inspired by pi-mono's approach to composable agent tooling.
Tech Stack
| Component | Technology |
|---|---|
| Language | Python ≥3.11 |
| Agent Runtime | deepagents 0.4.1 (LangChain) |
| Graph Runtime | LangGraph with SQLite checkpoints |
| Terminal UI | Textual |
| LLM Providers | langchain-openai, langchain-anthropic, langchain-google-genai |
| Tool Protocol | MCP (Model Context Protocol) |
| Persistence | SQLite via aiosqlite + langgraph-checkpoint-sqlite |
| Packaging | setuptools + uv |
Install
# With uv (recommended)
uv pip install -e .
# Or pip
pip install -e .
# Run
deepagentsReferences
- deepagents — LangChain's deep agent framework (upstream): GitHub
- pi-mono — Extensible agent toolkit inspiration: GitHub
- LangGraph — Stateful agent orchestration: docs
- Model Context Protocol — Tool server standard: modelcontextprotocol.io
- Textual — Terminal UI framework: textual.textualize.io
- Noktua — The desktop GUI sibling (same patterns, Electron UI): Noktua docs
- Xena — The webhook-first sibling (autonomous operations): Xena docs