← Open Source & Engineering Work
Vercel Open Source · vercel/aiAdopted Upstream · Vercel AI SDK (PR #18631)

fix(harness-claude-code): isolate subagent step tracking (#18631)

Sole Author: Patrick Ribbsaeter (@patrickswedish) · Immutable Commit SHA: 2db9e370e66b56e7802b30e7ea359d9dc9e27209

TypeScript streaming state-machine fix isolating nested parent_tool_use_id subagent events from parent step lifecycle boundaries in Vercel AI SDK's Claude Code harness.

fix(harness-claude-code): isolate subagent step tracking (#18631)

PR #18631

ADOPTED UPSTREAM · 51 CHECKS GREEN

2db9e37

Immutable Git SHA

TypeScript

Sdk

51 Checks Green

CI & Test Matrix

01 · Engineering problem

The failure mode

Claude Code Task subagents emit events carrying a non-null parent_tool_use_id, which leaked nested subagent token counts, tool calls, and partial stream deltas into parent-step accounting.

02 · Technical response

What changed

  1. 01Filtered subagent-originated assistant, user, tool-result, and partial stream events prior to parent-step normalization in Vercel AI SDK.
  2. 02Added 69 harness assertions verifying parent-step token and tool isolation.

03 · Verified outcome

Evidence-backed result

  • ✓Passed 20/20 Vercel CI checks on commit 2db9e370e66b56e7802b30e7ea359d9dc9e27209 and adopted upstream with explicit credit to @patrickswedish.

04 · Cryptographic Git record

Immutable source evidence

TypeScriptVercel AI SDKClaude CodeAgent HarnessObservability

Independent open-source engineering authored solely by Patrick Ribbsaeter (@patrickswedish). Company and project names identify the public repository context only under nominative fair use. No employment, client, vendor, or partnership relationship is implied unless explicitly stated.