Skip to content

fix(ai): recognize more context overflow errors - #57982

Merged
rekram1-node merged 1 commit into
devfrom
context-overflow-patterns
Oct 22, 2026
Merged

rekram1-node merged 1 commit into
devfrom
context-overflow-patterns

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

A few providers word their "context too long" errors in ways the overflow classifier doesn't match yet. When that happens the error isn't recognized as too long, so instead of compacting and retrying, the session just fails and stays stuck until you compact by hand.

This adds the three wordings I could confirm from real reports:

Message Provider
Prompt exceeds max length Z.ai / Zhipu error code 1261 (China endpoint, the international one already says Prompt too long)
The input is too long for the selected model. Custom endpoint from #57412
This text request is too large for the model's configured input limit. OpenCode Go gateway

The patterns stay specific to each message, so nothing generic like "too long" or "input limit" gets swept in.

Fixes #57412
Related: #50574, #56296, #56454


Added by the opencode bot (AI-generated).

Fixes #56296

Related: #50574, #50761

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I ran isContextOverflow on both checkouts with the three real payloads (the Z.ai 1261 JSON body, the custom-endpoint message and the Go gateway's 400 [unsupported_request] …configured input limit.). All three are unrecognized on the base and classified as context overflow with this change. An unrelated unsupported_request (image input) error stays unclassified. provider-error.test.ts passes (37 tests) and the packages/ai typecheck passes. I didn't run a full compact-and-retry session because the simulated model can't return these provider errors.

Public API is unchanged: only internal error-classification patterns change.

No concerns: the patterns are narrow and specific to each message.

Fixes #56296
Related: #50574, #50761

@rekram1-node
rekram1-node merged commit 09a1db3 into dev Oct 22, 2026
24 checks passed
@rekram1-node
rekram1-node deleted the context-overflow-patterns branch October 22, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant