AI_APICallError: prompt token count exceeds limit after updating to v0.14.6 #2020

Closed
opened 2026-02-16 17:33:46 -05:00 by yindo · 11 comments
Owner

Originally created by @nuson999 on GitHub (Oct 9, 2025).

Originally assigned to: @thdxr on GitHub.

Description:
After updating OpenCode to v0.14.6, I encountered an API call error related to token limits when using it alongside GitHub Copilot Pro. In previous versions, OpenCode automatically compacted the prompt data before sending API requests, but this functionality seems broken in the latest release.

Environment:

  • OpenCode version: v0.14.6
  • GitHub Copilot Pro: active subscription
  • OS: Windows 11
  • Model: Claude Sonnet 4.5 (Preview)

Error Message:

AI_APICallError: prompt token count of 135099 exceeds the limit of 128000

Expected Behavior:
OpenCode should automatically apply the compact or truncation function to reduce token usage, allowing the AI call to proceed without exceeding the limit (as it did in previous versions).

Actual Behavior:
After upgrading, OpenCode no longer compacts the prompt data, causing AI requests with large contexts to fail immediately with the above error.

Steps to Reproduce:

  1. Update to OpenCode v0.14.6
  2. Run a project or command that generates long context input for AI processing
  3. Observe the token limit error

Proposed Fix / Suggestion:

  • Reintroduce or patch the compacting logic before sending API requests.
Originally created by @nuson999 on GitHub (Oct 9, 2025). Originally assigned to: @thdxr on GitHub. **Description:** After updating OpenCode to **v0.14.6**, I encountered an API call error related to token limits when using it alongside **GitHub Copilot Pro**. In previous versions, OpenCode automatically compacted the prompt data before sending API requests, but this functionality seems broken in the latest release. **Environment:** - OpenCode version: v0.14.6 - GitHub Copilot Pro: active subscription - OS: Windows 11 - Model: Claude Sonnet 4.5 (Preview) **Error Message:** ``` AI_APICallError: prompt token count of 135099 exceeds the limit of 128000 ``` **Expected Behavior:** OpenCode should automatically apply the compact or truncation function to reduce token usage, allowing the AI call to proceed without exceeding the limit (as it did in previous versions). **Actual Behavior:** After upgrading, OpenCode no longer compacts the prompt data, causing AI requests with large contexts to fail immediately with the above error. **Steps to Reproduce:** 1. Update to OpenCode v0.14.6 2. Run a project or command that generates long context input for AI processing 3. Observe the token limit error **Proposed Fix / Suggestion:** - Reintroduce or patch the compacting logic before sending API requests.
yindo closed this issue 2026-02-16 17:33:46 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 9, 2025):

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

  • #2464: AT_APICallError: prompt token count of 130389 exceeds the limit of 128000 - Very similar error with token count exceeding limits, blocking the entire work process
  • #1172: high input token usage on a small project - Reports extremely high input token usage and context limit errors after upgrading, with similar AI_APICallError about input length exceeding limits
  • #924: Dramatic increase in token consumption - Reports significant increase in token consumption after upgrading, with context exhaustion happening much more frequently
  • #1937: Inconsistent Session Token Count - Reports issues with token counting mechanism that could lead to premature auto-compaction or other token-related problems
  • #2637: [Feature Request] Configuration to Limit Input Tokens per Request - Discusses the need for better token management and mentions automatic compaction issues

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 9, 2025): This issue might be a duplicate of existing issues. Please check: - #2464: AT_APICallError: prompt token count of 130389 exceeds the limit of 128000 - Very similar error with token count exceeding limits, blocking the entire work process - #1172: high input token usage on a small project - Reports extremely high input token usage and context limit errors after upgrading, with similar AI_APICallError about input length exceeding limits - #924: Dramatic increase in token consumption - Reports significant increase in token consumption after upgrading, with context exhaustion happening much more frequently - #1937: Inconsistent Session Token Count - Reports issues with token counting mechanism that could lead to premature auto-compaction or other token-related problems - #2637: [Feature Request] Configuration to Limit Input Tokens per Request - Discusses the need for better token management and mentions automatic compaction issues Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

i think we still auto compact, I believe the logic just needs some improvements

I will double check but idk if the compact logic got tweaked at all recently

@rekram1-node commented on GitHub (Oct 9, 2025): i think we still auto compact, I believe the logic just needs some improvements I will double check but idk if the compact logic got tweaked at all recently
Author
Owner

@OpeOginni commented on GitHub (Oct 9, 2025):

@nuson999 could you check if you have set your OPENCODE_DISABLE_AUTOCOMPACT env to true?

