feat: add SubagentTool for task delegation#43
Merged
priyanshujain merged 14 commits intomasterfrom Mar 10, 2026
Merged
Conversation
Implements a subagent tool that spawns a child agent with its own context, fresh history, and reduced maxIter. The child registry is built via a factory function that excludes the subagent tool itself, preventing recursion.
Covers simple task, child tool use, max iterations, no-recursion guard, context cancellation, empty task, and name verification.
Registers the subagent tool with a factory that provides child agents with all standard tools except subagent itself.
Registers the subagent tool with a factory that provides child agents with all standard tools except subagent itself.
Parent and child tool lists were duplicated in telegram session, CLI chat, and the subagent tool factory. Now all use NewStandardRegistry().
Adds a ## Sub-agents section explaining when to use vs not use the subagent tool, inspired by patterns from openclaw and zeroclaw.
Avoids real shell execution in unit tests. The stubTool returns a fixed output, making tests faster and more deterministic.
The judge couldn't distinguish which facts came from memory vs email because the criteria only marked one memory fact explicitly. Now both memory facts (Raj Patel role, June 15 deadline) and both email facts (Sprint 7 Retro, Launch Prep) are enumerated with their source, so the judge can properly attribute and verify each.
Has checks if a tool is registered by name. ToolNames returns all registered tool names sorted alphabetically. These will be used to auto-generate the tool list in system prompts.
…egistry The tool list is derived from Registry.ToolNames() so it can never drift out of sync. Sub-agents section is conditionally included based on whether the subagent tool is registered. Skills section loads the index dynamically.
Removes the duplicated buildSystemPrompt() function. The tool list is now auto-generated from the registry.
Removes the duplicated buildSystemPrompt() function and replaces it with the shared builder. User memory injection extracted into its own method for clarity.
Removes the third copy of buildSystemPrompt(). The spectest fixture now uses the same shared builder, with the tool list auto-generated from its 4-tool registry.
…ompt "Be concise and direct" was only in the Telegram prompt originally, not in CLI or spectest. Adding it to the shared prompt caused the spectest LLMs to skip skill discovery steps. Now it's back in Telegram's own prompt composition.
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.
Summary
subagenttool that lets the parent agent delegate self-contained sub-tasks to a child agentmaxIter(10), and its own tool registry that excludessubagent(preventing recursion)Design
Files changed
agent/tools/subagent.goagent/tools/subagent_test.gochannel/telegram/session.gointernal/cli/chat.goTest plan
go build ./...compiles without errorsgo test ./agent/tools/...— all 7 subagent tests passgo test ./...— no new failures (existing Gemini API key failures only)obk chat→ ask to "use a subagent to list files and summarize them"