Commit Graph

5 Commits

Author SHA1 Message Date
kshitijk4poor
f33b9dd07a test: drop the raw storage asserts from the writer invariant test
The get_session equality already proves the route commit kept the prompt
and that it still hydrates; the column/hash/system_prompts count checks
pinned the dedup layout, which test_session_system_prompt_dedup owns.
Also cut the module docstring to its first paragraph.
2026-09-27 00:35:39 +05:30
kshitijk4poor
5b3fbcaf71 test: trim the switch-invalidation suite to the two invariants
Keep the parametrized writer-trio test (goes red if any route writer
nulls the prompt again) and the compression-tip adoption-seam test.
Drop the three next-turn class tests: the reuse/rebuild/warn branches of
_restore_or_build_system_prompt are already covered by
test_system_prompt_restore.py, and the salvage bar is <=2 new tests.
2026-09-27 00:35:39 +05:30
Uttkarsh Tiwari
21b86ab13e fix(compression): drop the parent prompt cache when adopting a live child
_adopt_live_compression_child moves agent.session_id onto the live compression child,
but when the child's stored prompt fails _stored_prompt_matches_runtime the parent's
non-null _cached_system_prompt stayed in place. turn_context restores/rebuilds only
while that slot is None, so the child turn could send the parent session's prompt with
no validation. Clear the slot right after child confirmation, before the conditional
seed; a rejected tip then rebuilds through the canonical restore path and a matching
tip is still adopted verbatim.

The regression test now seeds a NON-NULL parent cache — the previous null-path-only
seed hid the leak — and asserts the rejected-tip agent carries session_id="child"
with the slot cleared (red on the previous head).

Review fix for #121843 (ehz0ah, agent/conversation_compression.py:1703).

(cherry picked from commit 531a5072ff4a2e74bd7003094786e32136d2545b)
2026-09-27 00:35:39 +05:30
teknium1
cd7f9d17d1 test: parametrize the writer trio, pin the adoption seam, fix the billing-route caller note
The three "commit keeps the snapshot" tests differed only in which writer ran; one
parametrized test carries the same assertions (including the dedup-row check, now applied to
all three). Adds the invariant for the compression-tip adoption reader: a moved route stays
unseeded, a matching one is adopted verbatim (red on the PR head before the previous commit).
update_session_billing_route is called from switch_model after the swap, not on provider
fallbacks; the module docstring said otherwise.

(cherry picked from commit 330e9b4509d044d8578c21eb769934d16f344904)
2026-09-27 00:35:39 +05:30
Uttkarsh
ae6e4428cb fix(state): stop nulling the stored system prompt on route commits
update_session_model (every /model commit), update_session_runtime_lock
and update_session_billing_route nulled the session's stored system
prompt snapshot unconditionally. The snapshot is a long-lived session's
provider cache prefix; nulling it makes the next turn take the broken-row
rebuild in _restore_or_build_system_prompt (the 'Stored system prompt
... is null' WARNING) and re-bills the whole prefix at ~0% cache.

The nulling predates _stored_prompt_matches_runtime, which now rebuilds
and re-persists exactly when the embedded Model:/Provider: footer is
stale and reuses the stored bytes otherwise. The DB-side nulling is
redundant for real switches and harmful for no-op route re-commits
(picker re-selects), runtime locks and billing-route writes.

Fixes #121840

(cherry picked from commit 07462e23c3b593d80546172a72f8385697c60c4c)
2026-09-27 00:35:39 +05:30