add subagent done notifications#212
Open
erikswedberg wants to merge 1 commit into
Open
Conversation
When a subagent finishes (agentWorking transitions to false), notify the parent conversation by injecting a summary message into its loop. This makes wait:false actually usable: the parent keeps working while subagents run, and gets notified with results when each one finishes — no blocking, no manual 'check on that subagent' prompting. Changes: - server/convo.go: onDone callback field on ConversationManager, called from SetAgentWorking when transitioning to not-working - server/server.go: notifyParentSubagentDone looks up parent, grabs last assistant response (truncated to 500 chars), injects [Subagent 'slug' finished] message into parent's loop - AGENTS.md: guideline to prefer wait:false for subagents Co-authored-by: Shelley <shelley@exe.dev>
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.
Subagent done notifications
The problem
Subagents force a bad choice: block or forget. With
wait: true(the default), the parent sits there stuck until the subagent finishes — serial execution, no parallelism. Withwait: false, the parent keeps working, but it never finds out the subagent finished. The results just sit there until the user manually prompts "check on that subagent." Neither option is good: you either waste time blocking, or you waste time chasing down results.The infrastructure for async is already there —
wait: falseexists,QueueUserMessageexists, the loop checks for injected messages between tool calls. But without notifications, async subagents are fire-and-forget. The parent has no way to know when results are ready.What this changes
When a subagent's
agentWorkingtransitions tofalse, anonDonecallback fires. This looks up the parent conversation, grabs the subagent's last assistant response (truncated to 500 chars), and injects a[Subagent 'slug' finished]\n<summary>user message into the parent's loop. The parent sees it between tool calls and can act on the results, catch errors, or adjust its plan without waiting for its own turn to end and without the user having to prompt it.Done notifications make
wait: falseactually usable. The parent keeps working while subagents run, and gets notified with a summary when each one finishes — so it can react, catch errors, and incorporate results within the same turn. No blocking, no forgetting. Subagents go from fire-and-wait to genuinely async and interactive: launch, continue working, react when results arrive.What it feels like
Before: you either block with
wait: trueand watch the parent do nothing for minutes, or usewait: falseand then spend time prompting "go check on that subagent" and discovering one of them went sideways after the fact.After: subagent results flow into the parent automatically — the parent reacts to a subagent finishing, checks if the output makes sense, and incorporates it into its work, all within the same turn.
Changes
server/convo.go:onDonecallback field onConversationManager, called fromSetAgentWorkingwhen transitioning to not-workingserver/server.go:notifyParentSubagentDonemethod;onDonewired ingetOrCreateSubagentConversationManagerAGENTS.md: guideline about preferringwait: falsefor subagentsWhat it doesn't change
loop.gois untouched —QueueUserMessageand the between-tool-calls check already existeddrainPendingMessagesis untouchedHow to test
wait: false— e.g. "launch two subagents: one to count the Go files in this repo, one to count the TypeScript files"[Subagent 'slug' finished]message appears in the parent's conversation with a summary of the resultPredictable model (no API key needed):
--predictable-onlyNotified parent of subagent completion