debug(streaming): add logging for AI SDK v5 lifecycle events#858
Open
vdimarco wants to merge 1 commit into
Open
debug(streaming): add logging for AI SDK v5 lifecycle events#858vdimarco wants to merge 1 commit into
vdimarco wants to merge 1 commit into
Conversation
Add detailed logging for AI SDK v5 fullStream lifecycle events (start, start-step, finish-step, raw) to help diagnose empty response issues where models return lifecycle events but no text-delta content. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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
start,start-step,finish-step,raw)text-deltacontentProblem
When GPT-4o (and potentially other models) return empty responses, the error message shows "Part types received: start, start-step, finish-step, finish" but no actual content. This makes it difficult to diagnose why the model isn't generating text.
Changes
start,start-step, andfinish-steplifecycle events with their full contentrawprovider responses for debuggingfinishevent details including usage informationRelated
This helps investigate issues where models like
openai/gpt-4oreturn no content despite receiving valid requests.🤖 Generated with Claude Code
Greptile Summary
This PR adds detailed logging for AI SDK v5
fullStreamlifecycle events to help diagnose empty response issues where models return lifecycle events but no actual content.Changes:
start,start-step, andfinish-steplifecycle events with full content (truncated to 300 chars)rawprovider responses (truncated to 500 chars)finishevent details includingfinishReason,contentReceivedflag, and usage informationImpact:
[AI SDK Route]prefix and truncating long content)openai/gpt-4oreturn empty responses despite receiving valid requestsConfidence Score: 5/5
console.logstatements, and follow existing logging patterns in the codebase. The logging will help diagnose empty response issues as described in the PR description.Important Files Changed
start,start-step,finish-step,raw,finish) to debug empty response issues - no functional changes, logging onlySequence Diagram
sequenceDiagram participant Client participant Route as AI SDK Route participant AISDK as AI SDK v5 participant Backend as Gatewayz Backend Client->>Route: POST /api/chat/ai-sdk-completions Note over Route: Validate request Note over Route: Convert messages format Route->>AISDK: streamText(model, messages) AISDK->>Backend: Stream request loop Stream lifecycle Backend->>AISDK: start event AISDK->>Route: part.type = 'start' Note over Route: Log lifecycle event Backend->>AISDK: start-step event AISDK->>Route: part.type = 'start-step' Note over Route: Log lifecycle event Backend->>AISDK: text-delta AISDK->>Route: part.type = 'text-delta' Route->>Client: SSE: content chunk Backend->>AISDK: raw response AISDK->>Route: part.type = 'raw' Note over Route: Log raw response Backend->>AISDK: finish-step event AISDK->>Route: part.type = 'finish-step' Note over Route: Log lifecycle event Backend->>AISDK: finish event AISDK->>Route: part.type = 'finish' Note over Route: Log finish details (usage) Route->>Client: SSE: [DONE] end