Isolating Claude Code Subagent Events in Vercel AI SDK Harness Tracking
A Vercel AI SDK contribution that prevents Claude Code subagent messages from contaminating parent-step usage and tool-event tracking. Vercel engineer Felix Arntz approved PR #18631, then reimplemented the same change in signed PR #18740 because the original commits were unsigned. PR #18740 merged upstream with explicit credit to @patrickswedish.
#18740
merged upstream
#18631
credited source PR
69
harness tests
APPROVED
Felix Arntz
01 · Engineering problem
The failure mode
Claude Code Task-tool subagents emit messages with a non-null parent_tool_use_id. The harness was processing those messages as though they belonged to the parent agent step, allowing nested usage, tool calls, tool results, and partial text to leak into parent-step accounting and observability.
02 · Technical response
What changed
- 01Reproduced the failure using a representative captured Claude Code event stream.
- 02Filtered subagent-originated assistant, user, tool-result, and partial-stream messages before parent-step normalization.
- 03Preserved normal parent-agent token usage and tool handling without changing the public API.
- 04Addressed review feedback, including partial stream-event isolation, and kept the patch focused with regression coverage and the required changeset.
03 · Verified outcome
Evidence, not implication
- ✓Vercel engineer Felix Arntz approved PR #18631 with: Thank you for the PR, LGTM!
- ✓Vercel’s bugfix review classified the issue as fully addressed with low side-effect risk and no breaking-change, architecture, performance, or security risk.
- ✓PR #18631 was closed only because its commits lacked required signatures; Felix reimplemented the same change in signed PR #18740.
- ✓PR #18740 merged upstream and explicitly credits @patrickswedish as the source contribution.
04 · Public record
Source evidence
Independent engineering and open-source work by Patrick Ribbsaeter / Ribbsaeter Systems. References to maintainers, repositories, or companies identify the public technical context only. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.