You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
opencode-go/glm-5.2 is advertised with a 1,000,000-token context window (both on https://opencode.ai/docs/go/ and via https://models.dev/api.json), but the Go backend routes GLM-5.2 requests to providers that only support 262,144 tokens (DigitalOcean Inference Engine, Cloudflare Workers AI). opencode trusts the models.dev metadata, computes usable against 1M, and only discovers the real backend cap when the provider returns a hard overflow error — at which point compaction has already failed.
Result: paying Go subscribers hit unrecoverable Conversation history too large to compact at ~230K input tokens, far below the advertised 1M, and lose the session.
Error
Error from provider (DigitalOcean): This model's maximum context length is 262144 tokens.
However, you requested 32000 output tokens and your prompt contains at least 230145 input tokens,
for a total of at least 262145 tokens. Please reduce the length of the input prompt or the number
of requested output tokens. (parameter=input_tokens, value=230145)
Followed by:
Conversation history too large to compact - exceeds model context limit 406.6K (41%) · $113.22
Expected vs actual
Advertised
Actual (DigitalOcean backend)
Context
1,000,000
262,144
Output
131,072
52,429
usable (opencode computes)
~849K
—
usable (real backend)
—
~189K
opencode computes usable = model.limit.context - maxOutputTokens - reserved = 1,000,000 - 131,072 - 20,000 ≈ 849K (per packages/opencode/src/session/overflow.ts). Compaction triggers near 849K. The compaction prompt alone (system + tools + MCP defs + skills) exceeds 230K, so the very first compaction request overflows the real 262K backend.
Workers AI is launching the model with a 262,144 token context window and plans to increase this in the future.
Endpoint https://opencode.ai/zen/go/v1/models returns only {id, owned_by} — no context_length field — so opencode cannot detect the real backend cap from the provider and falls back to models.dev's 1M claim.
Root cause
Two compounding bugs:
Backend routing mismatch: Go routes glm-5.2 to backends that cap at 262K while advertising 1M in metadata. Either route only to 1M-capable backends (Z.ai native, Fireworks) or update opencode-go/glm-5.2 metadata to reflect the lowest common backend (262K) so opencode computes usable correctly.
Overflow error not classified (already tracked in fix(provider): Z.AI GLM overflow error not classified as context overflow, causing chain compaction #27629): the DigitalOcean/Z.ai overflow error phrasing ("This model's maximum context length is 262144 tokens. However, you requested…") is not in OVERFLOW_PATTERNS (packages/opencode/src/provider/error.ts), so it is treated as a generic APICallError instead of ContextOverflowError, preventing graceful auto-compaction and leaving the session permanently stuck.
Repro
Subscribe to OpenCode Go, connect via /connect.
Use opencode-go/glm-5.2 as default model.
Load a large session (10+ MCP servers, 100+ tool calls, AGENTS.md hierarchy) until compaction triggers.
Observe: compaction request itself exceeds 262K → DigitalOcean returns overflow → opencode does not classify as context overflow → Conversation history too large to compact → session dead.
Environment:
opencode 1.17.18
Windows / PowerShell
Provider: opencode-go/glm-5.2 via https://opencode.ai/zen/go/v1
Metadata honesty: in packages/opencode/src/provider/provider.ts (or via models.dev), cap opencode-go/glm-5.2limit.context to the minimum across all backends Go routes to (262,144 today), until all backends support 1M. Alternatively, expose backend identity in https://opencode.ai/zen/go/v1/models so opencode can pick the right limit per request.
Overflow classification: add to OVERFLOW_PATTERNS in packages/opencode/src/provider/error.ts:
This ensures that even when metadata lies, the overflow is recognised and auto-compaction can reduce context instead of bricking the session.
Why this matters
Go subscribers pay for the advertised 1M context. Silently routing to 262K backends — and then bricking the session because the overflow is not recognised — is a paid-feature regression. The $113.22 session cost is not refundable through opencode; the user is left with a dead session and no indication that the root cause is backend routing, not their usage.
Summary
opencode-go/glm-5.2is advertised with a 1,000,000-token context window (both on https://opencode.ai/docs/go/ and viahttps://models.dev/api.json), but the Go backend routes GLM-5.2 requests to providers that only support 262,144 tokens (DigitalOcean Inference Engine, Cloudflare Workers AI). opencode trusts the models.dev metadata, computesusableagainst 1M, and only discovers the real backend cap when the provider returns a hard overflow error — at which point compaction has already failed.Result: paying Go subscribers hit unrecoverable
Conversation history too large to compactat ~230K input tokens, far below the advertised 1M, and lose the session.Error
Followed by:
Expected vs actual
usable(opencode computes)usable(real backend)opencode computes
usable = model.limit.context - maxOutputTokens - reserved = 1,000,000 - 131,072 - 20,000 ≈ 849K(perpackages/opencode/src/session/overflow.ts). Compaction triggers near 849K. The compaction prompt alone (system + tools + MCP defs + skills) exceeds 230K, so the very first compaction request overflows the real 262K backend.Evidence
models.dev metadata (what opencode trusts):
Cached at
~/.cache/opencode/models.json, refreshed fromhttps://models.dev/api.json.docs/opencode.ai/docs/go/ table lists GLM-5.2 with 1M context and 131K output.
DigitalOcean docs (
docs.digitalocean.com/products/inference/details/models/):Cloudflare changelog (
developers.cloudflare.com/changelog/2026-06-16-glm-52-workers-ai):Endpoint
https://opencode.ai/zen/go/v1/modelsreturns only{id, owned_by}— nocontext_lengthfield — so opencode cannot detect the real backend cap from the provider and falls back to models.dev's 1M claim.Root cause
Two compounding bugs:
Backend routing mismatch: Go routes
glm-5.2to backends that cap at 262K while advertising 1M in metadata. Either route only to 1M-capable backends (Z.ai native, Fireworks) or updateopencode-go/glm-5.2metadata to reflect the lowest common backend (262K) so opencode computesusablecorrectly.Overflow error not classified (already tracked in fix(provider): Z.AI GLM overflow error not classified as context overflow, causing chain compaction #27629): the DigitalOcean/Z.ai overflow error phrasing ("This model's maximum context length is 262144 tokens. However, you requested…") is not in
OVERFLOW_PATTERNS(packages/opencode/src/provider/error.ts), so it is treated as a genericAPICallErrorinstead ofContextOverflowError, preventing graceful auto-compaction and leaving the session permanently stuck.Repro
/connect.opencode-go/glm-5.2as default model.Conversation history too large to compact→ session dead.Environment:
opencode-go/glm-5.2viahttps://opencode.ai/zen/go/v1Related issues
Proposed fix
Two independent fixes, both useful:
Metadata honesty: in
packages/opencode/src/provider/provider.ts(or via models.dev), capopencode-go/glm-5.2limit.contextto the minimum across all backends Go routes to (262,144 today), until all backends support 1M. Alternatively, expose backend identity inhttps://opencode.ai/zen/go/v1/modelsso opencode can pick the right limit per request.Overflow classification: add to
OVERFLOW_PATTERNSinpackages/opencode/src/provider/error.ts:This ensures that even when metadata lies, the overflow is recognised and auto-compaction can reduce context instead of bricking the session.
Why this matters
Go subscribers pay for the advertised 1M context. Silently routing to 262K backends — and then bricking the session because the overflow is not recognised — is a paid-feature regression. The $113.22 session cost is not refundable through opencode; the user is left with a dead session and no indication that the root cause is backend routing, not their usage.