Bad Request: Exceeding model token limit even in an empty directory #9410

Closed
opened 2026-02-16 18:12:23 -05:00 by yindo · 2 comments
Owner

Originally created by @chelebyy on GitHub (Feb 15, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Bad Request: Token limit exceeded even in empty directories and across multiple providers (requested ~377k tokens)
Issue Body:

Description:
I am consistently receiving a "Bad Request" error indicating that the request exceeded the model's token limit, even when working in a completely empty directory and sending a simple "selam" (hello) message.

The error persists regardless of the provider or API key used. I have tested this with:

Kimi (Personal API Key)

GLM (Personal API Key)

MiniMax (Free Tier)

In all cases, the system attempts to send an massive amount of tokens (~330k to 377k), with a very high tool input count, which shouldn't be possible in an empty folder.

Error Message Example:
Invalid request: Your request exceeded model token limit: 262144 (requested: 377222)
Bad Request: ... requested about 331445 tokens (82218 of text input, 217227 of tool input, 32000 in the output).

I didn't have this issue before; it started occurring recently.

The fact that it happens in an empty folder suggests that OpenCode might be leaking context from previous sessions or incorrectly scanning global/system paths as tool input.

Plugins

ohmyopencode

OpenCode version

1.2.4

Steps to reproduce

  1. Create a brand new, empty directory.
  2. Open/Run OpenCode within this directory.
  3. Type a short message like "hello".
  4. The request fails immediately with the token limit error.

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

Windows Terminal

Originally created by @chelebyy on GitHub (Feb 15, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Bad Request: Token limit exceeded even in empty directories and across multiple providers (requested ~377k tokens) Issue Body: Description: I am consistently receiving a "Bad Request" error indicating that the request exceeded the model's token limit, even when working in a completely empty directory and sending a simple "selam" (hello) message. The error persists regardless of the provider or API key used. I have tested this with: Kimi (Personal API Key) GLM (Personal API Key) MiniMax (Free Tier) In all cases, the system attempts to send an massive amount of tokens (~330k to 377k), with a very high tool input count, which shouldn't be possible in an empty folder. Error Message Example: Invalid request: Your request exceeded model token limit: 262144 (requested: 377222) Bad Request: ... requested about 331445 tokens (82218 of text input, 217227 of tool input, 32000 in the output). I didn't have this issue before; it started occurring recently. The fact that it happens in an empty folder suggests that OpenCode might be leaking context from previous sessions or incorrectly scanning global/system paths as tool input. ### Plugins ohmyopencode ### OpenCode version 1.2.4 ### Steps to reproduce 1. Create a brand new, empty directory. 2. Open/Run OpenCode within this directory. 3. Type a short message like "hello". 4. The request fails immediately with the token limit error. ### Screenshot and/or share link <img width="1112" height="554" alt="Image" src="https://github.com/user-attachments/assets/c625c5e4-0193-47ad-9e8f-ed11a9a296e8" /> ### Operating System Windows 11 ### Terminal Windows Terminal
yindo added the windowsbugperf labels 2026-02-16 18:12:23 -05:00
yindo closed this issue 2026-02-16 18:12:23 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 15, 2026):

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

  • #10385: Compaction bug - prompt token limit (similar Windows token limit issue with comparable error messages)
@github-actions[bot] commented on GitHub (Feb 15, 2026): This issue might be a duplicate of an existing issue. Please check: - #10385: Compaction bug - prompt token limit (similar Windows token limit issue with comparable error messages)
Author
Owner

@chelebyy commented on GitHub (Feb 15, 2026):

Closing this as it seems to be a duplicate of #10385. I will add my specific findings (issue occurring in empty directories on Windows 11) to that thread

@chelebyy commented on GitHub (Feb 15, 2026): Closing this as it seems to be a duplicate of #10385. I will add my specific findings (issue occurring in empty directories on Windows 11) to that thread
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9410