Skip to content

fix(ai): classify Amazon Nova input token rejections as context overflow - #52131

Merged
rekram1-node merged 1 commit into
v2from
bedrock-nova-overflow
Sep 30, 2026
Merged

rekram1-node merged 1 commit into
v2from
bedrock-nova-overflow

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Problem

Amazon Nova on Bedrock rejects an oversized prompt with a mid-stream validationException after HTTP 200:

The model returned the following errors: Input Tokens Exceeded: Number of input tokens exceeds maximum length. Please update the input to try again.

No overflow pattern matched, so it was classified as a plain InvalidRequest. Compaction never started, and long Nova sessions failed.

Fix

Add number of input tokens exceeds maximum length to the context-overflow patterns in packages/ai/src/provider-error.ts. The Bedrock Converse stream already passes the exception message to the shared classifier.

Verification

  • Live, a 1.3M-token prompt to us.amazon.nova-2-lite-v1:0 and us.amazon.nova-pro-v1:0 now returns InvalidRequest: context-overflow, not retried.
  • New test uses the captured exception event.
  • bun test in packages/ai and bun run check pass.

@rekram1-node
rekram1-node merged commit 599bdc9 into v2 Sep 30, 2026
8 checks passed
@rekram1-node
rekram1-node deleted the bedrock-nova-overflow branch September 30, 2026 16:13
Ichinose-Kazuki pushed a commit to Ichinose-Kazuki/opencode that referenced this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant