GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — prompt is too long · Issue #5360 · anomalyco/opencode

prompt is too long #5360

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
prompt is too long#5360
Copy link
Assignees
rekram1-node
Labels
bugSomething isn't working

Description

@berenddeboer
berenddeboer
opened on Dec 11, 2025
Issue body actions

Description

Got this twice today:

prompt is too long: 202744 tokens > 200000 maximum

OpenCode version

1.0.143 (I think, version used to be visible all th etime, but no longer)

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04

Terminal

Alacritty/tmux

Reacted by Tyler Marques, Tommy Martin, COGnITO (mode: carbon), Pavel Tcholakov, scarf, mchafik-hoploud and Ratrat

Activity

  1. berenddeboer
    added
    bugSomething isn't working
    on Dec 11, 2025
  2. github-actions
    added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 11, 2025
  3. rekram1-node
    self-assigned this
    on Dec 11, 2025
  4. rekram1-node
    removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 11, 2025
  5. anomalyco
    deleted a comment from opencode-agent on Dec 11, 2025
  6. arsham commented on Dec 11, 2025

    @arsham
    arsham
    on Dec 11, 2025
    More actions

    Was there a tool call just before that? If that was the case, the result of the tool call must have been large. Your only option is to run /undo and then add an additional guidance to the agent to be more careful.

  7. berenddeboer commented on Dec 11, 2025

    @berenddeboer
    berenddeboer
    on Dec 11, 2025
    Author
    More actions

    Yeah, plenty of things going on.

  8. rekram1-node commented on Dec 11, 2025

    @rekram1-node
    rekram1-node
    on Dec 11, 2025
    Member
    More actions

    I'm gonna make it more resilient to these things soon, @arsham nails it w/ suggestion but ofc this isn't really an "acceptable" ux for you guys and that's on us. Will be better soon!

    Reacted by Arsham Shirvani, Michael Vessia, Justin Carlson and Erik James Fritsch
  9. nachose
    marked prompt is too long when replacing in a file. #5478 as a duplicate of this issue on Dec 13, 2025
  10. taxilian commented on Dec 15, 2025

    @taxilian
    taxilian
    on Dec 15, 2025
    More actions

    I haven't seen this much lately, things have been fantastic... but today suddenly it's happened now three times in a row doing different tasks. Did anything change recently?

  11. taxilian commented on Dec 15, 2025

    @taxilian
    taxilian
    on Dec 15, 2025
    More actions

    can't even undo and auto compact, it's failing on the compact message

  12. rekram1-node commented on Dec 15, 2025

    @rekram1-node
    rekram1-node
    on Dec 15, 2025
    Member
    More actions

    @taxilian could u share:

    • what model/provider it happened with
    • the session?

    opencode export > session.json

  13. taxilian commented on Dec 15, 2025

    @taxilian
    taxilian
    on Dec 15, 2025
    More actions

    It just happened again.

    This is with claude opus 4.5, anthropic pro plan.

    • https://opncd.ai/share/b6z1zV7h
    • https://opncd.ai/share/HNLgGiUx

    The other session is in a weird state now because it's the one I tried to fix. This is exactly the same thing I was working on Friday / Saturday though and haven't seen this issue before, now it keeps happening left and right.

  14. taxilian commented on Dec 15, 2025

    @taxilian
    taxilian
    on Dec 15, 2025
    More actions

    session.json
    session2.json

    I think those are the same two

  15. taxilian commented on Dec 15, 2025

    @taxilian
    taxilian
    on Dec 15, 2025
    More actions

    I am on the community discord server if that's useful. still trying to make this work

  16. rekram1-node commented on Dec 16, 2025

    @rekram1-node
    rekram1-node
    on Dec 16, 2025
    Member
    More actions

    It looks like it's because of the "bd" cmd in bash it's absolutely devouring tokens

  17. rekram1-node commented on Dec 16, 2025

    @rekram1-node
    rekram1-node
    on Dec 16, 2025
    Member
    More actions

    I think the proper pty should fix that

  18. ben-vargas commented on Dec 17, 2025

    @ben-vargas
    ben-vargas
    on Dec 17, 2025
    Contributor
    More actions

    Yeah, I'm running into similar error a ton, haven't been able to reliably use opencode for a few versions now. This is on the latest v1.0.164 and there was a firecrawl scrape right before truncation failed to work?

    Image

    Also opus 4.5 (max plan).

  19. justcarlson commented on Dec 19, 2025

    @justcarlson
    justcarlson
    on Dec 19, 2025
    More actions

    session.json

    Also running into this a lot.
    It's definitely large tool calls that are devouring context.
    Probably because of bd (but it's so good).
    Model: Anthropic/Claude Opus 4.5
    If I switch model to Gemini, it's fine (mostly).
    Truncation isn't aggressive enough, I think.

    Cleaned up JSON from my session showing where it all went wrong.

    [
      {
        info: {
          id: msg_b3475413b001geGkBJYoGtUd0o,
          role: assistant,
          modelID: claude-opus-4-5,
          tokens: {
            input: 6,
            output: 10586,
            cache: { read: 68795, write: 12195 }
          },
          finish: tool-calls
        },
        parts: [
          {
            type: reasoning,
            text: Good, test file cleaned up. Now I need to push these commits to the PR and update the PR.
          },
          {
            type: tool,
            tool: bash,
            state: {
              status: completed,
              input: {
                command: git push 2>&1,
                description: Push cleanup commits,
                env: {
                  /* ... [21,965 character-indexed entries truncated] ... */
                  CI: true,
                  DEBIAN_FRONTEND: noninteractive,
                  GIT_TERMINAL_PROMPT: 0,
                  GCM_INTERACTIVE: never,
                  HOMEBREW_NO_AUTO_UPDATE: 1
                }
              },
              output: To https://github.com/justcarlson/dotfiles.git\n   d263a20..f890276  feat/beads-init -> feat/beads-init\n,
              time: {
                start: 1766111786187,
                end: 1766111786842
              }
            }
          }
        ]
      },
      {
        info: {
          id: msg_b3477378e001PSDz7CbpYGme0T,
          role: assistant,
          error: {
            name: APIError,
            data: {
              message: prompt is too long: 212032 tokens > 200000 maximum,
              statusCode: 400,
              responseBody: {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 212032 tokens > 200000 maximum"},"request_id":"req_011CWFGUE8UeR24su49Cs3jB"}
            }
          }
        },
        parts: []
      }
    ]
    ...
  20. ben-vargas commented on Dec 19, 2025

    @ben-vargas
    ben-vargas
    on Dec 19, 2025
    Contributor
    More actions

    I didn't post it here, but I did in a thread on their discord... my root cause (at least for my issue) is non-truncated mcp tool calls dumping too much into the context window. There should be a truncation of mcp and all tools, similar to the 30k limit on bash/internal tools.

    I created a personal fix, but haven't PR'd it because opencode maintainers should probably weigh in on how they want to address this (truncation vs something like claude does - detailed below).

    https://discord.com/channels/1391832426048651334/1450309314337308762

    Image Image

    Claude Code has a unique way of handling really large bash outputs that I noticed... I asked it to explain the approach:

      When a tool result is too large, Claude Code:
    
      1. Persists the full output to a file in the session folder:
      /Users/ben/.claude/projects/.../tool-results/mcp-firecrawl-firecrawl_scrape-1765980251222.txt
      2. Returns a helpful message to the model instead of the raw content:
      Error: result (1,055,387 characters) exceeds maximum allowed tokens.
      Output has been saved to /Users/ben/.claude/projects/.../tool-results/...
      Format: JSON array with schema: [{type: string, text: string}]
      Use offset and limit parameters to read specific portions of the file,
      the Grep tool to search for specific content, and jq to make structured queries.
    
      This is much better than truncation because:
      - Data isn't lost - the full output is preserved
      - Model can explore - using Read (with offset/limit), Grep, or jq
      - Context stays small - only the file path and instructions go into context
    
      Would you like me to update the fix to implement this pattern instead of simple truncation? It would involve:
    
      1. Writing large MCP outputs to .opencode/tool-results/ (or similar)
      2. Returning a message with the file path and exploration instructions
      3. The model can then use existing tools (Read, Grep, Bash with jq) to explore
    
    Reacted by Justin Carlson, Alexei Nunez and Erik James Fritsch
  21. justcarlson commented on Dec 19, 2025

    @justcarlson
    justcarlson
    on Dec 19, 2025
    More actions

    I am loving this idea

  22. CybotTM commented on Dec 19, 2025

    @CybotTM
    CybotTM
    on Dec 19, 2025
    More actions

    Not sure if this #5360 or #1092 or #4845 are all about the same or more specific different issues, so I just post here: me too! ;-)

    Run into this every time on /compact ... sadly, but this makes OpenCode currently unusable for me. :-(

  23. guilllex commented on Dec 24, 2025

    @guilllex
    guilllex
    on Dec 24, 2025
    More actions

    I have the same problem with opencode , claude opus 4.5 and BMAD, I asked the agent to try to fix the probleme

    Done! The session should now work.

     Summary of the Root Cause & Fix                                                                                                                                                                                                  
                                                                                                                                                                                                                                      
     Root Cause: OpenCode stores ALL tool outputs (webfetch, read, write, task results) in the session history. When you fetch large web pages or read large files, they accumulate and                                               
     eventually exceed the 200K token limit.                                                                                                                                                                                          
                                                                                                                                                                                                                                      
     What I Fixed:                                                                                                                                                                                                                    
     - Truncated 20+ large parts in your session                                                                                                                                                                                      
     - Reduced session from ~330KB to ~123KB                                                                                                                                                                                          
     - Estimated tokens: from 200K+ down to ~47K                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                      
     To Prevent This in Future:                                                                                                                                                                                                       
     1. Avoid using webfetch on large documentation pages                                                                                                                                                                             
     2. If you need to read large files, summarize them rather than keeping full content                                                                                                                                              
     3. Consider starting a new session when doing research-heavy work with lots of webfetches                                                                                                                                        
     4. OpenCode should ideally have auto-truncation, but until then, be mindful of large fetches                                                                                                                                     
                                                                                                                                                                                                                                      
     Try your session now! 🚀
    
  24. ben-vargas commented on Dec 27, 2025

    @ben-vargas
    ben-vargas
    on Dec 27, 2025
    Contributor
    More actions

    I ended up creating #6234 for this since I had to patch this in my local fork I use, opencode was pretty unusable for me without it and I couldn't wait for a fix. Not sure if opencode team will accept it, but at least it is shared here so others can merge it onto their own versions if desired.

  25. PeterHa-UoH commented on Dec 30, 2025

    @PeterHa-UoH
    PeterHa-UoH
    on Dec 30, 2025
    More actions

    does anyone find a way to fix this?

  26. Traves-Theberge commented on Dec 31, 2025

    @Traves-Theberge
    Traves-Theberge
    on Dec 31, 2025
    More actions

    Same issue specifically when running up services for docker compose.. and using Claude code. it doesn't condense and summarize properly.

  27. rekram1-node commented on Dec 31, 2025

    @rekram1-node
    rekram1-node
    on Dec 31, 2025
    Member
    More actions

    fixing soon

    Reacted by rob, Sebastian Mendel, SeongwoongCho, Antonio Correa, Joey, Jihoon Kwak, Traves Theberge and luanxu
    Reacted by Justin Carlson
    Reacted by Sebastian Mendel
    Reacted by Justin Carlson
  28. rekram1-node
    closed this as a duplicateof prompt is too long unrecoverable #4845 on Dec 31, 2025
  29. raadkasem commented on Feb 6, 2026

    @raadkasem
    raadkasem
    on Feb 6, 2026
    More actions

    Still getting this issue using opus 4.6 on February 2026

    Reacted by Alexander Grosse, Oscar Morante, Stanislas, Marcel Folaron, dida1990, Evandro Sasse, RiveraHan, Faris Alherf, Susanth Kakarla, Colin Willson and 20 more
  30. MalteBoehm commented on Feb 15, 2026

    @MalteBoehm
    MalteBoehm
    on Feb 15, 2026
    More actions

    me too

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

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.