Vercel's AI SDK, specifically the @ai-sdk/openai-compatible package, received an update to version 3.0.28 on August 9.
This patch addresses a specific scenario in which a provider might report completion_tokens_details.reasoning_tokens as greater than completion_tokens. This situation was observed with Baseten when serving reasoning models that reached a length stop during the reasoning phase.
Key Points
- The @ai-sdk/openai-compatible package was updated to version 3.0.28.
- The release occurred on August 9.
- The update fixes an issue where
outputTokens.textcould be negative. - This occurs when
completion_tokens_details.reasoning_tokensexceedscompletion_tokens. - The fix clamps
outputTokens.textat0. - Baseten serving reasoning models was identified as a context where this issue appeared.
- Total and reasoning token counts remain as reported by the provider.
Context
According to Vercel, the patch ensures that the text share of completion tokens is never reported as a negative value. The issue arose when certain providers, such as Baseten, reported reasoning_tokens that surpassed the completion_tokens total, particularly when models hit a length stop mid-reasoning.
Why It Matters
This update ensures consistent and accurate token reporting within the Vercel AI SDK, preventing potential miscalculations or errors in applications that rely on precise token usage metrics. Builders can expect more robust handling of token details, especially when integrating with diverse reasoning models.
What To Do
- Developers using the Vercel AI SDK should update their @ai-sdk/openai-compatible package to version 3.0.28.
- Review applications that process
outputTokens.textto ensure they account for the new clamping behavior. - Note that total and reasoning token counts are still reported directly from the provider.
- If using Baseten or similar reasoning model providers, observe how this patch affects token reporting in your specific use cases.
