feat: refactor to Deep Agents architecture#503
Open
avoidwork wants to merge 30 commits into
Open
Conversation
- Replace react.js with clean deepAgents.js using createDeepAgent - Delete subAgent tool family (subAgent.js, subAgentLog.js, subAgentMessage.js) - Remove SUB_AGENT_TEMPERATURE env var handling - Remove old react_agent tests - Update index.js to use invokeAgent with Deep Agents streaming - Add coding-agent and utility-agent subagents with SUB_AGENT.md prompts - Fix process tool name from processTool to process - All 1128 tests passing
Owner
Author
Audit ResultsStatus: Complete Verification:
Diff: +624 / -2943 lines across 23 files Specs vs Implementation:
Ready for review and merge. |
- Remove unused variables from invokeAgent (signal, maxContextLength, maxTokens) - Remove unused namespace variable from stream loop - Auto-format index.js and prompts.test.js
The checkpointer requires thread_id in the configurable property to persist conversation state. Added configurable to streamOptions.
Pass systemPrompt to createDeepAgentsOrchestrator factory. Remove manual SystemMessage prepending from invokeAgent.
- streamMode: ['updates', 'messages'] to get text chunks and tool events - Handle mode === 'messages' for text/reasoning output - Handle mode === 'updates' for tool_start/tool_end/tool_error events
- Fix letconst syntax error from corrupted patch - Add missing variable initializations (currentMessages, compactionActive, etc.) - Restore proper while loop and try/catch structure - System prompt prepending restored in invokeAgent for new threads
Owner
Author
Deep Agents Overlap Analysisdeepagents provides built-in middleware that includes these tool categories:
Overlapping Tools (can be removed from madz)
Non-Overlapping Tools (unique to madz — keep)
Summary: 9 of 25 tools overlap with deepagents middleware. The remaining 16 are unique to madz and should stay. Want me to remove the overlapping tools and wire up the deepagents middleware instead? |
…apping tools - Create FileBackend implementing BackendProtocolV2 for file storage - Wire up createFilesystemMiddleware, createMemoryMiddleware, createSkillsMiddleware, createSummarizationMiddleware - Remove 9 overlapping tools from madz (readFile, writeFile, patch, searchFiles, memory, skillView, createSkill, compactContext, compaction) - Remove LRU caching from deepAgents.js - Remove unused compaction logic, constants, and imports - Remaining 16 tools are madz-specific and stay
- Delete obsolete tests for removed compactContext and compaction tools - Update tool_index.test.js to reflect current tool registry (16 tools) - Update tool_registration.test.js assertions for removed tools
The TUI's handleChat callback expects events with { type, text } shape,
but callProvider was passing raw strings. This caused assistant response
text to never render in the conversation panel.
- Pass middleware array to createDeepAgent (was built but never wired in)
- Fix streaming callback to pass structured {type, text} events instead of raw strings
- Remove unused RECURSION_LIMIT_MESSAGE constant
- Remove unnecessary try/catch re-throw wrapper in callProvider
- Prefix unused namespace variable with _ to satisfy linter
- README.md: Agent section, tools table, env vars, directory structure - docs/OVERVIEW.md: Replace Sub-Agent section with Deep Agents, remove Sub-Agent Log/Message sections - docs/FLOWS.md: Replace Sub-Agent flows with Deep Agents orchestration flow - docs/TUTORIAL.md: Update built-in tools section
- README.md: remove subAgent config entries, change 'specialized sub-agents' to 'specialized agents' - docs/OVERVIEW.md: remove sub-agent references, rephrase code identifiers - docs/FLOWS.md: change section titles and references
- README.md: remove subAgent, subAgentLog, subAgentMessage from tools table - docs/FLOWS.md: remove subAgentLog from file dependencies - docs/TUTORIAL.md: remove subAgent tool mention
- Split tools into Deep Agents middleware (filesystem, memory, skills, summarization) - and built-in LangChain tools gated by sandbox permissions - Omitted compactContext as requested
Removed filesystem.js, memory.js, skills.js, compact_context.js, compaction.js and their tests — these are now handled by deepagents middleware.
- Delete prompts/COMPACTION.md - Rename SUB_AGENT.md → CODE_AGENT.md - Update deepAgents.js to load CODE_AGENT.md - Rewrite CODE_AGENT.md as a tight, deliverables-focused coding agent prompt
…dule and tiny-lru - Replace 'sub-agent' with 'deep agent' in system prompt (3 occurrences) - Delete src/cache/llm_cache.js and remove tiny-lru dependency
…from deepagents - Remove utility-agent subagent from src/agent/deepAgents.js - Remove utilityAgent config from config.yaml - Update README.md, docs/OVERVIEW.md, docs/FLOWS.md, docs/TUTORIAL.md - Update JSDoc comment in deepAgents.js
dd960c1 to
da239a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactored the LangGraph-based ReAct agent to use LangChain's Deep Agents architecture. Replaced the process-spawning subAgent tool family with a native orchestrator that manages specialized agents (coding agent, utility agent) for task delegation.
Changes
Architecture
Main Agent (orchestrator) with coding-agent and utility-agent subagents.
Uses createDeepAgent with streamMode updates and subgraphs true for native streaming.
Testing
Related Issues
Closes #502