Repository navigation
Context window exceeded despite context left #2825
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Codex is running?
codex-cli 0.25.0
Which model were you using?
gpt-5 high
What platform is your computer?
Linux 6.16.3-arch1-1 x86_64 unknown
What steps can reproduce the bug?
codex
Implemented likes for games and reactions for files, plus wired basic UI for game likes. Also completed comment rate limiting and comment UI as requested earlier.
What’s new
Backend
- Ent schemas:
- GameLike: user_id + Game edge with unique (user_id, game) index.
- FileReaction: user_id, value(-1/+1) + File edge with unique (user_id, file).
- Edges on Game → likes and File → reactions (Relay connections).
- Comment schema already added (with sanitization).
- GraphQL API (api/custom.graphqls):
- Mutations:
- rateGame(gameId, like: Boolean!): Game!
- like=true creates the like; like=false removes it.
- reactToFile(fileId, value: Int!): File!
- value ∈ {-1, 1} sets reaction; 0 clears existing reaction.
- addComment/editComment/deleteComment (from earlier) are in place.
- Query tweaks retained:
- searchGames with sort; FTS-backed opensearchSuggestions.
- Resolvers (graph/custom.resolvers.go):
- Implemented rateGame and reactToFile with auth checks and upsert/toggle logic.
- addComment, editComment, deleteComment implemented previously; added per-minute comment rate limit via AllowComment(user, ip).
Rate limits
- internal/rate:
- Added per-minute buckets and AllowComment(userID, ip) with env tunables:
- RATE_LIMIT_ANON_COMMENTS_PER_MIN (default 5)
- RATE_LIMIT_USER_COMMENTS_PER_MIN (default 15)
Frontend
- GameDetail:
- Displays like count (Game.likes totalCount).
- Like/Unlike buttons (simple reload after mutation).
- Comments list and add form (sanitized display).
- Search:
- Filters (platform/year/format), sort selector, load-more append.
- Header search input navigates to /search.
- Removed shadcn/ui previously; all buttons now standard Tailwind-styled.
Changelog
- Added entries for Comments (schema/CRUD/rate limits/UI) and earlier search/observability items.
What’s left for likes/reactions (nice-to-haves)
- File reactions UI: add thumbs up/down in file rows; query likes/dislikes counts via reactions(where:{value:1/-1}). We can wire that next.
- Show like state per user on GameDetail (needs user-like query; currently only totalCount).
- Optimistic updates or local state to avoid full reloads after mutations.
Open issues remaining
- #43 Moderation route polish
- #40 FE: Game page UGC (we’ve started—comments/likes; reactions UI pending)
- #41/#29/#28 Collections/Favorites
- #30 Video links
- #21/#22/#23 Descriptions sanitize/version/history
- #37 Feature flags
- #38/#39 QA tests
- #20 Tracker
- #31 (FTS index) functionally complete via #58; can be closed as done
If you want, I can:
- Add file reactions UI (thumbs up/down) and display counts on GameDetail.
- Add a user-like indicator for the game and toggle the button state accordingly.
- Close #31 and move onto collections/favorites (#28/#29/#41).
user
yes
>_
✓ 📖 GameDetail.tsx
⚠ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 1/5 in 191ms…
⚠ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 2/5 in 420ms…
⚠ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 3/5 in 746ms…
⚠ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 4/5 in 1.505s…
⚠ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 5/5 in 3.516s…
🖐 stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.
▌ Explain this codebase
⏎ send Ctrl+J newline Ctrl+T transcript Ctrl+C quit 1883319 tokens used 32% context left
What is the expected behavior?
with 32% context left, no issues
What do you see instead?
see above
Additional information
maybe it's just task context
Note to me too/same here commenters, it would probably help if you included your codex-cli version
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
takemiyamakoto commentedon Aug 28, 2025
I get the same, exactly at 32% context left too.
dlukt commentedon Aug 28, 2025
And shortly after:
dlukt commentedon Aug 28, 2025
You can't be serious
dlukt commentedon Aug 28, 2025
Because of this I've completely lost track of where I am, what needs to be done, what has been already done, and the web codex just produces useless results. Essentially 1½ days wasted on a codebase that will get deleted...
dlukt commentedon Aug 28, 2025
https://github.com/deicod/archivedgames-failed
the failed repo
maver1ck commentedon Aug 28, 2025
Same problem with Figma MCP
oyiakoumis commentedon Aug 28, 2025
I put a breakpoint in the client to inspect the payload and noticed that the reasoning tokens from the previous message were being sent to the API.
However, in
codex-rs/protocol/src/protocol.rslines 529–536:This suggests that either:
If I recall correctly, the correct approach is the first one.
adsqx commentedon Aug 31, 2025
Probably the percentage doesn’t reflect the actual input. In such a situation, run /status and check how much input there really is. For me, at 80% it’s around 300k, so at 30% it must be huge.
If you want to work efficiently, I’d recommend running /compact at around 80%.
P.S. I never had the conscience to send the next message when it was already at 80% — I don’t think I ever went lower than that :) Leave a little room for the GPU :)
volgin commentedon Sep 1, 2025
I hit the same issue at 32% context left. It can't be a coincidence.
yokasaka commentedon Sep 2, 2025
Today, I hit this issue when my left context was 33%.
Anarchon14 commentedon Sep 2, 2025
I hit it on "89% context left" today playing with Playwright MCP doing some e2e tests with screenshots, maybe the screenshots flood the context window and are not tracked at all? @ae-openai
tekn0x commentedon Sep 2, 2025
Same for me. At exactly 32%. Two days in a row. Thats the magic number for what ever reason.
stream error: stream disconnected before completion: Your input exceeds the context window of this model.
Please adjust your input and try again.; retrying 5/5 in 3.423s…
🖐 stream disconnected before completion: Your input exceeds the context window of this model. Please adjust
your input and try again.
gianlucamazza commentedon Sep 3, 2025
same problem, there is no way to use /compact
RazeBerry commentedon Sep 4, 2025
Same problem here with ~32% context window left!
10 remaining items
alexfdo commentedon Sep 13, 2025
Because of this error I unsubscribed from the codex today. I subscribed yesterday - unsubscribed today. I live interestingly, I guess.
adsqx commentedon Sep 13, 2025
Let’s assume you have ~190k tokens in context, which leaves you with ~80k. The input counter is not updated in real time but only after a completed turn. If at that point you write “Analyze xyz…” and then “apply corrections”, this can lead to an overflow, and even auto-compact won’t help.
The probable reason is that each iteration adds to the context, but the input size is only updated after the whole turn ends. For example, after a full turn you might already exceed 300k, but this won’t be detected during generation — only after completion.
Possible solution:
In optimal conditions, auto-compact should solve this problem. However, the counting must be done in real time, and compacting should already run in a separate thread once the input size exceeds the auto-compact threshold. Then, the next iteration during agent execution could append directly to the compacted context rather than to the full previous conversation.
Alternatively, I suggest considering a scaled compact + the last N elements (with N configurable), so that the model doesn’t “get confused” during iteration.
Here, it would be best to dynamically calculate the last n elements based on the tools used and the calls made, so that nothing disappears during execution.”
This would improve both user experience (✅ no visible pauses or late compacting) and safety.
So the flow should look like:
✅ 190 → 210 → … → 250 → (compact) → 120 → 150 … → end of turn.
Currently, it’s wrong:
❌ 190 → 210 → … → 250 → context overflow (no compacting during the turn).
That’s why it’s worth maintaining a reactive design pattern with injection.
For example:
cli_service.input_size.watch(handler)
cli_service.input_size.update(val)
This way you get a reactive real-time stream, and everything works seamlessly.
Besides, I notice that after /compact, the context left shows 100% — that probably shouldn’t be the case.
😃
alexfdo commentedon Sep 13, 2025
In Cloud Code, all this is done automatically. But here, what do you have to sit with an abacus and count: "What if..."?
What kind of AI tool is this?
I'm currently sitting in Kilocode and using up to 280-300 thousand tokens, and there are no such stories when you haven't even started the task yet, and you already have no limit!
adsqx commentedon Sep 13, 2025
@alexfdo
This isn’t about sitting with an abacus — it’s a proposal for automatic refactoring that should happen seamlessly in the background.
From what I know, Claude Code doesn’t really expose this mechanism publicly; everything happens under the hood.
So either it works the way I’m describing, or it aggressively compacts when the context left drops to around 60%, for example.
That, in turn, might lead to the phenomenon where the model seems “dumbed down” just to save resources. What Claude Code has recently experienced.
These are simply observations about what could be causing the issue and how it might be fixed.
This is a standard procedure in computer science/programming — a backpressure safeguard, used when you’re sending more data at once than the system can handle.
So there’s no magic here. :)
So, briefly: a system operating on rx/tx needs a real-time backpressure mechanism, so that the transmitter does not exceed the receiver’s capabilities.
mateusgalasso commentedon Sep 16, 2025
same here
alexfdo commentedon Sep 16, 2025
And I said the same thing, but that was three days ago.
Dexus commentedon Sep 16, 2025
@aibrahim-oai @pakrym-oai I think it is not fixed yet...
Theysua commentedon Sep 17, 2025
Same here using on VS Code
ataetgi commentedon Sep 18, 2025
same issue with vscode extension
AidPaike commentedon Sep 19, 2025
same issue
command3rkeen commentedon Sep 20, 2025
same...
tekn0x commentedon Sep 21, 2025
This seems resolved for me on v0.39.0 in MacOS 14.7.6 using gpt-5-codex high.
Was able to get down to 1% left with no issues on two different sessions.
adsqx commentedon Sep 30, 2025
https://www.anthropic.com/news/context-management
SNIKO commentedon Oct 7, 2025
Happens to me too as soon as it hits a tool returning an image.
Happens on the new session with 100% context left. It is the 2nd tool it calls, so, I doubt it used any context at all.
I feel like it doesn't support images at all and reads them as a base64 string rather than an image.
mion-kr commentedon Oct 21, 2025
same