[BUG]: GPT 5.2 context_length_exceeded / Your input exceeds the context window of this model. #3807

Closed
opened 2026-02-16 17:41:32 -05:00 by yindo · 10 comments
Owner

Originally created by @peixotorms on GitHub (Dec 23, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Using GPT 5.2 via api, with reasoning high.

After about 1 hour of usage, I hit

{"type":"error","sequence_number":2,"error":{"type":"invalid_request_error","code":"context_length_exceeded","message":"Your input exceeds the context window of this model. Please adjust your input and try again.","param":"input"}}

On the right panel I see

Context
270,593 tokens
68% used
$5.13 spent

I noticed that context keeps going up, then down, which from what I read, its intended.
However, maybe its not counted correctly, because GPT 5.2 limit via api is 400k not 270k.

/compact works, then I can proceed, so this is just a report on the incorrect count and limit.

Thanks

OpenCode version

v1.0.193

Steps to reproduce

Just use normally with gpt 5.2 high.

Screenshot and/or share link

No response

Operating System

Ubuntu Server

Terminal

No response

Originally created by @peixotorms on GitHub (Dec 23, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Using GPT 5.2 via api, with reasoning high. After about 1 hour of usage, I hit `{"type":"error","sequence_number":2,"error":{"type":"invalid_request_error","code":"context_length_exceeded","message":"Your input exceeds the context window of this model. Please adjust your input and try again.","param":"input"}}` On the right panel I see ``` Context 270,593 tokens 68% used $5.13 spent ``` I noticed that context keeps going up, then down, which from what I read, its intended. However, maybe its not counted correctly, because GPT 5.2 limit via api is 400k not 270k. `/compact` works, then I can proceed, so this is just a report on the incorrect count and limit. Thanks ### OpenCode version v1.0.193 ### Steps to reproduce Just use normally with gpt 5.2 high. ### Screenshot and/or share link _No response_ ### Operating System Ubuntu Server ### Terminal _No response_
yindo added the bugzen labels 2026-02-16 17:41:32 -05:00
yindo closed this issue 2026-02-16 17:41:32 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 23, 2025):

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

  • #5970: Research subagent exceeded the context window and silently failed
  • #4659: Sliding window context management for long-running sessions (addresses context overflow scenarios)
  • #3031: Model in BUILD mode does not have enough context to continue after compaction
  • #1714: GPT5 incorrect context counting (similar context counting discrepancy)
  • #4845: prompt is too long unrecoverable (similar unrecoverable context limit errors)

The core issue appears to be context limit counting accuracy and handling for GPT 5.2. Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Dec 23, 2025): This issue might be a duplicate of existing issues. Please check: - #5970: Research subagent exceeded the context window and silently failed - #4659: Sliding window context management for long-running sessions (addresses context overflow scenarios) - #3031: Model in BUILD mode does not have enough context to continue after compaction - #1714: GPT5 incorrect context counting (similar context counting discrepancy) - #4845: prompt is too long unrecoverable (similar unrecoverable context limit errors) The core issue appears to be context limit counting accuracy and handling for GPT 5.2. Feel free to ignore if none of these address your specific case.
Author
Owner

@ghost commented on GitHub (Dec 24, 2025):

I am also encountering this issue.

@ghost commented on GitHub (Dec 24, 2025): I am also encountering this issue.
Author
Owner

@clayrisser commented on GitHub (Dec 27, 2025):

I am facing this issue with custom local models. Is there a way to configure the context size for local models?

@clayrisser commented on GitHub (Dec 27, 2025): I am facing this issue with custom local models. Is there a way to configure the context size for local models?
Author
Owner

@rekram1-node commented on GitHub (Dec 31, 2025):

@clayrisser make sure you have the context input & output defined for your model in the model definition

@rekram1-node commented on GitHub (Dec 31, 2025): @clayrisser make sure you have the context input & output defined for your model in the model definition
Author
Owner

@Tioit-Wang commented on GitHub (Feb 10, 2026):

GPT-5.2 xhigh

OpenCode Desktop
v1.1.53
@Tioit-Wang commented on GitHub (Feb 10, 2026): GPT-5.2 xhigh ``` OpenCode Desktop v1.1.53 ```
Author
Owner

@rafaell-lycan commented on GitHub (Feb 10, 2026):

Same here

Context
238,028 tokens
60% used
$8.72 spent

Also using GPT-5.2 (xhigh)

OpenCode Desktop:
v1.1.56

@thdxr any ideas?

@rafaell-lycan commented on GitHub (Feb 10, 2026): Same here ``` Context 238,028 tokens 60% used $8.72 spent ``` Also using **GPT-5.2 (xhigh)** ``` OpenCode Desktop: v1.1.56 ``` @thdxr any ideas?
Author
Owner

@peixotorms commented on GitHub (Feb 10, 2026):

Well, after this I stumble across some articles about the 272k limit, so the 400k OpenAI advertises as context is 272k in + 128k out.

Sneaky as it sounds, they changed the description to "context" for marketing purposes, starting on GPT 5.
In reality, its 272k input + 128k output, not "context" as we know it, and think that it's just input.

Still there is a bug here, to count it correctly.

@peixotorms commented on GitHub (Feb 10, 2026): Well, after this I stumble across some articles about the 272k limit, so the 400k OpenAI advertises as context is 272k in + 128k out. Sneaky as it sounds, they changed the description to "context" for marketing purposes, starting on GPT 5. In reality, its 272k input + 128k output, not "context" as we know it, and think that it's just input. Still there is a bug here, to count it correctly.
Author
Owner

@mvarchdev commented on GitHub (Feb 11, 2026):

Have this also, hope it gets fixed, as I quite like opencode - but for now, switching back to codex app

@mvarchdev commented on GitHub (Feb 11, 2026): Have this also, hope it gets fixed, as I quite like opencode - but for now, switching back to codex app
Author
Owner

@rekram1-node commented on GitHub (Feb 11, 2026):

This shouldnt happen nearly as often on latest, if you still get this issue im making sure it is recoverable shortly

@rekram1-node commented on GitHub (Feb 11, 2026): This shouldnt happen nearly as often on latest, if you still get this issue im making sure it is recoverable shortly
Author
Owner

@mvarchdev commented on GitHub (Feb 11, 2026):

Ah, okay nice! I am going to test again with the same prompt I tried yesterday. Will let you know!

@mvarchdev commented on GitHub (Feb 11, 2026): Ah, okay nice! I am going to test again with the same prompt I tried yesterday. Will let you know!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3807