Repository navigation
fix: Groq usage.raw keeps null fields - #308
Merged
Merged
Conversation
convertGroqUsage (convert-groq-usage.ts:53) returns the usage object as zod parsed it (groq-chat-language-model.ts:564-580): a null field stays null and unknown keys are dropped. aimux re-serialized the typed struct, which dropped null fields, so completion_tokens_details: null or reasoning_tokens: null disappeared from usage.raw. GroqUsage now keeps the parsed object (known keys only) and convert_groq_usage returns it. Test: usage_raw_keeps_null_fields (tests/groq_test.rs). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
cunninghamcard-bit
marked this pull request as ready for review
October 24, 2026 10:14
eric8810
approved these changes
Oct 25, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
Groq usage.raw 保留五个 null 字段并 strip unknown,符合 pinned zod。Approve。
…keeps-null-fields # Conflicts: # CHANGELOG.md
7 of 13 tasks
…keeps-null-fields # Conflicts: # CHANGELOG.md
…keeps-null-fields # Conflicts: # CHANGELOG.md
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
Before: Groq's
usage.rawwas the typedGroqUsagestruct serialized again, so a usage field the API sent asnull(completion_tokens_details: null,prompt_tokens_details.cached_tokens: null,reasoning_tokens: null) disappeared. Generate and stream both.After:
usage.rawis the usage object as parsed, as@ai-sdk/groq4.0.52 returns it (convertGroqUsage→raw: usage): anullstaysnull, keys outside the usage schema are dropped (zodobjectstrips them), and the counts are read as before.Found while porting the upstream Groq tests (#301, cases
convertGroqUsage › should handle null completion_tokens_detailsand› should handle null reasoning_tokens in completion_tokens_details). Part of the #276 list.How it works today
What this PR changes
Tests:
usage_raw_keeps_null_fields(tests/groq_test.rs) sends null details and an extraqueue_timekey and checksusage.raw; it fails on master. The upstream cases are ported in #301.Docs: CHANGELOG
Fixed.Type of change
Checklist
cargo +1.99 fmt -p aimux-providers -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers --lib --test groq_test --test groq_transcription_test --test cassette_full_test --test conformance_testpassesscripts/check_provider_boundaries.shpassesNotes for reviewers
Keys Groq sends outside the usage schema (such as
queue_time) were already dropped before, because the typed struct had no field for them; that stays.Generated by Claude Code