Skip to content

[Bug] Classify provider error 1261 as context overflow #52961

Closed as not planned
Closed as not planned

Description

@Suixinlei

Description

In our OpenCode Sandbox integration, a long-running session can fail when the accumulated prompt becomes too large for the Zhipu Coding Plan GLM model. The provider returns HTTP 400 with this response:

{"error":{"code":"1261","message":"Prompt exceeds max length"}}

OpenCode receives the message Prompt exceeds max length, but the latest provider error classifier still has no matching rule for it. The response is therefore treated as a generic provider error instead of a context-overflow error, and the existing compaction/recovery path is not entered.

I checked the latest public release, v1.18.34: packages/llm/src/provider-error.ts still has no Prompt exceeds max length match.

Plugins

None.

OpenCode version

v1.18.34 (source commit aec0b9a6d8898f68f923aaf08b7306d931fd9d76)

Steps to reproduce

  1. Start a long-lived OpenCode session using glm-5.3-flash through the Zhipu Coding Plan provider.
  2. Continue the same session through multiple tool calls, file reads, and edits so the assembled chat request grows large.
  3. Send another prompt.
  4. The provider responds with HTTP 400, error code 1261, and message Prompt exceeds max length.
  5. OpenCode reports the provider error without entering its context-overflow compaction/recovery path.

Expected behavior

An HTTP 400 provider error with message Prompt exceeds max length (or Prompt exceeds maximum length) should be classified as a context-overflow failure so OpenCode can use its existing compaction/recovery behavior, or report a specific context-overflow error when recovery is not possible.

Proposed scope

This appears to be a focused change to the shared provider error classifier, with regression coverage for the HTTP 400 invalid_request_error shape and negative cases such as max_tokens exceeds max length, ordinary bad requests, and HTTP 429 rate limits. I can prepare a small PR for this classifier change if the direction is in scope.

Operating System

Linux x64 Sandbox image

Terminal

Sandbox API integration

Activity

  1. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #44823: Reports the same GLM/Zhipu error ([1261] Prompt exceeds max length) and missing context-overflow recovery; the author later added a matching reproduction.
    • #50574: Reports oversized-context HTTP 400 errors not being classified as context overflow, preventing compaction and retry.
    • #35918: Earlier report that GLM and other non-OpenAI context-overflow messages are not detected by the classifier.
  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions