Skip to content

Send helpers home when their subagent hands back - #112

Draft
tuliren wants to merge 2 commits into
mainfrom
claude/project-thread-34j1kk
Draft

tuliren wants to merge 2 commits into
mainfrom
claude/project-thread-34j1kk

Conversation

@tuliren

@tuliren tuliren commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Requested by T · project thread

What was wrong

Some subagents fire no SubagentStart and no SubagentStop hook at all. A recorded session from 2026-11-21 has a web-fetch subagent like that: its tool calls carry its aid, so a helper walks in on its first call, but nothing ever said it was done, so the helper stood at its lead's desk until the whole session left. Replaying that bus through the director on main showed the helper still there 10+ minutes after it finished. Core is the same in agentopiahq@0.4.0 and main, so both have the bug.

Fix

Every subagent ends by calling SubagentHandback to give its report to the lead. The Claude adapter now reads a PostToolUse of that tool (with an aid) as worker.stop, and stages nothing for its PreToolUse or a failed attempt. Where SubagentStop does fire too (about 30 ms later in Claude Code 2.1.201), that second stop does nothing, because the helper is already on its way out.

Tests

  • New fixture 06-subagent-handback.jsonl, taken from the real session with ids anonymized. The reducer and director tests both fail without the fix.
  • Adapter cases for the hand-back, plus a director case for a hand-back followed by a SubagentStop.
  • yarn lint, yarn typecheck, yarn test and yarn format:check all pass.

Patch changeset included.

Some subagents (the web-fetch helper, for one) fire no SubagentStart or
SubagentStop, so their helper stayed at the lead's desk for the rest of
the session. The adapter now reads a SubagentHandback that went through as
worker.stop. Adds a fixture distilled from a real session.
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentopia Ready Ready Preview Nov 22, 2026 11:06pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 923ce78d Deployed Nov 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant