nof0xgiven

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

LangChain · LangGraph · LLM Provider SDKsdeepagents 0.4.1 (LangChain upstream)agent loop · planning tool · virtual filesystem · subagent spawning · memory middleware · skills middlewarepip dependency — no forks, no patchesimportsdeepagents_cli (this repo)Terminal UITextual TUIchat · approvalsslash commandsstreaming diffsAuth + Modelsmulti-provider registryOAuth + API keyslive model switchingreasoning effortExtensionsplugin systemMCP integrationcustom toolsmiddleware hooksRuntimebackground tasksthread persistencesession checkpointsthread lockingcoupling point: agent.py → create_deep_agent()

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)

LayerWhat it doesWhy it's needed
Terminal UIFull Textual TUI — chat, streaming, tool approvals, slash commands, autocompletedeepagents has no interface
Multi-provider authAPI keys + OAuth for OpenAI, Anthropic, GoogleYou wire up auth yourself in base deepagents
Model registryCatalog with live switching, aliases, reasoning effort, service tiersNo built-in model management
Provider adaptersOpenAI Responses API, Anthropic Messages, Google Generative AIdeepagents is model-agnostic — you write the glue
OAuth supportUse your existing Claude Pro/Max or Google AI Studio subscriptionBase library only supports API key env vars
ExtensionsPlugin system for custom tools, middleware, subagents, hooksdeepagents is extendable but has no plugin architecture
MCP integrationChrome DevTools, external tool servers via Model Context ProtocolNot in base deepagents
Background subagentsNon-blocking task execution with check_task/wait_for_task + live activity pillBase flow blocks on subagent completion
Command system/model, /assemble, /clear, /remember, /tokensNo CLI command framework upstream
Linear integration/assemble pipeline: scout → planner → worker → reviewerDomain-specific workflow
Session managementThread persistence, checkpoint resumption, conversation historyCheckpointing 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 .
deepagents

On 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 completion

The 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 skills

Skills 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 override

Subagent 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
CommandWhat it does
/modelOpen model selector
/model my-aliasSwitch to model by alias
/debug modelInspect resolved model config
/assembleRun Linear issue pipeline
/clearClear chat, new session
/rememberPersist learnings to memory
/tokensShow token usage
/threadsShow 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

ComponentTechnology
LanguagePython ≥3.11
Agent Runtimedeepagents 0.4.1 (LangChain)
Graph RuntimeLangGraph with SQLite checkpoints
Terminal UITextual
LLM Providerslangchain-openai, langchain-anthropic, langchain-google-genai
Tool ProtocolMCP (Model Context Protocol)
PersistenceSQLite via aiosqlite + langgraph-checkpoint-sqlite
Packagingsetuptools + uv

Install

# With uv (recommended)
uv pip install -e .

# Or pip
pip install -e .

# Run
deepagents

References

  • 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

On this page