fix: stop attaching accumulated reasoning_details to reasoning-delta events (#413) - #477
Merged
robert-j-y merged 1 commit intoApr 15, 2026
Conversation
…events (#413) Previously, each reasoning-delta chunk carried a full snapshot of all accumulatedReasoningDetails in its providerMetadata. For N reasoning chunks, this caused O(N²) total payload size. Changes: - Remove providerMetadata parameter from emitReasoningChunk() - reasoning-delta and reasoning-start events no longer carry metadata - reasoning-end, tool-call, and finish events still carry the full accumulated reasoning_details (unchanged) - Remove unused SharedV3ProviderMetadata import Add regression test with 7 cases including edge cases for single chunk, mixed detail types, and payload size verification. Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
robert-j-y
force-pushed
the
devin/1776216594-fix-413-reasoning-metadata-bloat
branch
from
April 15, 2026 21:17
24318a9 to
2d90052
Compare
robert-j-y
deleted the
devin/1776216594-fix-413-reasoning-metadata-bloat
branch
April 15, 2026 21:44
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #413 — reasoning metadata O(N²) payload bloat.
Problem
Each
reasoning-deltaSSE event carried a full snapshot of allaccumulatedReasoningDetailsin itsproviderMetadata. For N reasoning chunks, total serialized payload grew O(N²) instead of O(N).For example, with 20 reasoning chunks the total payload was 10,537 bytes — well above the 6,000-byte linear threshold (300 bytes × 20 chunks).
Fix
reasoning-startandreasoning-deltaevents no longer carryproviderMetadata. The full accumulatedreasoning_detailsare still available onreasoning-end,tool-call, andfinishevents (unchanged).Before / After
Before: Every
reasoning-deltaincluded a growing snapshot:After: Deltas carry only the text:
Changes
src/chat/index.ts— RemovedproviderMetadataparameter fromemitReasoningChunk, removed snapshot creationsrc/chat/index.test.ts— Updated 3 test expectations to verifyproviderMetadataisundefinedon reasoning-delta/start eventse2e/issues/issue-413-reasoning-metadata-bloat.test.ts— 7 new regression tests.changeset/fix-413-reasoning-metadata-bloat.md— Patch changesetTest Results
pnpm stylecheck: passedpnpm typecheck: passedHuman Review Checklist
providerMetadatafromreasoning-deltaevents are not broken (this was undocumented behavior)reasoning-endandfinishevents still carry the fullreasoning_detailsGenerated by Devin