feat(runtime): sub-agent progress reporting (loop emitter + OnEvent translate) (#455) - #462
Merged
Merged
Conversation
…#455) Inject the run-level emitter into the tool ctx before ExecuteToolCalls so the generic task tool can retrieve it (ProgressEmitterFromContext) and translate a dispatched child's tool-execution / turn boundaries into SubAgentProgressEvent on the parent stream. - loop.go: WithProgressEmitter(ctx, emitFrom) -> ExecuteToolCalls - subagent.go: executeGoroutine threads the parent tool-call id + description, installs an OnEvent handler that emits SubAgentProgressEvent (activity from activityOf, coarse token estimate from streamed text); child text still forwarded via onUpdate; nil parent emitter is a silent no-op - task.go: activityOf mapping (read->Reading, edit/write->Editing, bash->Running bash, grep/find/ls->Searching, webfetch->Fetching, TurnStart->Thinking) + estimateTokens - tests: activity mapping, child tool -> progress with parent id, nil-emitter no-panic Closes #455
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
Node #455: 子 agent 进度上报. The parent loop injects its run-level emitter into the tool context so the generic
tasktool can surface a dispatched child's structured progress up the parent event stream.loop.go:toolCtx := agentcore.WithProgressEmitter(ctx, emitFrom)beforeExecuteToolCalls.subagent.go:executeGoroutinethreads the parent tool-callid+description; installs a childDrainStreamOnEventhandler that translates child tool-execution / turn boundaries intoSubAgentProgressEvent{ToolCallID, Description, Activity, Tokens}via the ctx emitter. Reporting is per child tool-start / turn boundary (not per text delta). Child text is still forwarded viaonUpdate(no regression). Nil parent emitter is a silent no-op.task.go:activityOfmapping (read→Reading, edit/write→Editing, bash→Running bash, grep/find/ls→Searching, webfetch→Fetching, TurnStart→Thinking, else "") + coarseestimateTokens.Test plan
TestActivityOfpins the child-event → activity mapping.TestTaskEmitsSubAgentProgress: child read tool →SubAgentProgressEventwithToolCallID == parent idandActivity == "Reading".TestTaskNilEmitterNoPanic: nil emitter → no panic, no emission, child text returned.go build ./... && go vet ./... && go test ./internal/agentcore/... ./internal/runtime/...all pass.Closes #455