docs(state): state the route-writer prompt invariant in one line

The writer docstrings narrated why the NULL was removed; one line stating
the invariant (route writers never touch the stored prompt, the runtime
identity check decides staleness) is what a reader needs.
This commit is contained in:
kshitijk4poor
2026-09-26 21:52:38 +05:30
committed by kshitij
parent f33b9dd07a
commit f4bdc3dd28
2 changed files with 3 additions and 14 deletions

View File

@@ -680,14 +680,7 @@ class SessionSessionsMixin:
"""Set the model after a mid-session /model switch (unconditionally) and drop any Browser """Set the model after a mid-session /model switch (unconditionally) and drop any Browser
runtime lock (lineage markers survive). runtime lock (lineage markers survive).
The stored system prompt is deliberately PRESERVED: it is the session's provider cache Route writers never touch the stored prompt; ``_stored_prompt_matches_runtime`` decides staleness.
prefix, and a rebuilt prompt never matches those bytes — clearing the row re-bills the whole
prefix on a commit that may not even have moved the route (the picker re-committing the
session's current model), and the next turn then reads a NULL row and takes the broken-row
branch in ``agent.conversation_loop`` (a WARNING blaming the previous turn's
``update_system_prompt`` write path). The stale ``Model:``/``Provider:`` footer this used to
null the row for is caught by ``_stored_prompt_matches_runtime`` on the next turn: a real
switch rebuilds there (INFO, then re-persists), a same-route commit reuses the bytes.
When *provider* is given the whole route is written, in both shapes resume reads (top-level When *provider* is given the whole route is written, in both shapes resume reads (top-level
keys for the TUI/Desktop, ``gateway_runtime`` for the CLI), so a later resume recombines the keys for the TUI/Desktop, ``gateway_runtime`` for the CLI), so a later resume recombines the
@@ -761,9 +754,7 @@ class SessionSessionsMixin:
confirmed: bool = False, confirmed: bool = False,
) -> None: ) -> None:
"""Persist a Browser / API-client runtime lock into model_config (lineage markers survive). """Persist a Browser / API-client runtime lock into model_config (lineage markers survive).
The stored system prompt stays: a lock that moves the model is caught by the next turn's Route writers never touch the stored prompt; ``_stored_prompt_matches_runtime`` decides staleness."""
``_stored_prompt_matches_runtime`` identity check, and one that does not must keep the
session's cache prefix byte-identical."""
lock = { lock = {
"provider": provider or "", "model": model or "", "model_options": model_options or {}, "provider": provider or "", "model": model or "", "model_options": model_options or {},
"route_source": route_source or "", "confirmed": bool(confirmed), "updated_at": time.time(), "route_source": route_source or "", "confirmed": bool(confirmed), "updated_at": time.time(),

View File

@@ -88,9 +88,7 @@ class SessionUsageMixin:
"""Unconditionally set the billing route (``update_token_counts`` only COALESCE-fills """Unconditionally set the billing route (``update_token_counts`` only COALESCE-fills
NULLs) so the dashboard reflects the latest /model switch. NULLs) so the dashboard reflects the latest /model switch.
The stored system prompt is left alone — it is the session's cache prefix and the route Route writers never touch the stored prompt; ``_stored_prompt_matches_runtime`` decides staleness.
change is caught by the next turn's ``_stored_prompt_matches_runtime`` identity check, which
rebuilds only when the footer it embeds is actually stale.
See #48173, #48248. See #48173, #48248.
""" """