feat(agent-core): stream background subagent progress into /tasks#293
Open
persovt2 wants to merge 1 commit into
Open
feat(agent-core): stream background subagent progress into /tasks#293persovt2 wants to merge 1 commit into
persovt2 wants to merge 1 commit into
Conversation
Background subagents are Promise-based, so BackgroundProcessManager had no live proc.stdout to capture and their /tasks output pane stayed empty until completion. Tap the child agent's event stream via a new in-process Agent.onEvent, format assistant deltas and tool-call boundaries into log text, and feed it through registerAgentTask's outputSource into the task's ring buffer + output.log — matching background bash tasks. Output subscription is released on every terminal path (completed, failed, killed, timeout) via finalizeTerminal. Foreground subagents are unaffected. Closes MoonshotAI#292
🦋 Changeset detectedLatest commit: 34e1b34 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Related Issue
Resolve #292
Problem
Background subagents launched with
Agent(run_in_background=true)appear in/tasks, but their output pane stays empty until completion — only the final summary lands at the end. Background bash tasks stream live in the same UI, so there is no way to watch what a long-running background subagent is doing while it runs.Cause: agent tasks are Promise-based, so
BackgroundProcessManagerhas no liveproc.stdoutto capture —registerAgentTaskuses a dummy process whose stdout handlers are no-ops, and only the final result is appended on completion.What changed
Agent.onEvent— a lightweight in-process event tap, fanned out alongside the existing RPC sink (size-guarded so it stays free on the no-tap hot path).SubagentProgress+formatSubagentEvent(newsession/subagent-progress.ts) — buffer the child agent's events (assistant deltas, tool-call boundaries) as compact log text. Tool results are reduced to a one-line status so the log stays small; the buffer replays anything captured before the manager subscribes, so no early output is lost.SessionSubagentHosttaps the child only for background runs (foreground already streams inline via RPC) and coalesces deltas to keepoutput.logappends coarse.registerAgentTaskgains an optionaloutputSource; the manager streams chunks into the same ring buffer +output.logthat bash tasks use, and releases the subscription on every terminal path (completed/failed/killed/timeout) viafinalizeTerminal.Result:
/tasksshows live subagent progress, consistent with background bash tasks. Foreground subagents are unaffected.Checklist
SubagentProgress/formatSubagentEvent,Agent.onEvent,registerAgentTaskoutputSource; integration: host streams background progress, omits it for foreground)..changeset/stream-subagent-progress.md).