Skip to content

fix(core): strip tool output provider metadata from direct UI stream#1339

Open
liuzemei wants to merge 3 commits into
VoltAgent:mainfrom
liuzemei:fix-ui-stream-tool-provider-metadata-1290
Open

fix(core): strip tool output provider metadata from direct UI stream#1339
liuzemei wants to merge 3 commits into
VoltAgent:mainfrom
liuzemei:fix-ui-stream-tool-provider-metadata-1290

Conversation

@liuzemei

@liuzemei liuzemei commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Closes #1290

Tests

  • pnpm install --frozen-lockfile --ignore-scripts
  • pnpm --dir packages/internal build
  • pnpm --dir packages/core test:single src/agent/agent.spec.ts src/agent/streaming/guardrail-stream.spec.ts
  • pnpm --dir packages/core typecheck
  • pnpm --dir packages/core lint

Summary by cubic

Stop leaking provider metadata to console clients by stripping it from direct UI stream tool output chunks in @voltagent/core. Guardrail and full-stream paths are unchanged for #1195. Closes #1290.

  • Bug Fixes
    • Strip providerMetadata from tool-output-available and tool-output-error in direct result.toUIMessageStream().
    • Preserve UI stream cancellation while transforming the direct stream.
    • Add regression tests, including cancellation coverage, for the direct UI stream path.

Written for commit 8e02def. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Provider metadata is no longer included in direct UI stream tool-output and error chunks sent to console clients.
  • Tests

    • Added unit tests verifying metadata is stripped from tool output chunks and that stream cancellation still propagates correctly.

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e02def

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR strips providerMetadata from tool-output chunks in the non-guardrail UI stream path. Helper functions filter metadata from tool-output-available and tool-output-error chunks before they reach console clients. A test verifies the stripping behavior and a changeset documents the patch release.

Changes

Provider Metadata Stripping for Tool-Output Chunks

Layer / File(s) Summary
Provider metadata stripping implementation and test
packages/core/src/agent/agent.ts, packages/core/src/agent/agent.spec.ts, .changeset/cold-socks-listen.md
Helper functions stripProviderMetadataFromToolOutputChunk and stripProviderMetadataFromDirectUIStream remove providerMetadata from tool-output-available and tool-output-error chunks when guardrail pipeline is absent. Unit test validates that providerMetadata is stripped from tool-output chunks but preserved on tool-input-available and text-delta chunks. Changeset documents the behavior change for patch release.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • VoltAgent/voltagent#1202: Both PRs address providerMetadata handling on UI stream tool-output chunks; #1202 forwards metadata in the guardrail pipeline path, while this PR strips it in the non-guardrail "direct" path to prevent console client validation errors.

Suggested reviewers

  • omeraplak

Poem

🐰 Metadata whispers through the tool-output stream,
But browsers don't speak that tongued dream,
So we strip it clean on the direct path,
Leaving only the truth in its aftermath,
Console clients smile, no validation thrash!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description includes a clear summary, testing instructions, and links to the related issue #1290, but lacks explicit sections matching the template structure. Consider reorganizing the description to explicitly follow the template sections: 'What is the current behavior?' and 'What is the new behavior?' would clarify the problem and solution.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: stripping tool output provider metadata from the direct UI stream path.
Linked Issues check ✅ Passed The code changes fully address the root cause described in #1290: provider metadata is stripped from tool-output-available and tool-output-error chunks in the direct UI stream path via TransformStream pipeline.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing #1290: modifying agent.ts to sanitize the direct UI stream, adding test coverage in agent.spec.ts, and creating a changeset entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/core/src/agent/agent.ts
@liuzemei

Copy link
Copy Markdown
Author

Addressed the cancellation feedback in the latest commits: the direct UI stream sanitizer now uses a TransformStream pipeline so cancellation propagates to the source stream, and there is a regression test covering reader.cancel().

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.

[BUG] tool-output-available TypeValidationError with Anthropic SDK — toUIMessageStream() path not covered by PR #1202

2 participants