Skip to content

fix(ai): classify Novita context length rejections as context overflow - #52134

Merged
rekram1-node merged 1 commit into
v2from
novita-overflow
Oct 1, 2026
Merged

rekram1-node merged 1 commit into
v2from
novita-overflow

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Problem

Novita rejects an oversized prompt with HTTP 400 and no token counts:

{"message":"The input is longer than the model's context length trace_id: 39d8c3a5c6c91dbc8dd9055f0b37e084","type":"invalid_request_error"}

The existing pattern for this wording required token counts (The input (N tokens) is longer than the model's context length (N tokens)), so it didn't match. It was classified as a plain InvalidRequest, compaction never started, and long sessions failed.

Fix

Make the token counts optional in that existing context-overflow pattern in packages/ai/src/provider-error.ts. The wording with counts still matches.

Verification

  • Live, a 1.3M-token prompt to deepseek/deepseek-v4.1-flash and meta-llama/llama-3.3-70b-instruct now returns 400 InvalidRequest: context-overflow, not retried.
  • New test uses the captured body. The existing test for the counted wording still passes.
  • bun test in packages/ai and bun run check pass.

Not fixed here

qwen/qwen3.8-flash rejects the same prompt with only invalid request error trace_id: ..., which has nothing to classify on.

@rekram1-node
rekram1-node merged commit f0f4c94 into v2 Oct 1, 2026
8 checks passed
@rekram1-node
rekram1-node deleted the novita-overflow branch October 1, 2026 03:40
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