Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
mapStopReasonmapsmodel_context_window_exceededtofinishReason: 'length'. It was'unknown'.@anthropic-ai/sdkfrom^0.110.0to^0.114.0. 0.114.0 is the first version whoseStopReasontype includes the value, so the mapping needs no hand-written union or beta type.Why
On Claude 4.5 and newer, the API accepts requests where input plus
max_tokensexceeds the context window. If generation reaches the window limit, it stops withmodel_context_window_exceeded. Anthropic's docs say to treat that response as truncated.#211 makes this stop reason routine: an omitted
maxTokensbecomes the model ceiling, so a long prompt on a 200K model (Haiku 4.5, Sonnet 4.5, Opus 4.5) no longer ends withmax_tokens. With'unknown':finishReason === 'length'miss the truncationgenerateObject()skips its truncation error and throwsStructuredOutputParseErroron the cut-off JSONThe fix is independent of #211 and applies to
mainas is. It was split out of #211 so that PR can release first.Notes
package-lock.jsonalso picks up the workspace package versions (0.25.0 → 0.28.1), which were stale in the lockfile.Test plan
npm run release:checknpm run testmodel_context_window_exceededfinishes with'length'🤖 Generated with Claude Code