fix(agent): emit a reasoning start when a v2 delta finds no span open - #3481
Merged
Merged
Conversation
On the v2 stream-lifecycle path, a reasoning_content with no span open minted a span id via continueReasoning() but emitted only Content, so consumers got content for a messageId they never saw start and drop it. browser-encoder already synthesizes the missing start; v2 now matches. Closes veryfront/veryfront-issue-inbox#408
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe lifecycle adapter now opens a reasoning span when content arrives without an active span. Tests verify the start, content, and end events and the stable generated message ID. ChangesReasoning lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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.
Closes veryfront/veryfront-issue-inbox#408.
Bug
On the v2 stream-lifecycle path (
VF_STREAM_LIFECYCLE_MODE), areasoning_contentarriving with no span open mints a span id but emits only Content:No
ReasoningMessageStartis ever emitted for that id. Per veryfront/veryfront-issue-inbox#152, the API canonicalizer and Studio stream decoder key strictly on the reasoning lifecycle, so content whose start never arrived is dropped — silently missing reasoning text.browser-encoder.ts(v1) already synthesizes the missing start. This makes v2 match.Fix
One case in
lifecycle-browser-adapter.ts: emit the start first when a delta finds no span open. No other paths touched.Tests
One test,
opens a reasoning span visibly when a delta arrives with none open, asserting the fullStart → Content → Endsequence on one id. Confirmed red before the fix, green after.src/agent/ag-ui/29 passed / 158 steps.deno check/fmt/lint/ docs check clean.Note
Needs a provider that emits reasoning content without a preceding start; I have not confirmed one does. This fixes a real v1/v2 divergence, not a proven live incident.
Summary by CodeRabbit
Bug Fixes
Tests