Repository navigation
Description
Summary
Compaction (#440) and the tole status context meter need the model's context window. Tole gets it only from an explicit setting (TOLE_CONTEXT_WINDOW / config) or the provider's GET /models. The fleet gateway's /models entries carry only id, created, owned_by, so on the fleet compaction is silently off unless the setting is made. The only signal is one stderr line, printed once per process by run / chat / resume and only after the prompt passes the 8,000-token detection floor (compaction_host.rs, DETECT_FLOOR). And when a provider does report a context overflow, nothing recovers from it.
Measured
- Gateway
/models: 11 entries; fields ={created, id, owned_by}; 0/11 carry any recognized window field (context_length,context_window,max_context_length,max_model_len,max_input_tokens,top_provider.context_length). - On the maintainer's host:
TOLE_CONTEXT_WINDOWis not set in the fleet env files and there is no user config file. - Mock
/modelswithout a window,resumeafter a ~15k-token prompt: stderrtole: compaction off: the provider's /models reports no context window for this model; set TOLE_CONTEXT_WINDOW (tokens) to enable it; with a window present compaction proceeds silently. tole doctor --tier catalogprintscatalog: mock-model is served (<N> models)and exits 0 in both cases; it does not mention the missing window.- The window is re-fetched in every process (no disk cache); the gateway's
/modelstakes 0.15-0.36 s (3 probes) and is only called once the prompt passesDETECT_FLOOR. - Overflow: the mock answers HTTP 400
context_length_exceeded; tole ends the turn with rc 4http status: 400(the body is hidden, see the provider-error-body issue). The session is resumable, but nothing shrinks the history. - Worst case is derived from source, not measured:
MAX_STEPS = 32per turn xread_fileup to 20,000 chars per call is about 640k chars (about 160k tokens) of tool output inside ONE turn, against a window of about 200k for the fleet model. Compaction only runs between turns, so a single large turn can fill most of the window (and, on top of earlier history, exceed it) before compaction gets a chance. - Public window figures for the fleet model: 202,752-204,800 tokens depending on the source.
Why it matters now
#458 (session status snapshot) and the TUI footer (#460: "context used / window") need the same window; on the fleet gateway they would show no window at all.
Compare
- nca 0.5.5: static table of known windows, then the provider catalog, cached on disk 24 h per provider+endpoint+model. Its own benchmark: removing the catalog round trip cut first-event latency from 2.5-4.3 s to 14-20 ms. The table is stale (Claude 3.x era): copy the idea, not the data.
- fx: compacts at 80% of the usable window; if the provider reports a context overflow before any text or tool call, it compacts and retries once.
Proposal (smallest first)
tole doctor(catalog tier): warn when the catalog has no window for the configured model and print the exact setting to add. The coverage ledger stays honest. Note:doctorfetches ids only (fetch_model_ids_with_timeout,doctor.rs:447), so this needsfetch_context_window(openai.rs:819, returnsResult<Option<u64>, String>) or an extended fetch; it is not a one-line tweak.- Document
TOLE_CONTEXT_WINDOW/ configcontext_windowin the fleet setup and set it for the fleet model. - Overflow safety net: classify a context-overflow error (needs the provider-error-body issue: provider: HTTP error body is discarded (ureq default) — 4xx/5xx detail never reaches the operator #474) and force a compaction at the next
resume <id> "<prompt>", independent of window detection. Design question for the owner: compaction is deliberately between-turns only, so a mid-turn overflow can end the turn with a clear message and let the next turn compact, versus compacting and retrying in place as fx does. - Optional: small built-in table for the fleet's own models as a last-resort hint (explicit setting and catalog both win); optional 24 h disk cache of a successful lookup (atomic temp+rename; never cache failures).
Acceptance
-
doctor --tier catalogsurfaces the missing window as a non-fatal warning. - Overflow: mock E2E where the provider answers
context_length_exceeded; the operator sees the provider message and the next prompt compacts and succeeds. - If a table/cache is added: precedence tests (flag/env/config > catalog > table) and cache expiry; no write on failure.
- Docs.
Found by
Competitor research 2026-11-02 (nca model_limits_api.rs disk cache; fx compaction docs), measured against the fleet gateway and develop @ 438ad0d.
Activity
refactor(cli): one turn runner shared by the server faces and the TUI (…
refactor(cli): one module for a session's durable settings (#550)