Skip to content

fix(experimental llm pkg): forward topK to Converse via additionalModelRequestFields#33030

Merged
rekram1-node merged 1 commit into
anomalyco:devfrom
kimnamu:bedrock-converse-topk
Jun 20, 2026
Merged

fix(experimental llm pkg): forward topK to Converse via additionalModelRequestFields#33030
rekram1-node merged 1 commit into
anomalyco:devfrom
kimnamu:bedrock-converse-topk

Conversation

@kimnamu

@kimnamu kimnamu commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #33003

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The Bedrock Converse path silently drops the topK generation option. fromRequest in packages/llm/src/protocols/bedrock-converse.ts builds inferenceConfig from only maxTokens/temperature/topP/stopSequences, and never reads generation.topK.

The sibling Anthropic path already handles it (anthropic-messages.ts: top_k: generation?.topK), so the same model setting behaves differently depending on which protocol is used. The fix routes topK through additionalModelRequestFields as top_k. That is exactly where the AWS Converse API expects model-specific params that aren't part of the base InferenceConfiguration — the Converse API reference shows {"additionalModelRequestFields": {"top_k": 200}} for Anthropic models. The Converse body schema in this file already declares additionalModelRequestFields, so nothing new is introduced — this fills a gap in the existing mapping.

How did you verify your code works?

From packages/llm:

  • Added two tests in test/provider/bedrock-converse.test.ts: one asserting topK lands in additionalModelRequestFields: { top_k }, one asserting the field is omitted when topK is unset. Reverting the one-line fix makes the first test fail (Expected { top_k: 40 }, received none), confirming the test catches the bug.
  • bun test test/provider/bedrock-converse.test.ts → 28 pass; bun typecheck, oxlint, prettier --check all clean.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

AI-assisted (Claude Code); changes, rationale, and tests reviewed by a human before submission.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rekram1-node rekram1-node changed the title fix(bedrock): forward topK to Converse via additionalModelRequestFields fix(experimental llm pkg): forward topK to Converse via additionalModelRequestFields Jun 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title fix(experimental llm pkg): forward topK to Converse via additionalModelRequestFields doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@rekram1-node rekram1-node merged commit 2d993cd into anomalyco:dev Jun 20, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock Converse ignores topK / top_k generation option

2 participants