Agent Console Initialization (DeepAgents Full Stack · Complete Form)
Before starting, run
agent-dev/env-preflight(install docker/python/uv/bun + environment health check + version consistency).Detailed resources are in
references/: Copyable code inreferences/templates/, block-by-block explanations inreferences/backend-agent.md/backend-api.md/langgraph-json.md/docker-deploy.md/frontend.md, all pitfalls inreferences/pitfalls.md. This file only covers form, decisions, and workflow.
1. Complete Form (This Is What "Initialize an Agent" Looks Like)
┌─ Frontend (Vite + React + @langchain/react)──────────────────────────────┐
│ Top bar: Brand name · Navigation [Chat / Config / Tool Registration / Undeveloped UI] · Theme toggle |
│ │
│ Chat page Left: conversation list (search/copy/delete/clean empties/collapsible) │
│ Center: message stream (tool cards / sub-agents / reasoning stream / Tasks-Files panel) │
│ Composer: reasoning toggle · history (checkpoint time travel) · send │
│ Right: run details panel (**Undeveloped placeholder**) │
│ Config page tab1 Agent config: system prompt (custom instructions) + recursion limit │
│ tab2 Model config: provider / key / standard & reasoning models / temperature │
│ Tool registration tab1 Tools: two-level expander (integrated / self-developed → official groups) │
│ tab2 Skills: SKILL.md skill library (zip upload / paste creation / delete) │
│ Undeveloped UI Placeholder page (only shows "Not Developed") │
└──────────────────────────────────────────────────────────────────────┘
↕ HTTP/SSE
┌─ Backend (Python + deepagents + langgraph)─────────────────────────────┐
│ agent.py Dual graph registration (agent / agent-thinking) │
│ RuntimeConfigMiddleware: dynamically swap models / filter tools per config │
│ / append system prompt │
│ CompositeBackend: default=LocalShellBackend (execute available) │
│ routes: /skills/ real directory, /notes/ state │
│ TOOL_REGISTRY (custom tools) + skills=["/skills/"] │
│ TodoListMiddleware (planning, must be explicitly mounted) │
│ api.py /demo/* management routes: model config / Agent config / tool registry / skill library│
│ Config model_config.json, agent_config.json (mountable as volumes) │
│ Data skills/ (skill library), sandbox/ (execute working directory) │
└──────────────────────────────────────────────────────────────────────┘
↕
┌─ Deployment (Docker)──────────────────────────────────────────────────────┐
│ postgres(pgvector:pg16) + redis + langgraph-api + frontend(nginx) │
│ Volumes: pgdata(sessions) / appdata(thread metadata) / cfgdata(config) / datadata(skills)│
│ OSS route: python:3.12-slim + langgraph-cli[inmem] + custom PG checkpointer│
└──────────────────────────────────────────────────────────────────────┘
2. Seven Key Decisions (Solidified After Hitting Pitfalls)
- Runtime Config Middleware:
RuntimeConfigMiddlewarereads config before each model invocation (model / tool enable/disable / system prompt append). Changing config = writing a file; it takes effect on the next run. Do not rely on hot reload or rebuild the graph (hot reload oflanggraph devis unreliable on Windows). →references/backend-agent.md - Reasoning Mode = Multi-Graph Registration + Frontend Switching of AssistantId:
agent(standard model) andagent-thinking(deepseek-reasoner) each have their own graph. The frontend "reasoning" toggle switchesassistantIdand useskeyto remount. Thread states are shared across graphs, so the conversation list must not filter by graph; when switching, continue using the currentthreadIdas the seed. - Admin Backend Goes via
http.appinlanggraph.json(/demo/*), same process and port as the graph;langgraph-cli[inmem]does not include fastapi by default, it must be explicitly installed (file upload also requirespython-multipart). - Use Platform APIs Whenever Possible Instead of Building Custom Backend Endpoints: Sessions, runs, checkpoints, graph topology, store, and metrics are all provided by the platform (see
/docs). Custom endpoints only cover "concepts the platform doesn't know": model keys, tool enable/disable, system prompt, skill library. - Frontend Follows the Official deep-agents-ui Structure (conversation list / chat area / tool cards / Tasks-Files panel). Replace Next.js + shadcn with Vite + native CSS. Color scheme takes the two token sets from the official
globals.css. - Destructive operations always require confirmation (
ConfirmDialog). Batch operations follow "pre-check → confirm → execute". - Placeholder for undeveloped features:
NotDevelopedcomponent only shows "Not Developed"; the navigation item is directly called "Undeveloped UI"; do not write long planning lists.
3. Backend Key Points (See references/backend-agent.md and backend-api.md for Details)
# Composite backend: default determines execute availability; routes determine file storage
BACKEND = CompositeBackend(
default=LocalShellBackend(root_dir=SANDBOX_DIR, virtual_mode=True), # → execute available
routes={
"/skills/": FilesystemBackend(root_dir=SKILLS_DIR, virtual_mode=True), # Skill library (real directory)
"/notes/": StateBackend(), # In-thread files (Tasks/Files panel)
},
)
agent = create_deep_agent(
model=build_model(key="model"), # Placeholder instance; actual model injected by middleware
tools=list(TOOL_REGISTRY.values()),
system_prompt=SYSTEM_PROMPT,
backend=BACKEND,
skills=["/skills/"], # SKILL.md directory → inject skill list (progressive loading)
middleware=[RuntimeConfigMiddleware("model"), TodoListMiddleware()], # Planning must be explicitly mounted
)
agent_thinking = ... # Same structure, model_key="thinking_model"
| Built-in Capability | Provider | Notes |
|---|---|---|
ls/read_file/write_file/edit_file/delete/glob/grep | FilesystemMiddleware | Goes via backend routes |
execute | Requires SandboxBackendProtocol | supports_execution() only checks Composite's default |
task | SubAgentMiddleware | deepagents built-in general-purpose sub-agent |
write_todos | TodoListMiddleware (must be explicitly mounted) | Data source for the frontend Tasks panel |
| Skill library | SkillsMiddleware (skills=[...]) | Cached once per thread (skills_metadata); can use pinned_skills for forced loading |
Management API (api.py): /demo/model-config, /demo/agent-config (includes system_prompt + builtin_system_prompt),
/demo/tools (all visible tools + grouping/source/availability), /demo/skills (list / zip upload / text creation / delete).
4. Frontend Key Points (See references/frontend.md for Details)
useStream({ apiUrl, assistantId, threadId, onThreadId }); optimistic updates are built-in; loading state usesisLoading; history hydration usesisThreadLoading- Switching assistantId / session uses
keyremount;submitincludesconfig: { recursion_limit } - Reason stream must read from two sources: content blocks (
{type:"reasoning"}) +additional_kwargs.reasoning_content - Multi-tab pages: tabs sync with URL (
?tab=) + old route usesNavigate replace; each tab is an independent component - Theme toggles directly between two states + inline script in
index.htmlto prevent flash - Conversation capabilities all go via platform APIs:
threads.search/count/copy/prune/getHistory/updateState,assistants.search/getGraph
5. Deployment Key Points (See references/docker-deploy.md for Details)
- Two routes: ① Official
langchain/langgraph-apiimage (requires LANGSMITH_API_KEY/license); ② OSS server + custom checkpointer (default, no license required) - Data persistence: Sessions → PG (
pgdata); Thread metadata →appdata; Configuration (including system prompt) →cfgdata; Skills/Sandbox →datadata - Configuration and data directories use environment variables pointing to volumes:
AGENT_CONSOLE_CONFIG_DIR=/app/config,AGENT_CONSOLE_DATA_DIR=/app/data - Windows+WSL: WSL gets suspended after the last
wsl.execommand finishes (.wslconfig'svmIdleTimeoutis ineffective for WSL2) → Services userestart: unless-stopped+ keep-alive sessions (already built intodocker-up.ps1); native Linux servers should pay attention to firewall/security groups andsystemctl enable docker - Before verifying persistence, first confirm the container is actually running (
docker compose psshowslanggraph-api), otherwise you might be hitting a leftover dev service on the host
6. Initialization Workflow
0) agent-dev/env-preflight → install-deps (install dependencies) + preflight (health check)
1) Backend: agent.py → api.py → langgraph.json → pyproject.toml → .env
(Copy from references/templates/ and modify as per comments)
2) Start backend: langgraph dev --port 2024; verify with curl /ok, /demo/tools
3) Frontend: vite + @langchain/react + react-router; lib/chat.tsx → lib/api.ts → theme → components → pages
4) Integration test: Send a message (tool call + reply); switch to reasoning mode and verify reasoning stream
5) Docker: docker-compose.yml + Dockerfile.oss + checkpointer.py + start/stop scripts → verify "sessions/config/skills persist after container rebuild"
6) Documentation: Write the form and new pitfalls of this project back to the skill's references/
7. Pitfalls (Full Table in references/pitfalls.md)
Top Ten:
| Symptom | One-Sentence Cause |
|---|---|
| Changed code, behavior unchanged | Hot reload of langgraph dev unreliable on Windows → Restart service and confirm the process is actually replaced |
execute unavailable | supports_execution() only checks Composite's default → Set default to LocalShellBackend |
| Tasks/Files panel empty | After switching to a real backend, there is no files channel → Add a StateBackend route (/notes/) in Composite |
model reports 'coroutine' object has no attribute 'result' | awrap_model_call missing await handler(...) |
| See only 401 without configured key | before_agent + @hook_config(can_jump_to=["end"]) short-circuit with a human-readable message |
Upload endpoint reports Blocking call to os.getcwd | Endpoint defined as async def → Change to sync def |
Build reports not satisfiable | requires-python mismatches the image's Python version → Set python_version |
Container exits with Exited (0) after ~10 seconds | WSL gets suspended → restart: unless-stopped + keep-alive |
| Model "forgets", checkpoint is 0 | thread_id in body is ignored → Use POST /threads/{id}/runs/wait |
| Reasoning panel / file popup abnormal | Reasoning must read from two sources; files is a {content,…} structure |
8. Variants and Roadmap
v1 intentionally omits: Orchestration page / topology visualization (normal agents using ReAct/DeepAgent default loop suffice; when needed, use getGraph(xray) + threads.getHistory + forkFrom + subagents=); human-in-the-loop interrupt (interrupt_on + stream.respond, Provider already reserved); long-term memory (/store/* + memory middleware); multiple environment dev/prod layering.
Other directions: Official frontend source (E:/deep-agents-ui, old SDK style); Deploy to LangGraph Platform (official image requires license, but threads/runs/assistants also persist to PG); Replace execute with a truly isolated sandbox (E2B / Daytona).