echo $OPENCODE_DISABLE_AUTOCOMPACT
@OpeOginni commented on GitHub (Oct 9, 2025): @nuson999 could you check if you have set your `OPENCODE_DISABLE_AUTOCOMPACT` env to true? ```sh echo $OPENCODE_DISABLE_AUTOCOMPACT ```
Author
Owner

@nuson999 commented on GitHub (Oct 9, 2025):

@nuson999 could you check if you have set your OPENCODE_DISABLE_AUTOCOMPACT env to true?

echo $OPENCODE_DISABLE_AUTOCOMPACT

echo $OPENCODE_DISABLE_AUTOCOMPACT set to false. The issue persists :(

edit: could not test further, but the issue seems to occur only when I run opencode via git bash

@nuson999 commented on GitHub (Oct 9, 2025): > [@nuson999](https://github.com/nuson999) could you check if you have set your `OPENCODE_DISABLE_AUTOCOMPACT` env to true? > > echo $OPENCODE_DISABLE_AUTOCOMPACT echo $OPENCODE_DISABLE_AUTOCOMPACT set to false. The issue persists :( edit: could not test further, but the issue seems to occur only when I run opencode via git bash
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

I don't think OPENCODE_DISABLE_AUTOCOMPACT is going to fix this, I think u should probably unset that variable actually. Your session got to a bad state so here is what you can try:

  • try /compact (execute slash command manually)
  • try using /undo to get to prior state of chat (u can do this multiple times) and then trying to continue chat from earlier point
  • alternative: start new session with /new you can always navigate back using /sessions to view session list
@rekram1-node commented on GitHub (Oct 9, 2025): I don't think `OPENCODE_DISABLE_AUTOCOMPACT` is going to fix this, I think u should probably unset that variable actually. Your session got to a bad state so here is what you can try: - try /compact (execute slash command manually) - try using /undo to get to prior state of chat (u can do this multiple times) and then trying to continue chat from earlier point - alternative: start new session with /new you can always navigate back using /sessions to view session list
Author
Owner

@nuson999 commented on GitHub (Oct 9, 2025):

I don't think OPENCODE_DISABLE_AUTOCOMPACT is going to fix this, I think u should probably unset that variable actually. Your session got to a bad state so here is what you can try:

  • try /compact (execute slash command manually)
  • try using /undo to get to prior state of chat (u can do this multiple times) and then trying to continue chat from earlier point
  • alternative: start new session with /new you can always navigate back using /sessions to view session list

It failed on the first run, a fresh session. And the prompt was just 100 characters.

@nuson999 commented on GitHub (Oct 9, 2025): > I don't think `OPENCODE_DISABLE_AUTOCOMPACT` is going to fix this, I think u should probably unset that variable actually. Your session got to a bad state so here is what you can try: > > - try /compact (execute slash command manually) > - try using /undo to get to prior state of chat (u can do this multiple times) and then trying to continue chat from earlier point > - alternative: start new session with /new you can always navigate back using /sessions to view session list It failed on the first run, a fresh session. And the prompt was just 100 characters.
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

how many mcps are u using i think they are flooding ur context

@rekram1-node commented on GitHub (Oct 9, 2025): how many mcps are u using i think they are flooding ur context
Author
Owner

@nuson999 commented on GitHub (Oct 9, 2025):

how many mcps are u using i think they are flooding ur context

All I did was clean install the opencode via npm and sign in the github copilot pro.

@nuson999 commented on GitHub (Oct 9, 2025): > how many mcps are u using i think they are flooding ur context All I did was clean install the opencode via npm and sign in the github copilot pro.
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

really no custom config at at? no global agents md or local ?

@rekram1-node commented on GitHub (Oct 9, 2025): really no custom config at at? no global agents md or local ?
Author
Owner

@nuson999 commented on GitHub (Oct 9, 2025):

really no custom config at at? no global agents md or local ?

No. Because I did a clean reinstall to test it. But I'll check it again

edit: Yesterday, I got an API error through Git Bash, but it’s working now. Maybe the issue was on GitHub’s side.

@nuson999 commented on GitHub (Oct 9, 2025): > really no custom config at at? no global agents md or local ? No. Because I did a clean reinstall to test it. But I'll check it again edit: Yesterday, I got an API error through Git Bash, but it’s working now. Maybe the issue was on GitHub’s side.
Author
Owner

@rekram1-node commented on GitHub (Oct 10, 2025):

but it’s working now

lmk if you have this issue crop up again

@rekram1-node commented on GitHub (Oct 10, 2025): > but it’s working now lmk if you have this issue crop up again
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2020