Skip to content

Bedrock Converse ignores topK / top_k generation option #33003

@kimnamu

Description

@kimnamu

Description

When using an Amazon Bedrock model through the Converse protocol, the topK generation option is silently dropped. fromRequest in packages/llm/src/protocols/bedrock-converse.ts builds inferenceConfig from maxTokens/temperature/topP/stop only, and never reads generation.topK. The Anthropic Messages protocol (anthropic-messages.ts) does map it (top_k: generation?.topK), so the two paths diverge.

Per the AWS Converse API reference, top_k is not part of inferenceConfig and must be passed via additionalModelRequestFields (e.g. { "top_k": 200 }). The Converse body schema already declares that field, it's just never populated.

Steps to reproduce

  1. Build a request for a Bedrock model with generation: { topK: 40 }.
  2. LLMClient.prepare(request).
  3. prepared.body contains no top_k anywhere (neither inferenceConfig nor additionalModelRequestFields), so the value is dropped before the request is signed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions