dsad
0fb46b8185
fix(agent): keep the compaction summary when the turn-end override rewrites the user row
...
`_apply_persist_user_message_override` replaces the anchored user message's
content with the clean transcript text. Its DB-write twin refuses to do that
for a compaction-merged row, and says why:
# Preflight compaction can re-anchor the override index at a message
# whose content was MERGED with the compaction summary
# (merge-summary-into-tail). Overwriting that with the clean gateway text
# would silently drop the summary from the durable transcript.
... and not msg.get(COMPRESSED_SUMMARY_METADATA_KEY)
The live mutation has no such guard, and `finalize_turn` runs it FIRST -- it
calls `_apply_persist_user_message_override(messages)` and only then
`_persist_session(...)`. So the row is already clobbered by the time the
DB-side guard looks at it, and the clobbered list is also what is returned as
the continuation history the next turn is built from.
The anchor lands on the merged row by design, not by accident:
`reanchor_current_turn_user_idx` prefers the last user row whose content
matches this turn's text and "fall[s] back to the last user message when no
exact match survives (merge-summary-into-tail rewrites the content ...)" --
after a merge the exact match cannot survive, so the fallback selects exactly
the merged row.
Effect: on the turn a compaction fires, the `[MERGED PRIOR CONTEXT]` summary --
the entire pre-compaction conversation -- is deleted from the history the
session continues from. It is silent, there is no error, and the archived
pre-compaction turns are already rotated away. The durable child row still has
the summary, so the live session and a later `/resume` now replay different
bytes for the same row.
Add the same guard to the live path. The paired timestamp override is
unrelated and still applies.
Both halves of this invariant are now covered:
`TestFlushCompressedSummaryOverrideGuard` already asserted it for the DB write;
the two new tests assert it for the in-memory path, plus a negative control
that an ordinary turn is still cleaned in place.
2026-07-26 19:30:08 -07:00
..
2026-07-20 13:43:36 -04:00
2026-07-24 15:54:08 -07:00
2026-07-14 03:23:19 -07:00
2026-07-26 19:29:51 -07:00
2026-07-01 01:36:34 -07:00
2026-06-27 19:14:43 -07:00
2026-07-20 08:47:55 -07:00
2026-06-08 09:36:38 -07:00
2026-06-17 13:20:29 +05:30
2026-06-23 23:59:40 -07:00
2026-07-04 15:16:13 +05:30
2026-06-10 20:45:16 -07:00
2026-06-10 20:45:16 -07:00
2026-07-24 15:54:38 -07:00
2026-07-26 19:30:08 -07:00
2026-07-06 12:46:20 -07:00
2026-06-26 19:15:18 -07:00
2026-07-25 14:58:04 -07:00
2026-07-04 15:44:50 -07:00
2026-05-28 22:26:25 -07:00
2026-06-26 11:21:05 +05:30
2026-07-15 07:47:18 -07:00
2026-06-27 21:22:49 -07:00
2026-07-01 17:00:30 +05:30
2026-07-02 04:51:56 +05:30
2026-05-29 00:28:02 -07:00
2026-07-25 12:26:28 -07:00
2026-07-16 04:23:12 -07:00
2026-06-29 01:27:10 -07:00
2026-07-06 12:46:20 -07:00
2026-07-05 19:23:26 -07:00
2026-07-17 09:08:30 -07:00
2026-07-02 01:09:37 -07:00
2026-06-14 02:09:16 -07:00
2026-06-07 02:02:40 -07:00
2026-05-28 22:26:25 -07:00
2026-07-21 13:54:11 -05:00
2026-05-18 10:14:38 -07:00
2026-07-23 11:45:07 -07:00
2026-07-20 03:27:38 -07:00
2026-07-08 01:51:05 +05:30
2026-07-18 19:38:21 +05:30
2026-07-22 18:08:59 -05:00
2026-07-18 14:30:24 +05:30
2026-07-27 01:49:43 +05:30
2026-07-05 14:00:20 -07:00
2026-07-18 21:20:48 -04:00
2026-06-27 11:43:08 -07:00
2026-07-22 06:57:22 -07:00
2026-06-25 12:24:34 -05:00
2026-07-17 06:49:47 -07:00
2026-07-22 12:02:40 -05:00
2026-05-28 22:26:25 -07:00
2026-07-06 12:46:20 -07:00
2026-07-15 09:47:37 -07:00
2026-07-17 13:44:12 -07:00
2026-07-17 04:46:59 -07:00
2026-06-30 00:59:59 -05:00
2026-07-14 02:19:40 +05:30
2026-07-22 08:11:40 -07:00
2026-07-11 22:59:49 +05:30
2026-07-23 08:19:14 -07:00
2026-07-22 16:58:35 -07:00
2026-07-23 08:08:48 -07:00
2026-07-24 15:57:09 -07:00
2026-07-22 08:13:41 -07:00
2026-07-25 22:47:07 -07:00
2026-06-21 11:34:47 -07:00
2026-07-15 12:28:09 -07:00
2026-06-20 21:32:30 -07:00
2026-06-25 12:56:05 -07:00
2026-07-22 06:56:42 -07:00
2026-07-22 11:19:37 +05:30
2026-07-24 16:00:34 -07:00
2026-07-08 11:56:17 -07:00
2026-07-22 08:10:47 -07:00
2026-07-22 11:46:05 +05:30
2026-05-28 22:26:25 -07:00
2026-07-15 09:47:04 -07:00
2026-07-20 11:58:50 +05:30
2026-07-22 06:57:22 -07:00
2026-07-05 21:42:19 +05:30
2026-07-26 18:06:21 -07:00
2026-06-07 22:09:45 -07:00
2026-07-22 06:56:53 -07:00
2026-07-23 16:27:06 -07:00
2026-06-11 13:57:13 -07:00
2026-07-22 06:56:53 -07:00
2026-07-23 17:03:49 -07:00
2026-07-14 02:19:40 +05:30
2026-07-23 19:44:35 -07:00
2026-07-23 19:44:35 -07:00
2026-07-23 16:44:12 -07:00
2026-07-24 21:20:52 -05:00
2026-06-30 00:19:49 -07:00
2026-07-24 17:10:39 -07:00
2026-07-17 13:08:46 -04:00
2026-07-13 23:20:48 +05:30
2026-07-16 06:14:56 -07:00
2026-07-12 03:00:53 -07:00
2026-07-24 22:58:47 +05:30
2026-07-24 15:50:36 -07:00
2026-07-23 09:31:58 -07:00
2026-06-12 01:06:46 -07:00
2026-06-06 13:18:18 +05:30
2026-07-23 01:28:58 -05:00
2026-06-06 13:18:18 +05:30
2026-07-18 14:30:24 +05:30
2026-07-11 11:07:34 +05:30
2026-05-28 22:26:25 -07:00
2026-07-18 02:31:20 -07:00
2026-07-05 13:42:46 -07:00
2026-05-28 22:26:25 -07:00
2026-07-10 18:32:32 +05:30
2026-06-13 02:01:09 -07:00
2026-07-12 23:30:52 -07:00
2026-06-25 00:17:17 -07:00
2026-07-23 17:57:33 +05:30
2026-07-10 19:14:06 +05:30
2026-05-28 22:26:25 -07:00
2026-07-18 12:28:59 -07:00
2026-07-23 17:38:05 +05:30
2026-07-23 07:25:08 -07:00
2026-07-18 12:54:58 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-06-20 10:46:01 -07:00
2026-06-02 14:03:37 +10:00
2026-07-16 00:18:38 -07:00
2026-05-28 22:26:25 -07:00
2026-06-02 11:29:24 +10:00
2026-07-17 05:45:12 -07:00
2026-07-01 01:02:35 -07:00
2026-07-19 14:58:59 +05:30
2026-07-05 13:44:33 -07:00
2026-05-28 22:26:25 -07:00
2026-07-23 17:26:24 -07:00
2026-07-17 04:54:06 -07:00
2026-07-23 16:58:06 -07:00
2026-07-22 16:51:01 -04:00
2026-07-23 08:08:48 -07:00
2026-07-22 09:14:11 -07:00
2026-07-23 08:32:09 -07:00
2026-07-11 05:59:42 -07:00
2026-06-30 03:20:11 -07:00
2026-05-28 00:20:11 -07:00
2026-07-14 16:47:33 +05:30
2026-07-19 12:21:59 -07:00
2026-05-23 17:38:19 -07:00
2026-06-30 16:56:01 -07:00
2026-06-30 11:54:16 -05:00
2026-07-01 16:25:48 -05:00
2026-06-30 15:16:25 -05:00
2026-07-16 07:57:51 -07:00
2026-06-05 10:18:10 +10:00
2026-07-23 08:19:14 -07:00
2026-07-05 13:42:46 -07:00
2026-07-17 04:55:58 -07:00
2026-07-09 03:21:54 +05:30
2026-07-24 13:00:53 +05:30
2026-06-08 02:18:59 -07:00
2026-06-16 10:37:37 -07:00
2026-05-28 22:26:25 -07:00
2026-06-22 07:00:42 -07:00
2026-06-19 15:23:41 +08:00
2026-07-20 02:25:44 -07:00
2026-07-04 20:59:02 +05:30
2026-07-01 06:02:33 -07:00
2026-07-23 16:17:27 -07:00
2026-07-23 18:11:57 -07:00
2026-07-23 18:40:09 -07:00
2026-07-15 00:11:04 -07:00
2026-07-23 18:40:09 -07:00
2026-07-23 11:20:54 -07:00
2026-07-23 16:17:27 -07:00
2026-06-30 03:39:50 -07:00
2026-07-01 04:07:46 -07:00
2026-06-30 03:27:12 -07:00
2026-07-09 14:08:44 +05:30
2026-07-23 11:21:04 -07:00
2026-05-29 23:45:05 -07:00
2026-07-20 11:05:52 -07:00
2026-07-02 17:05:05 +05:30
2026-07-09 21:10:07 -07:00
2026-06-06 13:18:18 +05:30
2026-07-18 14:30:24 +05:30
2026-06-04 01:19:28 +05:30
2026-07-24 17:10:39 -07:00
2026-06-07 08:36:48 -07:00
2026-06-23 08:01:50 +00:00
2026-06-30 15:41:44 -05:00
2026-06-25 00:44:53 -05:00
2026-07-08 06:18:18 -07:00
2026-06-18 14:28:01 -07:00
2026-05-28 22:26:25 -07:00
2026-07-25 22:15:00 -07:00
2026-07-20 02:25:57 -07:00
2026-06-25 01:20:23 +05:30
2026-07-23 16:23:57 -07:00
2026-07-23 16:44:12 -07:00
2026-07-23 16:44:12 -07:00
2026-07-09 14:08:44 +05:30
2026-07-23 11:55:01 -07:00
2026-07-24 16:01:38 -07:00
2026-07-23 07:25:33 -07:00
2026-05-28 22:26:25 -07:00
2026-07-10 05:41:59 -05:00
2026-07-19 16:32:20 -07:00
2026-07-20 02:25:57 -07:00
2026-07-11 05:41:58 -07:00
2026-06-27 20:04:45 -07:00
2026-06-11 13:57:13 -07:00
2026-07-21 12:11:31 +05:30
2026-07-16 04:32:23 -07:00
2026-05-24 18:10:47 -07:00
2026-07-22 04:39:17 -07:00
2026-07-22 10:00:39 +05:30
2026-07-16 07:28:07 -07:00
2026-05-28 22:26:25 -07:00
2026-06-30 00:59:29 -05:00
2026-07-05 14:48:11 -07:00
2026-06-26 19:15:18 -07:00
2026-07-14 16:41:21 +05:30
2026-07-26 02:58:12 -05:00
2026-07-17 04:52:02 -07:00
2026-07-22 07:00:16 -07:00
2026-06-13 21:14:32 -07:00
2026-07-02 04:51:56 +05:30
2026-06-10 20:21:38 -05:00
2026-07-17 18:31:09 +00:00
2026-05-18 10:53:08 -07:00
2026-05-28 22:26:25 -07:00
2026-07-01 04:55:15 -07:00
2026-05-28 22:26:25 -07:00
2026-07-22 08:11:09 +05:30
2026-07-15 00:10:22 -07:00
2026-07-24 15:48:23 -07:00
2026-07-24 15:48:23 -07:00
2026-07-24 16:01:38 -07:00
2026-07-24 16:01:38 -07:00
2026-07-16 01:07:29 +05:30
2026-06-25 19:00:48 -07:00
2026-07-17 20:55:24 +00:00
2026-07-26 02:58:16 -05:00
2026-06-28 02:44:06 -07:00
2026-07-11 05:41:58 -07:00
2026-07-20 13:04:12 -07:00
2026-07-18 02:08:39 -07:00
2026-07-11 05:41:58 -07:00
2026-07-07 15:12:49 -07:00
2026-07-14 02:59:39 +05:30
2026-05-24 18:04:54 -07:00
2026-07-23 08:43:21 -07:00
2026-07-24 16:00:34 -07:00
2026-06-22 13:57:59 -07:00
2026-07-19 07:27:10 +05:30
2026-06-23 23:52:28 -07:00
2026-07-20 11:42:29 -04:00
2026-07-19 01:09:29 -07:00
2026-07-22 12:02:40 -05:00
2026-07-26 17:47:51 -07:00
2026-07-16 04:23:12 -07:00
2026-07-16 04:23:12 -07:00
2026-07-23 11:45:07 -07:00
2026-07-24 15:55:08 -07:00
2026-07-20 11:42:29 -04:00
2026-07-20 11:42:29 -04:00
2026-07-12 04:32:52 -07:00
2026-06-30 00:59:29 -05:00
2026-07-02 06:07:56 +05:30
2026-07-14 02:59:39 +05:30
2026-05-24 15:01:28 -07:00