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 }}
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
See formatPromptWithHistory (lib/sessionStore.ts). Catalog models expose
up to ~1M token windows. We store 8 MiB and send a character tail
that neither respects tokenizer reality nor the model’s window.
#327 / PR #547 paint provider usage on the context slot. That is a meter, not a budget. We still fold with 400 / 3.5M.
Goal
The fold budget is model capability:
Input sized to the selected model’s context window (catalog / provider
metadata), minus a reserve for the completion (Pi-style contextWindow - reserveTokens, not a magic 3.5M chars).
Prefer tokens (provider tokenizer or a documented estimator). Character
slice is a last-resort backstop only, and must not be the product rule.
Drop 400 as an intelligence cap. A row count may remain only as a
safety rail against pathological message count, not as the way we
“save payload size.”
Success: a long session on a 1M-context model actually uses that window
for prior work (after A1/A2 content exists to put in it). A small-window
model compact-first (A4) instead of silently tail-slicing prose.
Caps (for the future plan — do not change in this issue)
Cap
Today
Direction
maxMessages 400
intelligence cap
change — human gate in create-plan
maxChars 3.5M
intelligence cap
change — replace with window-derived token budget
Function body 2 MiB / 4.5 MB
transport
unchanged — never raise fold until it fits the Gateway request, not the Blob
Blob 8 MiB
storage
unchanged here
Any raise/lower of 400 / 3.5M is a human decision on the phase plan
(plan-review cap rule).
Non-goals
Implementing compaction (A4) — this issue is the policy + accounting
create-plan against #548 A3. Need a per-model window source (catalog
field vs provider vs conservative default) before deleting 3.5M.
Peer harness notes
Pi: compact when contextTokens > contextWindow - reserveTokens (default
reserve 16 384). Occupancy for that comparison is last/max step, not
the summed turn total painted today (1.3M in can be 15×90k). Meter work
is #556 (not this board); this issue consumes occupancy once it
exists.
Also shrink what we send before arguing the window:
Budget still comes from last/max-step occupancy (#556, not this board) vs catalog window. Extra law: a family / model switch (operator Next, or a future router) is a cache miss — price the re-read of the warm prefix at fresh rates. Prefer switching only at the same boundaries as compaction (#552). Stay-put is the default decision.
buffer 20k vs window; keep.tokens 8k raw tail; tool-output serialize cap 2k chars
Codex local compact
keep recent user messages up to 20k tokens; tool outputs dropped
Occupancy for the comparison is still last/max step (#556, not this board), not the summed turn total.
OpenCode reloads projected history every provider turn — we already do that (stateless Functions). Dropping 400 / 3.5M only helps once #549’s array exists to spend the window on.
Family switch / Next = cache miss remains an Orrery lock with #558 / #552.
The durable-turn fold budget is now the selected model's context window minus a Pi-style reserve (max(16384, 15% × window)), measured in tokens (ceil(chars/4)). The 400-message intelligence cap is retired to a row-count safety rail; maxChars≈3.5M is a transport backstop only.
Occupancy metering (#556) and compaction (#552 / A4) remain separate boards.
Activity
btipling commentedon Aug 19, 2026
2026-08-19 source-level peer research
Budget policy is unchanged (model window − reserve, tokens not 3.5M chars). Extra peer numbers for the create-plan Caps table:
floor(max(16384, 0.15 × window)); keep-recent 20k tokensOccupancy for the comparison is still last/max step (#556, not this board), not the summed turn total.
OpenCode reloads projected history every provider turn — we already do that (stateless Functions). Dropping 400 / 3.5M only helps once #549’s array exists to spend the window on.
Family switch / Next = cache miss remains an Orrery lock with #558 / #552.
Merge pull request #945 from btipling/plan/context-window-budget
btipling commentedon Sep 5, 2026
Shipped by PR #945 (plan #944).
Merge:
9a049c65c9c6f625478a2720c83ef67fe2ea62e4The durable-turn fold budget is now the selected model's context window minus a Pi-style reserve (
max(16384, 15% × window)), measured in tokens (ceil(chars/4)). The 400-message intelligence cap is retired to a row-count safety rail;maxChars≈3.5Mis a transport backstop only.Occupancy metering (#556) and compaction (#552 / A4) remain separate boards.