Skip to content

The agent that grows with you

Merge branch 'simp/r3-04-w1b' into simp/r3-04-w1

Tekniumaabb4ddf4473
diff --cc agent/chat_completion_helpers.py
index 77af80fc6e9,7d5de2b7dbb..07124959268
--- a/agent/chat_completion_helpers.py
+++ b/agent/chat_completion_helpers.py
@@@ -2130,22 -2435,13 +2130,12 @@@ def build_assistant_message(agent, assi
return msg
-
def rewrite_prompt_model_identity(agent, model: str, provider: str) -> None:
- """Point the cached system prompt's ``Model:``/``Provider:`` lines at
- the active runtime after a provider switch.
-
- The system prompt is session-stable and replayed verbatim for prefix-cache
- warmth, but after a failover the new backend's cache is cold anyway —
- while a stale identity line makes the agent misreport which model it is
- when asked. Rewrite the lines in place WITHOUT persisting to the session
- DB: the stored row keeps the primary's labels, so when the primary is
- restored the prompt is byte-identical to the stored copy again and its
- prefix cache still matches.
-
- Only the LAST occurrence of each line is touched — the identity lines
- live in the volatile tail of the prompt, and earlier matches could be
- user content (memory snapshots, context files).
- """
+ """Rewrite the cached prompt's ``Model:``/``Provider:`` lines after a provider switch.
+
+ Not persisted: the stored row keeps the primary's labels so a restored primary replays a
+ byte-identical prompt (prefix cache intact). Only the LAST occurrence of each line is touched —
+ earlier matches may be user content (memory snapshots, context files)."""
sp = getattr(agent, "_cached_system_prompt", None)
if not isinstance(sp, str) or not sp:
return