Skip to content

feat(core): emit SubagentProgress for child tool/turn milestones#41

Merged
ZhiXiao-Lin merged 1 commit into
mainfrom
feat/subagent-progress-events
May 23, 2026
Merged

feat(core): emit SubagentProgress for child tool/turn milestones#41
ZhiXiao-Lin merged 1 commit into
mainfrom
feat/subagent-progress-events

Conversation

@ZhiXiao-Lin
Copy link
Copy Markdown
Contributor

Replaces #36 which was auto-closed when its stacked base branch was deleted on merge of #35. Same commit, retargeted to `main`.

Summary

The `SubagentProgress` event variant existed but was never emitted — the tracker landed in #35 had no mid-task signal to update from. This PR fills that gap.

Adds `synthesize_subagent_progress()` in `tools/task.rs`, called by the mpsc → broadcast forwarder inside `TaskExecutor::execute_with_task_id`. Translates two child-loop events into compact progress milestones on the parent broadcast:

  • `ToolEnd` → `status = "tool_completed"`, `metadata = { tool, exit_code, output_bytes, error_kind? }`
  • `TurnEnd` → `status = "turn_completed"`, `metadata = { turn, total_tokens, prompt_tokens, completion_tokens }`

Noisy events (TextDelta / ToolStart / ToolOutputDelta / nested Subagent*) are intentionally not translated.

Test plan

  • 4 new unit tests for `synthesize_subagent_progress` cover ToolEnd, ToolEnd with error_kind, TurnEnd, and the negative cases.
  • Extended `parallel_task_executor_emits_subagent_events_for_each_child` to assert at least 2 `turn_completed` progress events arrive for a 2-task parallel run.
  • New integration test `subagent_progress_events_accumulate_in_tracker` verifies progress events flow through `RuntimeEventSink` into the tracker's `progress` Vec.
  • `cargo test --lib -p a3s-code-core` clean.

The `SubagentProgress` event variant exists but until now was never sent —
the subagent task tracker introduced in the previous commit observed
Start and End but had no mid-task signal to update from.

Adds a `synthesize_subagent_progress()` helper called by the mpsc → broadcast
forwarder inside `TaskExecutor::execute_with_task_id`. It translates two
child-loop events into compact progress milestones on the parent broadcast:

- `ToolEnd` → `status = "tool_completed"`, metadata `{ tool, exit_code,
  output_bytes, error_kind? }`
- `TurnEnd` → `status = "turn_completed"`, metadata `{ turn, total_tokens,
  prompt_tokens, completion_tokens }`

Noisy events (TextDelta / ToolStart / ToolOutputDelta / nested Subagent*)
are intentionally not translated — consumers needing token-level detail
should subscribe to the raw event stream directly.

The original child events are still forwarded unchanged; progress is
additive, so downstream consumers see both the synthesized milestone
and the underlying event.
@ZhiXiao-Lin ZhiXiao-Lin merged commit 706bc23 into main May 23, 2026
1 check passed
@ZhiXiao-Lin ZhiXiao-Lin deleted the feat/subagent-progress-events branch May 23, 2026 16:06
@ZhiXiao-Lin ZhiXiao-Lin mentioned this pull request May 23, 2026
8 tasks
ZhiXiao-Lin pushed a commit that referenced this pull request May 23, 2026
Bumps Rust core, Node SDK, and Python SDK to 3.2.0 and documents the
subagent task tracker work that landed across #35#41 + #38.

Changes
- Bump all five version files (core/sdk Cargo.toml, sdk/node/package.json,
  sdk/python/pyproject.toml) plus Node lockfiles and Cargo.lock.
- Mark SubagentStatus #[non_exhaustive] so future variants are non-
  breaking. The Cancelled variant added in this release still counts as
  a breaking change for exhaustive matchers — flagged in the CHANGELOG.
- Add a [3.2.0] section to CHANGELOG.md covering: the tracker query
  API, SubagentProgress emission, the Cancelled status and
  cancel_subagent_task entry point, Node + Python SDK exposure of all
  of the above, the regen-stable Node .d.ts split, and the
  TaskExecutor / register_task_with_mcp signature additions.
- Extend README with a "What's new in 3.2" block and a Delegation
  table that lays out the observe + cancel API across Rust, Node, and
  Python.

Preflight done locally
- cargo fmt --all --check
- cargo test -p a3s-code-core --lib  (1661 passed)
- cargo test -p a3s-code-core --tests (all green)
- scripts/check_release_versions.sh  (consistent at 3.2.0)
- (cd sdk/node && npm run build:debug && npm test && npm run test:types)

Not run here: release.sh / git tag. This commit is for review only;
tagging + publishing happens after the PR lands.
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.

2 participants