[KongchangAI]
· 2 min read· 1,029 words

AI SDK xAI 5.0.36 Fix: No More False 'other', Correctly Returns 'length'

AI SDK xAI 5.0.36 Fix: No More False 'other', Correctly Returns 'length'

AI SDK's xAI provider releases 5.0.36 patch, fixing the mapping defect where token truncation was misreported as other.

AI SDK's xAI provider has released the `@ai-sdk/xai@5.0.36` patch, fixing a mapping omission that impacted troubleshooting efficiency: when calling `generateText` in Responses mode, responses truncated due to `max_output_tokens` had their `finish reason` incorrectly reported as the fallback value `other` instead of the semantically correct `length`. The change comes from commit `3d6ac0a`, mapping `incomplete_details.reason` to the unified `finish reason` enum. After the fix, callers' truncation retry and error handling branches can trigger properly, `other` noise in monitoring decreases while `length` counts rise, and output capacity and quality assessments become more accurate. As a patch-level version with changes limited to mapping logic, teams using the Responses interface are advised to upgrade as soon as possible.

A Small but Critical Patch: Token Truncation Is No Longer Misjudged

When building applications that rely on large models, one of the most frustrating problems isn't a lack of model capability—it's errors being silently swallowed. The xAI provider for AI SDK has just released the @ai-sdk/xai@5.0.36 patch version, fixing exactly this kind of easily overlooked issue that impacts troubleshooting efficiency: when a response is truncated due to max_output_tokens, the finish reason is no longer incorrectly reported as other, but correctly mapped to length.

This change comes from commit 3d6ac0a, which maps incomplete_details.reason to finish reason for generateText calls in Responses mode. The release was automated via GitHub Actions, includes 13 commits, and comes with a GitHub verified signature.

rss source: @ai-sdk/xai@5.0.36

What Was the Problem: other Is an Information Black Hole

finish reason is the first-hand signal callers use to determine whether model output is complete. Common values like stop, length, tool-calls, content-filter, etc., each correspond to clear handling paths. But other is essentially a fallback value—it tells you "something is wrong" without telling you "what is wrong."

When a request sets max_output_tokens and the model output is truncated upon reaching the limit, the correct semantics is length. Callers can then decide whether to retry with a higher limit, continue writing in segments, or notify users that content is incomplete. But before the fix, the xAI provider returned other under the Responses path, forcing developers to guess or add extra logging to infer, and automated retry logic couldn't be triggered.

Why It Only Appeared in Responses

The commit message for this fix explicitly points to generateText in Responses mode. AI SDK has adaptation layers for different providers and different API shapes. xAI's Responses interface returns the truncation reason in the incomplete_details.reason field, but the adaptation layer previously didn't translate it into the unified finish reason enum value. This is a typical "upstream field exists, downstream didn't connect" mapping omission.

Semantic Differences Between finish reason and incomplete_details.reason

finish reason is an enum of termination reasons abstracted uniformly across providers by AI SDK, with values like stop, length, tool-calls, content-filter, other, etc., allowing callers to handle outputs from different models with the same logic. incomplete_details.reason, on the other hand, is a field natively returned by xAI's Responses API, a provider-specific expression that may contain more low-level reason strings like max_output_tokens, content_filter, etc. The adaptation layer's job is to establish a many-to-one mapping between the two: translating provider-specific reasons into the SDK's unified enum. When the mapping table misses an entry, the code falls into the other fallback branch—that's exactly what caused this bug. Understanding this relationship helps developers quickly identify mapping gaps rather than model anomalies when similar issues arise with other providers or new interfaces.

Practical Impact on Developers

Error Handling Branches Finally Trigger

If your code has branches like if (finishReason === 'length'), this patch makes them effective. For scenarios prone to hitting token limits—long text generation, code completion, structured output—this means a real logic defect has been fixed, rather than masked by raising the limit.

Improved Observability

The count of other on monitoring dashboards will noticeably decrease, while length counts rise accordingly. This isn't a numbers game—distinguishing "model ended normally" from "model was forcibly truncated" is a fundamental metric for evaluating output quality and capacity. Truncated requests previously categorized as other were just noise in alerts and reports.

Upgrade Recommendation

This is a patch-level version with changes confined to mapping logic and no new API surface introduced. Teams relying on @ai-sdk/xai and using the Responses interface should upgrade as soon as possible; if you're mainly on the Chat Completions path, the impact is relatively limited, but unifying versions is still the safer approach.

Patch Versions and Semantic Versioning (SemVer)

5.0.36 is the patch position in semantic versioning, which by convention should only contain backward-compatible bug fixes and not introduce new APIs or breaking changes. Therefore, upgrade risk is very low—typically just update the dependency and run your existing tests. In contrast, the minor position (e.g., 5.1.0) may add features, and only the major position (e.g., 6.0.0) permits breaking changes. Determining which position a fix falls into is an efficient rule of thumb for judging whether it can be safely adopted. This change is confined to the mapping logic internally, with no changes to function signatures or return structures, consistent with a patch version's positioning—teams can confidently include it in their routine dependency update process.

The Value of Adaptation Layers Seen Through This Fix

The core value of multi-provider AI SDKs lies in smoothing over differences, and the hard part of smoothing is precisely "semantic alignment" rather than "field shuffling." incomplete_details.reason is xAI's expression, finish reason is the SDK's unified abstraction—every missing entry in the mapping table means callers have to write an extra layer of defensive code.

Such patches won't appear in the spotlight of launch events, but they directly determine whether developers see a clear enum value when debugging or find themselves poring over docs staring at other. For teams embedding AI capabilities into production systems, choosing an actively maintained SDK with timely mappings often yields greater long-term benefits than short-term feature richness.

This release also comes with a GitHub verified signature, and supply chain traceability is worth noting—in today's increasingly complex AI toolchains, this kind of basic hygiene is equally important.

One-line Summary

AI SDK's xAI provider releases 5.0.36 patch, fixing the mapping defect where token truncation was misreported as other.

Paragraph Summary

AI SDK's xAI provider has released the @ai-sdk/xai@5.0.36 patch, fixing a mapping omission that impacted troubleshooting efficiency: when calling generateText in Responses mode, responses truncated due to max_output_tokens had their finish reason incorrectly reported as the fallback value other instead of the semantically correct length. The change comes from commit 3d6ac0a, mapping incomplete_details.reason to the unified finish reason enum. After the fix, callers' truncation retry and error handling branches can trigger properly, other noise in monitoring decreases while length counts rise, and output capacity and quality assessments become more accurate. As a patch-level version with changes limited to mapping logic, teams using the Responses interface are advised to upgrade as soon as possible.

#AI SDK#xAI#finish reason#max_output_tokens#Responses API#patch version#semantic versioning
Share:

Related articles