fix(llm): forward bedrock.thinking provider option to Bedrock Converse#33631
Open
Robin1987China wants to merge 2 commits into
Open
fix(llm): forward bedrock.thinking provider option to Bedrock Converse#33631Robin1987China wants to merge 2 commits into
Robin1987China wants to merge 2 commits into
Conversation
select() partitions the conversation into head (summarized) and recent (kept) at a token budget. When the boundary lands mid-message, that message is split into splitPrefix (head) and splitSuffix (recent). The split branch set split = index + 1 and reused it for both head's slice end and recent's slice start, so head = slice(0, index + 1) included the full boundary message AND splitPrefix (a truncated copy) — duplicating it. head is the exact text fed to the summarizer, so on every overflow-triggered compaction where the boundary lands mid-message the boundary message was sent twice (full + truncated), wasting tokens and risking pushing the summary prompt past the context limit so compaction silently fails. Track two boundaries: headEnd (end of head's full-message slice) and recentStart (start of recent's slice). They differ only in the split case (headEnd = index, recentStart = index + 1); all other paths keep them equal, preserving existing behavior. Export select and add a regression test for the duplication plus a fully-fitting sanity case. Closes anomalyco#33329
…e additionalModelRequestFields
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.
Issue for this PR
Closes #33634
Type of change
What does this PR do?
The Bedrock Converse route already parses extended-thinking/reasoning from Bedrock responses, but has no way to request it. This adds
providerOptions.bedrock.thinkingsupport, following the existing AnthropicproviderOptions.anthropic.thinkingpattern. The thinking config is lowered intoadditionalModelRequestFields.thinkingwithbudget_tokens(snake_case per the Bedrock Converse API).How did you verify your code works?
bun typecheckin packages/llm passesbun test test/provider/bedrock-converse.test.ts— 31 tests pass (3 new: thinking alone, thinking + topK, rejects missing budgetTokens)Checklist