Skip to content

fix(core): propagate resolved output limit into model request generation - #46601

Closed
clopca wants to merge 1 commit into
anomalyco:v2from
clopca:bedrock-output-limit
Closed

clopca wants to merge 1 commit into
anomalyco:v2from
clopca:bedrock-output-limit

Conversation

@clopca

@clopca clopca commented Sep 1, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #46595

Type of change

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

What does this PR do?

The prepared model request dropped generation entirely unless a hook or context set one, so a model's configured limit.output never reached the provider. On Bedrock the Converse request went out without inferenceConfig.maxTokens, the service applied a much lower implicit budget, and with adaptive thinking enabled the whole budget could be consumed by reasoning — truncating turns at 4096 output tokens despite limit.output: 128000.

This projects maxTokens into the request with explicit precedence: hook/context override → model defaults → route defaults → resolved.limit.output. The Bedrock protocol already serializes generation.maxTokens as inferenceConfig.maxTokens; it just never received a value.

How did you verify your code works?

  • Regression tests for the precedence chain in session-model-request.test.ts; updated two existing expectations that asserted generation was undefined.
  • Full packages/core suite green (4,104 tests; one unrelated SubagentTool timeout passes in isolation).
  • Live against Bedrock with a private build: wire capture via http.request hook now shows "inferenceConfig":{"maxTokens":128000}, and previously-truncating sessions respond normally.

Screenshots / recordings

Captured request before the fix (sanitized): no inferenceConfig key. After:

{"modelId":"global.anthropic.claude-fable-5","inferenceConfig":{"maxTokens":128000},"additionalModelRequestFields":{"thinking":{"type":"adaptive","display":"summarized"},"output_config":{"effort":"xhigh"}}}

The prepared model request only carried generation values set by hooks or
context, so a model's configured limit.output never reached the provider.
On Bedrock the request was sent without inferenceConfig.maxTokens and the
service applied a much lower implicit budget; with adaptive thinking the
whole budget could be consumed by reasoning, truncating responses at
4,096 tokens despite limit.output=128000.

Project maxTokens with explicit precedence: hook/context override, model
defaults, route defaults, then resolved.limit.output.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 1, 2026
@github-actions github-actions Bot closed this Sep 1, 2026
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.

1 participant