Skip to content

AI_APICallError: prompt is too long #1092

Closed

Description

@almirsarajcic

I've asked Claude (opencode v0.3.17, claude-opus-4-20250514) to do some research on the web, and it returned AI_APICallError: prompt is too long error. I can't continue the session. I wasn't able to compact it either.

Image

https://opencode.ai/s/O0iKt5Jt

Related: #164, #500.
Might be related: #491.

Activity

  1. almirsarajcic commented on Jul 17, 2025

    @almirsarajcic
    ContributorAuthor

    After creating this issue, I went back to opencode and just typed something in to see if it's responsive because I got an error after typing /compact. And it gave me this.
    Image

  2. self-assigned this
    on Jul 17, 2025
  3. neocoder commented on Aug 6, 2025

    @neocoder

    @thdxr
    Would not like to create another similar issue, so posting here.
    opencode v0.3.132
    The same error: "AI_APICallError: prompt is too long: 210171 tokens > 200000 maximum"
    What I mentioned, though is the amount of used tokens in the top right corner

    Image

    Does this shed some light on the issue? I keep getting this error a couple of times a day and every time at about 20% of context used ( if that's what the top info means)

  4. taxilian commented on Aug 8, 2025

    @taxilian

    This keeps happening to me as well; it seems to happen most often when it's looking at the output from a command, e.g. after running unit tests.

    Image
  5. kevcube commented on Aug 10, 2025

    @kevcube

    this is often happening to me too.

  6. NotASithLord commented on Aug 23, 2025

    @NotASithLord

    Same here. Asked it to loop through a CSV and download a bunch of files, not a complicated ask and the total files are just ~30 PDFs, so surprised it hit a context limit basically right away.

    Image
  7. NotASithLord commented on Aug 23, 2025

    @NotASithLord

    In my case it's being triggered whenever I try to download even a single PDF.

    Image
  8. blentz commented on Sep 2, 2025

    @blentz

    I'm encountering this error during MCP server use. There doesn't appear to be guardrails on making sure that MCP server queries are properly limited or paged.

    If the underlying MCP server allows the bot to do unrestricted queries for information, the bot can self-sabotage if it attempts to consume the unlimited MCP server output.

  9. andreimarinescu commented on Sep 8, 2025

    @andreimarinescu

    Also seeing this by just asking an agent to use the playwright MCP to do a web scrape. Haven't found a good workaround yet, some MCP server allow setting a token limit.

  10. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Collaborator

    [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