Skip to content

fix(harness-claude-code): exclude subagent messages from parent step usage and tool-call tracking - #18740

Merged
felixarntz merged 2 commits into
mainfrom
fa/18631-clone
Aug 11, 2026
Merged

fix(harness-claude-code): exclude subagent messages from parent step usage and tool-call tracking#18740
felixarntz merged 2 commits into
mainfrom
fa/18631-clone

Conversation

@felixarntz

Copy link
Copy Markdown
Collaborator

Same as #18631 - that PR lacked verified commits. Credit goes to @patrickswedish.

Background

Claude Code emits messages from Task-tool subagents with a non-null parent_tool_use_id.

The harness currently processes those messages as though they belong to the parent agent step. This causes subagent > activity to affect the parent step's usage accounting and exposes subagent tool calls/results as parent-step events.

The issue has been reproduced against the current harness behavior with a captured Claude Code stream.

Summary

This PR keeps the change narrowly scoped:

  • ignore assistant messages associated with a subagent when tracking the parent step
  • ignore corresponding subagent user/tool-result messages
  • preserve normal parent-agent usage and tool-call handling
  • add regression coverage using a representative subagent stream fixture
  • add a patch changeset for @ai-sdk/harness-claude-code

No public API or normal main-agent behavior is changed.

Verification

The regression covers a stream where subagent messages contain a non-null parent_tool_use_id.

It verifies that:

  • the parent step retains its own token usage
  • subagent tool calls are not emitted as parent-step tool calls
  • subagent tool results are not emitted as parent-step tool results

Validation on the final branch:

  • TypeScript — passed
  • Lint & Format — passed
  • Build Packages — passed
  • AI test matrix on Node 22, 24, and 26 — passed
  • Codemod test matrix — passed
  • Example builds — passed
  • Changeset verification — passed

Related Issues

Fixes #18618.

Closes #18619.

@felixarntz
felixarntz merged commit f133c4c into main Aug 11, 2026
52 checks passed
@felixarntz
felixarntz deleted the fa/18631-clone branch August 11, 2026 22:33
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.62 github npm
@ai-sdk/amazon-bedrock 5.0.54 github npm
@ai-sdk/angular 3.0.62 github npm
@ai-sdk/azure 4.0.41 github npm
@ai-sdk/code-mode 1.0.19 github npm
@ai-sdk/gmicloud 3.0.1 github npm
@ai-sdk/harness 1.0.68 github npm
@ai-sdk/harness-acp 1.0.5 github npm
@ai-sdk/harness-claude-code 1.0.70 github npm
@ai-sdk/harness-codex 1.0.70 github npm
@ai-sdk/harness-deepagents 1.0.67 github npm
@ai-sdk/harness-grok-build 1.0.4 github npm
@ai-sdk/harness-opencode 1.0.69 github npm
@ai-sdk/harness-pi 1.0.69 github npm
@ai-sdk/langchain 3.0.62 github npm
@ai-sdk/llamaindex 3.0.62 github npm
@ai-sdk/openai 4.0.40 github npm
@ai-sdk/otel 1.0.62 github npm
@ai-sdk/policy-opa 1.0.62 github npm
@ai-sdk/react 4.0.65 github npm
@ai-sdk/rsc 3.0.62 github npm
@ai-sdk/sandbox-just-bash 1.0.68 github npm
@ai-sdk/sandbox-vercel 1.0.68 github npm
@ai-sdk/svelte 5.0.62 github npm
@ai-sdk/tui 1.0.63 github npm
@ai-sdk/vue 4.0.62 github npm
@ai-sdk/workflow 1.0.62 github npm
@ai-sdk/workflow-harness 1.0.68 github npm
@ai-sdk/xai 4.0.36 github npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

harness-claude-code: subagent (Task-tool) messages aren't excluded from step usage/tool-call tracking

2 participants