Replies: 2 comments
|
Refined root cause, from a second session plus a run of the current resolution path against a real settings file — this is narrower than "provider default applied wholesale". The installed catalog simply has no entry for this id, while three sibling ids are described:
OpenRouter declares Local workaround (documented field, no code change)llm-pi-ai:
providers:
openrouter:
models:
- id: deepseek/deepseek-v4.1-flash
name: Deepseek Flash v4.1
contextWindow: 1048576Verified through Three things that a harness-side fix could cover
(Separately, 1,024,000 vs 1,048,576 for the two catalog-described siblings is pi-ai catalog drift; harmless at ~2%.) The two sessions cited: |
|
Your refinement checks out against the installed build. Two things I can add — a structural reason the miss cannot be diagnosed, and a consequence that reaches the wire. Verification
and has no Why the miss is structurally undiagnosable
const contextWindow = entry.contextWindow ?? base?.contextWindow ?? request.defaultContextWindowThe A diagnostic needs no new plumbing though: at A fourth consequence, and the most severe: it reaches the wireThe resolved number is not only a scheduling input. It is handed to pi-ai as const available = model.contextWindow - estimateContextTokens(context).tokens - 4096;
return Math.min(maxTokens, Math.max(1, available));Once the conversation outgrows the believed window, Footnotes on your third point
And the collapse is a band, not a cliff: at 250,000 anchored tokens |
Uh oh!
There was an error while loading. Please reload this page.
Summary
llm-pi-airesolves an unconfigured route's context window fromDEFAULT_CONTEXT_WINDOW(262,144) even when the provider publishes a larger capacity for the same model id. In this session two routes on the same profile disagreed:contextWindowmodlens-openrouter/deepseek-v4-flashopenrouter/deepseek/deepseek-v4.1-flashThe profile declares the model with only
idandname, so the default applies silently. Compaction then fires ~4× early, and the harness infers context overflow at 262,144 while the provider accepts 1,048,576.Environment
0.1.6-alpha.2, commitddefc45fbc7f8e46dd73185e68295696d1297887~/.dsh/settings.yaml:No
defaultContextWindow, no per-modelcontextWindow, no built-in catalog entry for this id.Current behavior
The harness-resolved capacity is recorded in the session's
request/contextevents:jq -c 'select(.type=="request/context") | .data' session-2496881f-sanitized.jsonlThe provider's own catalogue for that exact id, from
https://openrouter.ai/api/v1/models:Two consequences in this session:
resolveCompactSpecderivesthresholdTokens = 0.8 × 262144 = 209,715andretainTokens = 0.16 × 262144 = 41,943, so pressure compaction starts at a quarter of the usable context.isContextOverflow(message, contextWindow)is called with 262,144, so the harness declaresCONTEXT_WINDOW_EXCEEDEDfor a ~287k-token prompt that the provider served without complaint.Expected behavior
The default should not silently stand in for a capacity the provider publishes:
contextWindowfrom provider metadata when the route is reachable (thediscoverModelsseam already readscontext_length), orcontextWindow/defaultContextWindowfor a model id with no built-in entry, failing loud at load, orA 4× under-declaration is not a conservative fallback: it changes compaction scheduling, and it makes the harness reject requests the provider would accept.
Relation to existing reports
Evidence bundle
https://gist.github.com/gorban/4725c87390cb391047a2f14b56b98d28—EVIDENCE.mdsection 2, plus the full session log.All reactions