Skip to content

prompt is too long unrecoverable #4845

Closed as not planned
Closed as not planned

Description

Description

Opencode with Opus 4.5 often gives me prompt is too long: 209549 tokens > 200000 maximum. This is completely unrecoverable, short of rolling back the session or forking and you then need to compact or something.

Note I'm only at: 121,480 61% ($5.62)

OpenCode version

1.0.119

Steps to reproduce

Use Antropic api key with Opus 4.5, trigger a huge search for example in the primary agent.

Screenshot and/or share link

No response

Operating System

macos

Terminal

ghostty

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 27, 2025
  2. github-actions commented on Nov 27, 2025

    @github-actions
    Contributor

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

    All these issues share the same core problem: context window overflow leading to unrecoverable sessions. Feel free to ignore if your case has specific differences!

  3. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  4. self-assigned this
    on Dec 2, 2025
  5. menoatree commented on Dec 12, 2025

    @menoatree

    I had this happen today aswell when the main agent tried to webfetch the openrouter model list

    % WebFetch https://openrouter.ai/api/v1/models
    prompt is too long: 206917 tokens > 200000 maximum
    
  6. Nindaleth commented on Dec 18, 2025

    @Nindaleth
    Contributor

    @menoatree That URL returns over 450 kB of data for me, that must be around 100,000 tokens of context.

  7. ben-vargas commented on Dec 19, 2025

    @ben-vargas
    Contributor

    Yeah, see that #5360 issue where i added comments, there are tool calls like webfetch and mcp tools that are not truncated and if the source being webfetched or mcp tool scraped with something like firecrawl, it can easily cause the context window to be exceeded which results in this error with opus 4.5.

  8. thdxr commented on Dec 30, 2025

    @thdxr
    Member

    will be fixing this next week

  9. marked prompt is too long #5360 as a duplicate of this issue on Dec 31, 2025
  10. PeterHa-UoH commented on Jan 6, 2026

    @PeterHa-UoH

    will be fixing this next week

    has it been fixed yet/

  11. Nindaleth commented on Jan 6, 2026

    @Nindaleth
    Contributor

    @PeterHa-UoH

    rekram1-node closed this as completed in #6480 5 days ago

    I would say yes, but feel free to try it on your own

  12. 12 remaining items

  13. miguelangelmorenochacon commented on Feb 10, 2026

    @miguelangelmorenochacon

    Happening with Opus 4.6

  14. ashaychangwani commented on Feb 11, 2026

    @ashaychangwani

    Can we please reopen this issue? A lot of people are reporting the same in #5360

  15. rekram1-node commented on Feb 11, 2026

    @rekram1-node
    Collaborator

    I found some places we had issues, fixing

  16. daheli commented on Feb 13, 2026

    @daheli
  17. smashah commented on Feb 14, 2026

    @smashah

    The whole payload seems to be filled with tool definitions

  18. ogyr commented on Feb 14, 2026

    @ogyr

    Same problem here with opus 4.6
    /compact fails as well. I could live with a simple "How much of the oldest content do you want to trim? In k tokens"

  19. iamtekeste commented on Feb 15, 2026

    @iamtekeste

    Is there a workaround in the meantime?

  20. ogyr commented on Feb 15, 2026

    @ogyr

    I created https://github.com/ogyr/opencode-cullto today as a workaround. It lets you cull your current session (or select one) to a specified token limit. Works from within opencode when the session is still responsive, or as a standalone CLI that lists all sessions to choose from, then reopens opencode with the culled session. Works well enough for my use case.

  21. drchopinfrederic commented on Feb 19, 2026

    @drchopinfrederic

    In my cases, I switch the model to GLM5-Free (or another model with a large context windows) and compact session multiple times. ( I did until it’s under 10K tokens.) I lost a detail of the context little bit, but at least I can recover the session from the deadlock, and can use the Anthropic opus model again.
    Still, it need to be fix. it seems this happens when I switch to a model whose context window is smaller than the current session's token count. Trimming might sliced out the the middle of the session data, There should be a exception handling on the compacting sequence.

  22. zulufoxtrot commented on Mar 23, 2026

    @zulufoxtrot

    I'm having the same problem.

    Model: Qwen3.5 122B A10B 6bit. Default context window.
    Backend: oMLX
    Frontend: Opencode GUI 1.2.26 (note: Opencode CLI not installed)
    Tool calls / MCPs: default
    I did not switch models / agents during the session.

  23. removed
    bugSomething isn't working
    on May 3, 2026
  24. dlasher commented on May 20, 2026

    @dlasher

    Seeing this as well, doesn't seem to depend on the model, breaks a bit over 300k in size.

  25. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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