Show the selected model's known context window in the `clai2` status before the first turn
Fixes #11291
Why: a new clai2 session showed ? / ? for context (web header and terminal status row) until its first request reported a window, although the selected model's window is known from its profile and genai-prices.
New public surface: Status.model_window (the selected model's known window, set by the shell) and the read-only Status.window property (context_window, falling back to model_window), both on host.status, documented in PLUGINS.md.
User-visible behavior:
- new session, before the first turn: context ? / ?
+ new session, before the first turn: context 0 / 200k
- The shell resolves the window in
SessionRuntime.show_model: from the agent'sModel.context_windowfor an agent-default model, else coreinfer_model_profile(provider profile, then genai-prices), so it matches what a request later resolves.@profileaccount names are stripped first. - It re-seeds when the model changes, and on a new or resumed conversation. Once a completed turn on the selected model has run, only the requests' measured window shows, so a window the
compactiongauge leaves unresolved (such as for a fallback model) still reads?instead of a guess. - The measured
context_windowand itsif Nonefill-in fromSession.on_context_windoware unchanged; the seed lives in its own field. - An empty conversation reads
0instead of?.
Verification: the new tests in tests/clai2/test_status.py (test_the_shell_shows_the_known_window_before_the_first_turn, test_a_window_a_turn_left_unresolved_stays_unknown, test_a_turn_failing_before_its_request_keeps_the_known_window) and tests/clai2/test_web_parts.py (test_the_browser_status_shows_the_known_window_before_a_request_measures_one) fail on main and pass here. tests/clai2 passes locally, apart from 3 subprocess timeouts under -n 16 that pass when rerun serially. Ruff and pyright are clean on the changed files.
Known limitation: with a compaction context_window override, the row shows the model's window before the first request and the override after it. Before this PR it showed ? there. The shell does not read plugin settings, so a fix needs a plugin-to-status contract and is out of scope here.
What changes for existing users: the context figure shows 0/WINDOW before the first turn instead of ?/?. Nothing else changes.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.