← Open Source & Engineering Work
Vercel · AI SDKMerged Upstream

Isolating Claude Code Subagent Events from Parent-Step Tracking

A Vercel AI SDK contribution that prevents Claude Code subagent messages from contaminating parent-step usage and tool-event tracking. Merged upstream in PR #18740 with explicit credit to @patrickswedish.

Isolating Claude Code Subagent Events from Parent-Step Tracking

PR #18740

merged upstream

PR #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 processed those messages as belonging to parent agent steps, corrupting token accounting.

02 · Technical response

What changed

  1. 01Filtered subagent-originated messages before parent-step normalization.
  2. 02Preserved parent-agent token usage and tool handling without breaking public APIs.

03 · Verified outcome

Evidence-backed result

  • Vercel engineer Felix Arntz approved and shipped the fix upstream in PR #18740 with full credit.
  • Prevented nested token leakage across agent workflows.

04 · Public record

Source evidence

TypeScriptVercel AI SDKClaude CodeAgent Harnesses

Independent open-source engineering by Patrick Ribbsaeter. Company and project names identify the public repository and maintainer context only. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.