feat: expose subagent lifecycle tools (list_agents, kill_agent) + asy… - #20846
Closed
RoamingQuack wants to merge 1 commit into
Closed
feat: expose subagent lifecycle tools (list_agents, kill_agent) + asy…#20846RoamingQuack wants to merge 1 commit into
RoamingQuack wants to merge 1 commit into
Conversation
…nc completion queue - list_agents: expose list_active_subagents() as an agent-callable tool. Returns ID/status/role/goal/uptime/tool_count for all active subagents. Internal fields (_agent, _executor, _future) are stripped from output. - kill_agent: expose interrupt_subagent() as an agent-callable tool. Polite mode (default): sets interrupt flag, child stops at next boundary. Force mode (force=true): additionally shuts down per-child executor with wait=False/cancel_futures so the parent's delegate_task() call exits immediately. - async_notification: emit DelegateEvent.TASK_COMPLETED to a new _subagent_completion_queue (mirrors ProcessRegistry.completion_queue). drain_subagent_completions() is provided for the gateway to consume after each agent turn (Mastra streamUntilIdle pattern). - Both tools blocked from subagents via DELEGATE_BLOCKED_TOOLS. - Executor/future refs stored in _active_subagents registry for force-kill. - No breaking changes — interrupt_subagent(force=False) defaults preserved.
This was referenced Aug 19, 2026
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.
What does this PR do?
Exposes three previously internal subagent lifecycle capabilities as agent-callable tools, and adds an async notification queue for subagent completion events. This closes critical observability/control gaps identified through cross-framework research (Claude Code, OpenAI Agents SDK, LangGraph, CrewAI, AutoGen, Mastra, Vercel AI SDK, Agno, Pydantic AI).
The three capabilities were already partially implemented in Hermes internals (TUI-only or gatekept behind internal APIs) — this PR surfaces them to the agent itself so it can self-manage its subagent tree.
Changes Made
tools/delegate_tool.py:
toolsets.py:
How to Test
Type of Change
Checklist
Code
Documentation & Housekeeping