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
{{ message }}
Repository navigation
Over-window session: historian fails on every idle with no backoff (exceeds_window bypasses the failure counter) and each failed attempt still creates a new hidden session #595
When a session grows past the historian model's context window, every incremental historian run fails immediately with producer_prompt_exceeds_window — retried on every idle marker with no backoff, because the admission-refused branch returns beforeincrementHistorianFailure and rolls back the retry-throttle reservation. Each failed attempt still creates a fresh hidden session. On hosts where hidden sessions can't be deleted at runtime (plain opencode serve / OpenChamber, #589) this floods the session list.
What happened?
Observed on 0.42.6 (running); mechanism verified in the 0.44.4 dist.
A long-running orchestrator session (1,929 messages, calibrated 236,700 tokens) exceeded the configured historian model's window (218,250). From then on:
Every opencode idle marker on that session triggered an incremental historian run that fails instantly with producer_prompt_exceeds_window calibrated_tokens=236700 limit=218250 — 106 failed runs in ~64 minutes while the session was active (one every 15–30 s). The condition is permanent (the session only grows), so the historian never recovers.
Each failed attempt correlates 1:1 with the creation of a new "Magic Context historian" hidden session (timestamps match exactly): 54 new hidden sessions in 15 minutes, 114 that day. Under OpenChamber (no runtime deletion) they all stay visible; even where deletion works, it's a create+delete churn per turn.
Code path (0.44.4 dist)
The producer_prompt_(exceeds_window|fit_unavailable) branch logs "historian producer admission refused", sets retainDrainReservationForRetryThrottle = false, calls rollbackDrainReservation(), and returns — before the incrementHistorianFailure / notifyHistorianIssue calls, which only run for other validation failures. So the most permanent failure class is exactly the one that bypasses the failure counter, the user-facing notice, and the retry throttle.
Suggestions
Treat admission-refused exceeds_window as permanent for the session: stop scheduling incremental retries (or gate retries behind an explicit trigger / config change), instead of re-firing on every idle.
Run the admission check before creating (or retiring) the hidden child, so a refused pass doesn't churn a session per attempt.
Consider a degrade path for over-window sessions — e.g. summarize a trailing prefix that fits the window — instead of refusing the whole pass forever.
Thanks for the detailed trace. The three problems you describe are all real.
No backoff on an admission refusal.producer_prompt_exceeds_window returns before the failure counter and rolls back the retry-throttle reservation. So the one failure that can't fix itself is the one that retries on every idle with no backoff and no notice.
A hidden session per refused attempt. The admission check runs after the child session is created, so each refused attempt leaves one more hidden session behind.
The underlying cause. The historian should never build a prompt bigger than its own model's window in the first place. The chunk it summarizes needs to be sized to fit, so a long session keeps getting summarized instead of being refused forever.
We're fixing all three on current master: chunk sizing that fits the historian model's window, refusals counted with backoff and surfaced once, and the admission check moved before any child session is created. I'll post here when it ships.
For the hidden sessions themselves: upstream OpenCode has merged plugin-side session removal and parented child sessions (anomalyco/opencode#49389) on its v2 branch. We're building on it now, so once the next OpenCode 2 release ships, hidden runs will be children of your session and removed when they finish.
Fixed in 0.45.0, now on npm. The historian now fits its prompt to the model's window before opening a session: it leaves room for the system prompt, memories and recent summaries, then sizes the chunk. If the window is too small even for the fixed parts, it reports MC-H05 once and retries only when the model or window changes, so an over-window session no longer opens a new hidden session on every idle.
To update, quit every OpenCode and Pi process first: the database migrates on first start, which can take up to a minute on a large database. OpenCode 1 and Pi pick up the new version on restart. On OpenCode 2 (2.0.22 or newer is now required), open /plugins, select Magic Context and press ctrl+u, or run opencode plugin update. If you still see this on 0.45.0, please reopen with a log.
Activity
magic-alfonso commentedon Oct 1, 2026
Thanks for the detailed trace. The three problems you describe are all real.
producer_prompt_exceeds_windowreturns before the failure counter and rolls back the retry-throttle reservation. So the one failure that can't fix itself is the one that retries on every idle with no backoff and no notice.We're fixing all three on current master: chunk sizing that fits the historian model's window, refusals counted with backoff and surfaced once, and the admission check moved before any child session is created. I'll post here when it ships.
For the hidden sessions themselves: upstream OpenCode has merged plugin-side session removal and parented child sessions (anomalyco/opencode#49389) on its v2 branch. We're building on it now, so once the next OpenCode 2 release ships, hidden runs will be children of your session and removed when they finish.
magic-alfonso commentedon Oct 4, 2026
Fixed in 0.45.0, now on npm. The historian now fits its prompt to the model's window before opening a session: it leaves room for the system prompt, memories and recent summaries, then sizes the chunk. If the window is too small even for the fixed parts, it reports
MC-H05once and retries only when the model or window changes, so an over-window session no longer opens a new hidden session on every idle.To update, quit every OpenCode and Pi process first: the database migrates on first start, which can take up to a minute on a large database. OpenCode 1 and Pi pick up the new version on restart. On OpenCode 2 (2.0.22 or newer is now required), open
/plugins, select Magic Context and press ctrl+u, or runopencode plugin update. If you still see this on 0.45.0, please reopen with a log.