Skip to content

Fetched documentation exeeds context window limit - Automatic truncation possible? #1212

Closed

Description

@WismutHansen

When opencode pulls documentation from websites, the resulting response can sometimes exceed the context length of the current model in use (currently Claude sonnet 4 for me). It's impossible to continue this sessions in this case. Manually editing the sessions logs and removing the content makes it possible to resume the session.

Could we implement a token counter that considers how many tokens are left in a given session and truncates the fetched content to a size that still fits the context window (including a short hint for the model)?

Here is the error message for reference:

AI_APICallError: input length and max_tokens exceed context limit: 184714 + 32000 > 200000, decrease input length or max_tokens and try again

Activity

  1. self-assigned this
    on Jul 22, 2025
  2. isaacraja commented on Jul 25, 2025

    @isaacraja

    I see a similiar error message on retrieving from docs from web. AI_APICallError: input length and max_tokens exceed context limit: 190641 + 32000 > 200000, decrease input length or max_tokens and try again

  3. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

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