Skip to content

it keeps failing mid talking #44823

Closed as not planned
Closed as not planned

Description

@Janamostafa-star

Error from provider (Console): Upstream request failed: [1261] Prompt exceeds max length

Activity

  1. github-actions commented on Aug 25, 2026

    @github-actions
    Contributor

    This issue does not follow our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request, or Question.
    • The title ("it keeps failing mid talking") is not descriptive enough.
    • There is no description, reproduction steps, environment info, or OpenCode version — just an error message.

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


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

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

  2. github-actions commented on Aug 25, 2026

    @github-actions
    Contributor

    This issue 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 issue that follows our issue templates.

  3. Suixinlei commented on Oct 3, 2026

    @Suixinlei

    I can provide a complete reproduction from our OpenCode v2 Sandbox integration.

    Environment:

    • OpenCode version: 1.18.29
    • OpenCode source commit: 1674747
    • Model: glm-5.3-flash
    • OpenCode provider: lovrabet-openai
    • API endpoint: /v1/chat/completions
    • Provider path: OpenCode → AI Gateway → Sub2API OpenAI group → Zhipu/GLM

    Reproduction:

    1. Start a long-lived OpenCode v2 session in the Sandbox.
    2. Continue the same session through multiple tool calls, file reads, and edits so that the assembled chat request becomes large.
    3. Send another prompt using glm-5.3-flash.
    4. The request is forwarded through AI Gateway and Sub2API to the Zhipu GLM upstream.

    The upstream returns HTTP 400 with this response body:

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

    Sub2API preserves the upstream error message. AI Gateway also preserves this HTTP 400 response because its provider-error normalization only rewrites 499/5xx responses, and its existing input-length normalization only handles Responses API requests with an input field.

    OpenCode then receives the exact message “Prompt exceeds max length”. The current context-overflow matcher recognizes messages such as “prompt is too long”, “request_too_large”, and “input is too long for requested model”, but not this Zhipu error message. The failure is therefore treated as a generic provider error, and the existing context-overflow recovery path is not entered.

    Expected behavior:

    An HTTP 400 response with provider error code 1261 and message “Prompt exceeds max length” should be classified as a context-overflow failure. OpenCode should invoke its existing compaction/recovery behavior, or report a specific context-overflow error if recovery is not possible.

    Proposed focused fix:

    • recognize Prompt exceeds max length and Prompt exceeds maximum length in the shared provider error classifier;
    • keep the match case-insensitive;
    • add regression tests for the HTTP 400 invalid_request_error shape;
    • ensure unrelated errors such as max_tokens exceeds max length, ordinary bad requests, and HTTP 429 rate-limit responses are not classified as context overflow.

    This is a provider-independent change in OpenCode’s LLM error classification. It does not require changes to AI Gateway or Sub2API.

    I can submit a small PR containing only this classifier change and its regression tests if this behavior is in scope for the current dev branch.

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