跪拜 Guibai
← All articles
JavaScript · Agent

Subagents, Files, and Skills: A Deep Research Assistant Built on Deep Agents

By YIAN ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

This pattern is the difference between a demo and a tool that survives long research tasks. It shows how to enforce real constraints with tools and middleware instead of hoping the model obeys the prompt.

Summary

Deep Agents shifts the design of a research assistant from a single-agent prompt loop to a multi-agent orchestration. The demo uses one main agent to plan and deliver, a researcher subagent that runs web searches and writes findings files, an analyst that executes JavaScript through a QuickJS REPL, and an editor that reviews drafts without touching files. A general-purpose subagent comes built in via createDeepAgent, so there's no need to declare it yourself. The key architectural choice is file-based communication between subagents: each subagent runs in an isolated context and receives only the task description passed through the task tool, so intermediate results have to be written to disk in a self-contained form. A FilesystemBackend with virtualMode maps stable virtual paths like /workspace/sources/ to the real project directory, which keeps prompts independent of machine-specific paths.

Pitfalls and engineering constraints get as much attention as the build itself. Skills are loaded progressively: the middleware reads only name and description first, and the full SKILL.md is read only when the model deems it relevant. But a skill is guidance, not a hard constraint; any rule you need enforced, like a maximum search count, has to live in tool code or middleware. A common bug: a skills path that doesn't match the backend's rootDir gets silently skipped, so the agent runs but never loads the skill. The demo also recommends per-run workspace directories to avoid stale findings files contaminating a new report. The progression from prompt-driven to engineering-driven is the core lesson: prompts decide what the agent wants to do, while tools, middleware, backends, and checkpoints decide what it can and cannot do.

Takeaways
— createDeepAgent automatically includes a general-purpose subagent; you don't have to declare it in subagents.
— The task tool takes only description and subagent_type; the description becomes the subagent's entire user message, so any file path must be embedded there.
— FilesystemBackend with virtualMode: true maps virtual paths like /workspace/sources/ to the project root, keeping prompts independent of the real directory layout.
— Skill middleware loads only each skill's name and description first; the full SKILL.md is read only when the model decides it's relevant.
— A skill is not a subagent and not a hard constraint; limits like 'search at most three times' must be implemented in tool code or middleware.
— Subagents run with isolated contexts; they only see the task description, not the main agent's history, so findings files must be self-contained.
— A mismatched skills path (e.g., /skills/ instead of /src/skills/) is silently skipped by Deep Agents; the agent runs but never loads the skill.
— Use per-run workspace directories like workspace/runs/2026-11-23-ai-news/ to prevent old findings files from being read into a new report.
— The CLI should print the final AI text, report file path, and subagent status, not just tool call names.
— For actual code execution, use createCodeInterpreterMiddleware(); writing 'do math' in the prompt isn't enough.
— Enforce file permissions so only the main agent can write the final report; the editor should be read-only.
Conclusions

File-based handoffs between subagents force each agent to produce auditable artifacts; that's a pragmatic fix for context bloat and for debugging long agent runs.

Prompts define what the agent wants to do, but the real claim is that tools, middleware, backends, and checkpoints define what it can and cannot do.

Progressive skill loading is a compromise: it keeps the initial prompt small, but it relies on the model to ask for the right manual, which is itself a fragile behavior.

Silent skill-loading failure reveals that agent frameworks often fail softly; without observable output, you may never notice a skill didn't load.

Concepts & terms
Deep Agents
A LangChain framework that runs a main agent plus subagents, each with its own context, tools, and system prompt. It provides file tools, a task tool for delegation, and a skill system.
FilesystemBackend
A Deep Agents backend that gives the agent read/write access to the host filesystem. With virtualMode, virtual paths like /workspace/ map to a real root directory.
Skill
A markdown work manual (SKILL.md) containing a name, description, and instructions. The main agent can load it on demand to get domain-specific procedures.
task tool
A built-in Deep Agents tool that lets the main agent delegate a job to a subagent. It takes a description and subagent_type; the description becomes the subagent's user message.
Subagent
A separate agent instance with its own system prompt, tools, and middleware. In this demo, researcher, analyst, and editor each have a focused role and isolated context.
createCodeInterpreterMiddleware
A middleware from @langchain/quickjs that injects a JavaScript REPL into an agent, so it can execute code rather than reason about calculations.
Checkpointer
A mechanism to persist agent state, often via a thread_id, so long tasks can resume after interruptions.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