Skip to content

feat(runtime): sub-agent progress reporting (loop emitter + OnEvent translate) (#455) - #462

Merged
smallnest merged 1 commit into
masterfrom
feat/node-455-progress
Jul 31, 2026
Merged

feat(runtime): sub-agent progress reporting (loop emitter + OnEvent translate) (#455)#462
smallnest merged 1 commit into
masterfrom
feat/node-455-progress

Conversation

@smallnest

Copy link
Copy Markdown
Owner

Summary

Node #455: 子 agent 进度上报. The parent loop injects its run-level emitter into the tool context so the generic task tool can surface a dispatched child's structured progress up the parent event stream.

  • loop.go: toolCtx := agentcore.WithProgressEmitter(ctx, emitFrom) before ExecuteToolCalls.
  • subagent.go: executeGoroutine threads the parent tool-call id + description; installs a child DrainStream OnEvent handler that translates child tool-execution / turn boundaries into SubAgentProgressEvent{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 via onUpdate (no regression). 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, else "") + coarse estimateTokens.

Test plan

  • TestActivityOf pins the child-event → activity mapping.
  • TestTaskEmitsSubAgentProgress: child read tool → SubAgentProgressEvent with ToolCallID == parent id and Activity == "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

…#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
@smallnest
smallnest merged commit 51cc439 into master Jul 31, 2026
1 check passed
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.

子 agent 进度上报(loop 注入 emitter + OnEvent 翻译)

1 participant