Skip to content

Conversation

@aimbit-ni
Copy link

Summary

  • StreamEndEvent.usage can be null when providers don't include usage data in their final stream chunk, causing a TypeError downstream (e.g. in laravel/ai)
  • Adds ?? new Usage(0, 0) fallback to emitStreamEndEvent() in all 7 providers missing it: Groq, XAI, OpenRouter, Mistral, DeepSeek, Anthropic, and Gemini
  • Matches the existing pattern already used in the OpenAI stream handler

Refs #900

Test plan

  • Full test suite passes (1361 tests, 0 failures)
  • PHPStan level 8 clean
  • Pint + Rector formatted

StreamEndEvent.usage can be null when providers don't include usage
data in their final stream chunk, causing a TypeError downstream.
Add `?? new Usage(0, 0)` fallback to emitStreamEndEvent() in all
providers missing it, matching the existing pattern in the OpenAI
stream handler.
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.

1 participant