feat(core): Task tool — sub-agent invocation#98
Merged
Conversation
The agent could load sub-agents (.deepcode/agents/*.md) but had no tool to RUN
one — the biggest §0.1 parity gap. Add the Task tool + a runSubAgent runner
threaded into ToolContext by runAgent (which has provider/model/tools in scope):
- Task({prompt, subagent_type?, description?}) runs a named sub-agent (or a
generic one) in a fresh context and returns only its final text.
- The sub-agent gets a filtered tool registry (its frontmatter `tools` whitelist
minus a denylist of Task/Enter·ExitPlanMode/AskUserQuestion), its own
model/maxTurns from frontmatter, no session, and clean (no) system reminders.
- Recursion is capped (MAX_SUBAGENT_DEPTH=1): a sub-agent gets no runSubAgent and
no Task tool, so it can't spawn further sub-agents — Task fails gracefully.
- The runner is built inline (no ToolRegistry import) + lazy-loads the sub-agent
loader, so agent.ts still drags zero node:fs into the renderer bundle.
+10 tests (Task unit incl. error paths; agent-loop integration runs a sub-agent
and feeds its output back; depth-guard). core 510 pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
The agent could load sub-agents (
.deepcode/agents/*.md) but had no tool to run one — the biggest §0.1 parity gap. Adds theTasktool + arunSubAgentrunner threaded intoToolContextbyrunAgent.Task({prompt, subagent_type?, description?})runs a named (or generic) sub-agent in a fresh context, returns only its final text.toolswhitelist minus a denylist of Task/Enter·ExitPlanMode/AskUserQuestion), its own model/maxTurns, no session, clean context.runSubAgentand noTask→ can't spawn more; fails gracefully.ToolRegistryimport) + lazy-loads the sub-agent loader → zeronode:fsinto the renderer bundle.+10 tests (unit error paths, agent-loop integration runs a sub-agent + feeds output back, depth guard). Full suite green: core 510, desktop 26, cli 59, lsp 8.
🤖 Generated with Claude Code