7.1 KiB
7.1 KiB
Notes: LangChain DeepAgents vs rig-deepagents (Full Audit)
Sources
Source 1: Python DeepAgents (LangChain)
- Path:
deepagents_sourcecode/libs/deepagents/deepagents/graph.py - Key points:
create_deep_agentwires default middleware:TodoListMiddleware,FilesystemMiddleware,SubAgentMiddleware,SummarizationMiddleware,AnthropicPromptCachingMiddleware,PatchToolCallsMiddleware; addsHumanInTheLoopMiddlewarewheninterrupt_onis set.- Filesystem toolset includes
ls,read_file,write_file,edit_file,glob,grep,execute. - Subagents use default middleware/tools and can attach
interrupt_on; includes a general-purpose subagent. create_agent(...).with_config({"recursion_limit": 1000}).
Source 2: Python DeepAgents Filesystem Middleware
- Path:
deepagents_sourcecode/libs/deepagents/deepagents/middleware/filesystem.py - Key points:
- Tools update state via
Command(update={...})when backend returnsfiles_update(write/edit). executetool added only if backend supportsSandboxBackendProtocol.- Path validation normalizes and rejects traversal; Windows absolute paths are rejected.
- Large tool result eviction into filesystem via
tool_token_limit_before_evict. - Model call wrapping removes unsupported execute tool and injects dynamic system prompt.
- Tools update state via
Source 3: Python DeepAgents Subagents
- Path:
deepagents_sourcecode/libs/deepagents/deepagents/middleware/subagents.py - Key points:
SubAgentschema supportsinterrupt_onanddefault_middleware/default_interrupt_on.tasktool returnsCommandwith state updates (excludes messages/todos/structured_response).- Requires
ToolRuntime.tool_call_idfor returning updates. - Parallel subagent calls are supported via multiple tool_calls in a single message.
Source 4: Python DeepAgents Backends
- Paths:
deepagents_sourcecode/libs/deepagents/deepagents/backends/* - Key points:
StoreBackendsupports LangGraphBaseStore(long-term memory across threads).SandboxBackendProtocolprovidesexecutecapability for shell commands;BaseSandboxhelper exists.BackendFactoryallows runtime-based backend selection.grepuses regex (re.compile) in utils.StateBackendreturnsfiles_updateand relies on LangGraphCommandupdates (state is not mutated directly).
Source 5: Python DeepAgents Tests (Behavioral Spec)
- Paths:
deepagents_sourcecode/libs/deepagents/tests/* - Key points:
create_deep_agentsupportsresponse_format(ToolStrategy) andcontext_schema.FilesystemMiddlewareexposes 7 tools incl. execute, and evicts large tool results into files.StateBackendsupports regex grep errors;CompositeBackendrouting tested.SubAgentreturns ToolMessage with final response and merges state updates.- Checkpointer usage (
InMemorySaver) used withcreate_deep_agentinvocations.
Source 6: deepagents-cli (Adjacent Capabilities)
- Paths:
deepagents_sourcecode/libs/deepagents-cli/* - Key points:
- Adds
shell,web_search,fetch_urltools, memory middleware, skills middleware, auto-approve HITL. - Persistent memory stored via
.deepagents/agent.mdand project.deepagents/files. - Skills system supports project/user-level skills with progressive disclosure.
- Adds
Source 7: Rust rig-deepagents
- Paths:
rust-research-agent/crates/rig-deepagents/src/* - Key points:
- No
create_deep_agentfactory; usesAgentExecutor+MiddlewareStack+ explicit tool injection. - Tools available:
read_file,write_file,edit_file,ls,glob,grep,write_todos,task,think,tavily_search. Noexecutetool. Backendtrait lacksexecute; includesexists/delete(extra vs Python).- Tools return
Stringonly; no mechanism to returnCommand-like state updates. ToolRuntimehastool_call_idbut executor does not set it per tool call.- Subagent config includes
default_middlewarebut is not applied inSubAgentMiddleware::new. SubAgentSpeclacksinterrupt_onanddefault_interrupt_onhandling.SummarizationMiddleware,PatchToolCallsMiddleware,HumanInTheLoopMiddlewareexist but are not wired as defaults.grepis literal (non-regex) by design; path validation does not reject Windows absolute paths.- Rust includes extra systems absent in Python: Pregel runtime/checkpointer, workflow graph, skills middleware, research workflows.
- No
Source 8: Rust Pregel Workflow System
- Paths:
rust-research-agent/crates/rig-deepagents/src/pregel/*,src/workflow/* - Key points:
- Pregel runtime is custom;
WorkflowStateuses a single update type (no per-key reducers). - Agent execution in Pregel uses
AgentVertexwith tool registry; tools are executed viaMemoryBackendand do not mutate sharedAgentState. - Workflow vertices do not integrate middleware stack or file/todo updates.
- SubAgentVertex uses empty isolated state and
superstepas recursion proxy. - AgentExecutor (non-Pregel) is the primary DeepAgents path today.
- Pregel runtime is custom;
Synthesized Findings
Parity Gaps (Python has, Rust missing or incomplete)
create_deep_agenthigh-level factory with default middleware + base prompt + recursion_limit.- Filesystem middleware behavior: toolset auto-injection + state updates on write/edit + tool-result eviction.
- Planning middleware (
TodoListMiddleware) behavior:write_todosupdates state. executetool + sandbox backend protocol.- Subagent default middleware/interrupt handling and state update propagation back to parent.
StoreBackend(LangGraph store) and backend factory pattern.ToolRuntime.tool_call_idpropagation to tools.- Regex-capable grep (Rust is literal only).
- Structured output wiring (
response_format,context_schema) and cache hooks increate_deep_agent. - Streaming + checkpointer integration in main agent path.
- Parallel tool-call execution semantics (Python allows parallel; Rust executor is sequential).
Pregel-Model Differences (Execution Layer)
- LangChain DeepAgents runs on LangGraph (Pregel-style) with Command state updates per tool.
- Rust pregel exists but deepagent logic uses a custom
AgentExecutor, not Pregel. - Rust Pregel workflow graph does not use the same middleware stack or filesystem/todo state reducers.
- LangGraph uses per-key reducers (e.g., files reducer supports deletion via
None); RustWorkflowStatelacks reducer-per-field semantics. - LangGraph tool execution can update state via
Command(update=...); Rust tool execution returnsStringonly. - LangGraph checkpointer and stream channels are part of the main agent path; Rust Pregel checkpointer exists but is not used by
AgentExecutor.
Divergences/Extras (Rust-only)
- Pregel workflow runtime + checkpointing backends (SQLite/Redis/Postgres).
- Skills middleware (progressive disclosure) included in Rust core.
- Research workflow builders (planner/search/synthesizer) in Rust.
- Backend supports
exists/delete(not exposed as tools).
Divergences/Extras (Python CLI-only)
- Shell tool, web search, fetch_url.
- Agent memory middleware (user/project memory).
- Skills system at user/project level in CLI distribution.