kshitijk4poor
820d3ca65d
fix(agent): send-path canonicalization is prefix-only, clock is admission time, corrupt stamps fail closed
...
Follow-up to the two cherry-picked commits from #105308 (@JoaoMarcos44), closing the
three blockers raised on that thread plus one regression the salvage found:
- Prefix-only on the send path. build_api_messages now canonicalizes only
messages[:current_turn_user_idx]; rows the current turn appended (its own tool
calls/results) pass through verbatim. Canonicalizing the live tail rewrote a block
the previous iteration had already sent whenever a tool result matched the
interrupt heuristic, which is exactly the mid-turn prefix rewrite this fix exists
to remove, and it also made the dangling-tail transform order-dependent on when
the user row was appended.
- Exact interrupt marker. is_interrupted_tool_result matched
"exit_code" + ("130" | "-1") + "interrupt" as substrings, so an ordinary
`grep KeyboardInterrupt` result next to a diff hunk header rewrote a terminal
result to an orphan notice (or dropped a read-only block). That heuristic was
tolerable at resume time only; it now runs per request. Match the executors'
bracketed markers ("[Command interrupted", "[execution interrupted") and nothing else.
- Admission-time clock. The frozen expiry clock was the input's platform-event
stamp, so a message queued 70 s before the turn ran kept a 129 s-old confirmation
live on the send path while replay expired it. _reset_per_turn_agent_state stamps
time.time() once at admission; the three other writes (bind identity, stage
message, build_api_messages write-back under suppress(Exception)) are gone.
- Fail closed on corrupt stamps. A present-but-unparseable timestamp (`"nan"`,
`"not_a_number"`) made strip_stale_dangerous_confirmations keep the confirmation
and its api_content sidecar. Coerce through hermes_cli.timefmt.coerce_epoch and
treat an unknowable age as expired; missing stamps (legacy rows) are still left
alone.
- Shape: drop the canonicalize_history_for_send alias (no consumer, never existed on
main), the `now=` kwarg (no production caller), and the getattr/hasattr rewrite of
_reset_per_turn_agent_state (only the test double needed it).
- Tests: 17 → 2 invariant tests. Real SessionDB round trip → canonicalize →
ChatCompletionsTransport bytes, equal to the send path with sidecars applied and
the durable list untouched, live tail preserved; admission-clock freeze across
iterations + corrupt-stamp fail-closed. Each is red under the matching mutation
(send path unpatched, whole-list canonicalization, per-request clock, fail-open,
loose heuristic).
2026-09-13 19:23:09 +05:30
..
2026-09-12 05:09:11 -07:00
2026-09-09 13:01:48 -07:00
2026-09-02 13:30:17 -07:00
2026-09-02 20:51:07 +05:30
2026-09-03 13:28:22 -07:00
2026-09-10 15:13:02 -04:00
2026-09-11 13:06:16 +05:30
2026-08-14 21:54:56 -07:00
2026-08-29 18:34:35 -07:00
2026-09-11 13:06:16 +05:30
2026-08-29 18:34:35 -07:00
2026-09-03 13:16:47 -07:00
2026-09-03 13:16:47 -07:00
2026-09-01 16:27:20 +05:30
2026-09-03 13:16:47 -07:00
2026-08-29 18:34:35 -07:00
2026-09-03 13:16:47 -07:00
2026-09-03 13:16:47 -07:00
2026-09-07 08:07:26 -07:00
2026-09-03 13:16:47 -07:00
2026-08-15 00:34:29 -07:00
2026-09-07 08:07:26 -07:00
2026-08-18 20:34:46 -04:00
2026-09-03 13:16:47 -07:00
2026-08-20 12:29:11 -05:00
2026-09-03 13:16:47 -07:00
2026-09-03 13:16:47 -07:00
2026-09-09 10:32:01 +05:30
2026-08-23 02:54:30 -07:00
2026-09-07 21:43:54 +05:30
2026-08-31 10:51:19 -07:00
2026-08-31 13:00:24 -07:00
2026-09-07 00:41:09 +05:30
2026-09-09 16:21:36 -07:00
2026-09-09 16:21:36 -07:00
2026-09-01 23:56:06 -07:00
2026-09-01 23:56:06 -07:00
2026-09-03 13:16:47 -07:00
2026-09-10 09:11:00 -07:00
2026-09-11 13:06:16 +05:30
2026-09-03 13:16:47 -07:00
2026-09-02 21:22:07 -07:00
2026-09-03 19:33:28 -07:00
2026-09-10 09:11:00 -07:00
2026-09-03 02:06:51 -07:00
2026-09-03 13:29:35 -07:00
2026-09-09 14:06:12 -07:00
2026-09-03 13:29:35 -07:00
2026-09-12 08:28:49 -07:00
2026-08-31 13:00:24 -07:00
2026-09-10 18:11:25 -07:00
2026-09-07 06:02:22 -07:00
2026-09-07 07:06:58 -07:00
2026-09-09 12:19:13 +05:30
2026-08-26 10:10:11 -07:00
2026-09-02 19:12:32 -07:00
2026-09-03 13:29:35 -07:00
2026-09-11 01:37:22 -07:00
2026-09-11 03:45:33 +05:30
2026-08-16 01:55:00 -07:00
2026-09-01 08:30:26 -07:00
2026-08-14 21:54:56 -07:00
2026-08-14 13:56:58 -07:00
2026-09-02 13:29:47 -07:00
2026-09-06 13:21:17 -07:00
2026-08-20 20:20:23 -07:00
2026-09-07 08:08:04 -07:00
2026-09-03 03:09:06 +05:30
2026-08-15 01:04:19 -07:00
2026-08-31 14:02:55 -07:00
2026-08-31 13:00:18 -07:00
2026-08-31 13:00:18 -07:00
2026-09-03 13:28:22 -07:00
2026-09-07 08:09:57 -07:00
2026-09-01 12:08:11 -07:00
2026-09-07 06:04:44 -07:00
2026-08-23 19:02:30 -07:00
2026-09-07 05:24:15 -07:00
2026-08-24 11:25:04 -07:00
2026-09-03 14:00:59 -07:00
2026-08-23 18:27:07 -07:00
2026-08-26 21:38:20 -07:00
2026-08-31 12:36:02 -07:00
2026-08-23 18:27:07 -07:00
2026-09-02 04:14:10 -07:00
2026-09-07 02:30:04 -07:00
2026-08-30 09:03:57 -07:00
2026-08-28 12:38:49 +05:30
2026-09-02 04:12:12 -07:00
2026-09-09 09:21:39 -07:00
2026-09-03 13:46:50 -07:00
2026-09-03 13:29:35 -07:00
2026-08-30 19:46:21 -07:00
2026-08-31 09:58:11 -07:00
2026-08-26 07:16:04 -07:00
2026-08-31 14:09:42 +05:30
2026-08-28 02:29:27 +05:30
2026-08-30 19:46:21 -07:00
2026-09-07 02:30:04 -07:00
2026-08-28 06:32:43 -07:00
2026-09-06 14:19:42 -07:00
2026-08-23 15:03:29 +05:30
2026-08-31 10:39:55 -07:00
2026-09-06 13:21:17 -07:00
2026-09-08 02:27:01 +05:30
2026-08-31 20:43:00 -05:00
2026-09-06 13:21:17 -07:00
2026-08-23 18:27:07 -07:00
2026-08-26 07:16:04 -07:00
2026-09-07 05:59:08 -07:00
2026-09-03 13:30:27 -07:00
2026-09-09 09:21:55 -07:00
2026-09-07 08:13:01 -07:00
2026-09-07 00:49:51 -07:00
2026-09-05 16:44:23 +05:30
2026-09-13 05:20:26 -07:00
2026-08-24 04:14:26 +05:30
2026-09-13 19:17:06 +05:30
2026-09-07 22:47:33 +05:30
2026-09-03 19:33:28 -07:00
2026-09-03 13:16:47 -07:00
2026-09-03 19:33:28 -07:00
2026-09-07 08:06:48 -07:00
2026-09-09 21:17:35 +05:30
2026-09-01 22:42:27 +05:30
2026-08-14 21:54:56 -07:00
2026-09-05 17:43:45 +05:30
2026-09-11 03:45:33 +05:30
2026-09-03 11:27:40 +05:30
2026-09-03 01:43:22 +05:30
2026-09-12 05:56:15 -07:00
2026-09-07 22:47:33 +05:30
2026-08-23 20:01:18 -07:00
2026-09-09 21:16:48 +05:30
2026-09-07 08:19:32 -07:00
2026-09-02 13:29:48 -07:00
2026-09-01 02:14:35 -07:00
2026-09-06 05:37:03 -07:00
2026-09-10 13:23:00 +02:00
2026-08-29 18:23:07 -07:00
2026-09-12 08:23:42 -07:00
2026-09-03 03:41:52 -07:00
2026-09-03 16:20:10 -07:00
2026-09-12 21:52:48 -07:00
2026-09-09 16:30:24 -07:00
2026-08-30 20:40:43 -07:00
2026-09-07 06:07:16 -07:00
2026-09-07 06:15:43 -07:00
2026-09-13 05:09:06 -07:00
2026-09-02 14:43:45 -07:00
2026-09-07 00:20:11 +05:30
2026-09-02 18:58:42 -07:00
2026-09-02 13:29:48 -07:00
2026-09-07 08:10:36 -07:00
2026-09-12 21:18:24 -07:00
2026-09-07 21:10:50 -07:00
2026-09-12 21:10:02 -07:00
2026-09-07 21:10:50 -07:00
2026-08-29 02:30:44 -07:00
2026-09-10 01:08:18 -07:00
2026-08-31 13:00:33 -07:00
2026-09-11 15:26:46 -07:00
2026-09-06 09:09:00 -07:00
2026-09-03 03:07:33 +05:30
2026-08-28 12:15:24 -07:00
2026-09-06 14:19:42 -07:00
2026-09-11 15:26:46 -07:00
2026-09-07 06:05:13 -07:00
2026-09-12 08:23:13 -07:00
2026-09-02 13:29:31 -07:00
2026-08-23 18:25:19 -07:00
2026-09-07 08:28:43 -07:00
2026-09-07 08:28:43 -07:00
2026-09-03 13:16:47 -07:00
2026-08-30 09:03:57 -07:00
2026-09-11 11:54:49 -07:00
2026-09-09 11:42:43 -07:00
2026-08-29 12:06:48 +05:30
2026-09-03 13:28:22 -07:00
2026-09-03 12:42:38 -07:00
2026-09-12 08:27:11 -07:00
2026-08-19 22:41:05 -07:00
2026-09-12 08:22:57 -07:00
2026-09-06 13:25:48 -07:00
2026-09-06 13:25:48 -07:00
2026-09-13 19:05:39 +05:30
2026-08-15 01:04:19 -07:00
2026-09-03 13:29:35 -07:00
2026-09-03 13:16:47 -07:00
2026-08-17 12:58:51 -07:00
2026-09-02 16:46:33 -07:00
2026-08-14 22:04:16 -07:00
2026-09-03 13:16:47 -07:00
2026-09-10 18:11:25 -07:00
2026-08-14 21:36:41 -07:00
2026-09-03 22:00:01 -07:00
2026-09-07 06:15:43 -07:00
2026-08-19 13:56:11 -05:00
2026-08-24 03:20:57 -07:00
2026-09-12 07:46:36 -07:00
2026-09-03 00:58:16 -07:00
2026-09-11 16:50:20 -07:00
2026-09-11 15:26:46 -07:00
2026-09-12 01:35:05 -07:00
2026-09-03 13:12:23 -07:00
2026-09-03 13:16:47 -07:00
2026-09-09 16:30:24 -07:00
2026-09-07 05:24:15 -07:00
2026-09-05 06:09:24 -07:00
2026-09-02 18:29:20 -07:00
2026-09-11 13:06:16 +05:30
2026-09-11 03:45:33 +05:30
2026-09-11 03:45:33 +05:30
2026-09-06 09:11:04 -07:00
2026-09-02 15:53:44 -07:00
2026-09-02 21:46:36 -07:00
2026-09-01 07:00:38 -07:00
2026-09-03 13:33:47 -07:00
2026-09-03 04:51:51 +05:30
2026-09-11 15:26:46 -07:00
2026-09-07 04:38:59 -07:00
2026-09-06 02:18:14 -07:00
2026-09-09 12:42:02 +05:30
2026-08-28 23:38:59 -05:00
2026-09-02 13:29:47 -07:00
2026-09-03 13:27:01 -07:00
2026-09-03 17:00:26 -07:00
2026-09-03 13:28:22 -07:00
2026-09-03 15:07:39 -07:00
2026-08-30 01:20:27 -07:00
2026-09-09 09:59:13 -07:00
2026-08-31 11:18:53 -07:00
2026-09-03 12:26:22 +05:30
2026-09-03 12:23:55 +05:30
2026-08-23 17:47:50 -07:00
2026-09-03 13:28:22 -07:00
2026-09-02 13:53:57 -07:00
2026-09-06 13:32:51 +05:30
2026-09-02 13:53:57 -07:00
2026-08-29 11:33:05 +05:30
2026-09-02 16:37:14 -07:00
2026-09-02 16:10:07 -07:00
2026-09-03 13:29:35 -07:00
2026-09-02 09:57:39 -07:00
2026-09-12 13:44:52 -07:00
2026-09-03 13:28:22 -07:00
2026-09-13 05:09:43 -07:00
2026-09-03 13:16:47 -07:00
2026-09-12 08:06:48 -07:00
2026-08-19 16:04:22 -07:00
2026-09-07 08:24:54 -07:00
2026-09-10 02:44:26 -07:00
2026-09-13 05:07:50 -07:00
2026-08-22 16:47:39 +02:00
2026-09-09 12:19:13 +05:30
2026-08-28 08:28:21 -04:00
2026-08-19 08:52:03 -07:00
2026-08-28 08:28:21 -04:00
2026-08-15 00:33:01 -07:00
2026-09-10 13:23:24 -07:00
2026-08-28 08:28:21 -04:00
2026-08-16 01:55:51 -07:00
2026-09-06 14:04:05 -07:00
2026-09-13 19:23:09 +05:30
2026-09-03 13:28:22 -07:00
2026-09-13 05:09:43 -07:00
2026-09-08 04:38:47 -07:00
2026-09-01 16:01:53 -04:00
2026-09-09 17:04:30 +05:30
2026-08-20 11:36:54 +05:30
2026-09-02 18:58:42 -07:00
2026-09-13 05:32:38 -07:00
2026-09-01 22:28:52 -07:00
2026-09-02 16:27:44 -07:00
2026-09-05 00:10:26 -07:00
2026-08-16 11:32:02 -07:00
2026-09-06 05:35:12 -07:00
2026-08-23 13:34:32 +05:30
2026-09-07 08:08:41 -07:00
2026-09-03 13:29:35 -07:00
2026-09-03 02:35:21 -07:00
2026-09-12 07:54:57 -07:00
2026-09-13 05:07:11 -07:00
2026-08-29 08:23:47 -07:00
2026-09-12 08:25:36 -07:00
2026-08-30 04:53:39 -07:00
2026-08-29 20:39:04 -07:00
2026-09-12 08:25:59 -07:00
2026-09-02 19:41:47 -07:00
2026-09-03 13:28:22 -07:00
2026-09-06 13:08:31 -07:00
2026-08-14 14:15:42 -07:00
2026-09-03 13:29:35 -07:00
2026-09-12 21:07:46 -07:00
2026-09-07 05:24:15 -07:00
2026-08-18 20:34:46 -04:00
2026-09-03 13:28:22 -07:00
2026-08-23 18:25:19 -07:00
2026-09-02 01:06:24 -07:00
2026-08-27 16:13:45 +05:30
2026-09-12 08:34:07 -07:00
2026-09-03 02:07:33 -07:00
2026-08-29 18:23:07 -07:00
2026-09-02 19:11:11 -07:00
2026-08-29 19:13:00 -07:00
2026-09-09 10:31:26 +05:30
2026-09-08 13:36:05 -07:00
2026-08-24 20:10:44 -07:00
2026-08-15 00:33:01 -07:00
2026-09-12 21:10:02 -07:00
2026-09-13 05:09:43 -07:00
2026-08-23 18:24:43 -07:00
2026-09-02 00:26:57 -07:00
2026-09-01 20:55:35 +05:30
2026-09-12 08:25:14 -07:00
2026-09-03 14:18:25 -07:00
2026-09-10 10:27:07 -07:00
2026-09-06 13:21:17 -07:00
2026-09-02 16:42:25 -07:00
2026-09-06 13:21:17 -07:00
2026-09-10 10:27:07 -07:00
2026-09-03 03:31:03 -07:00
2026-09-10 13:23:00 +02:00
2026-09-03 09:54:04 -07:00
2026-09-03 13:48:14 -07:00
2026-09-09 09:51:31 -07:00
2026-09-01 03:19:59 +05:30
2026-09-12 10:00:06 +05:30
2026-09-03 05:20:11 -07:00
2026-09-06 13:52:15 -07:00
2026-08-20 12:35:20 +05:30
2026-09-03 13:29:35 -07:00
2026-09-03 13:29:35 -07:00
2026-09-06 13:21:17 -07:00
2026-09-10 02:44:26 -07:00
2026-09-10 11:48:01 -07:00
2026-09-09 02:35:41 -07:00
2026-09-09 02:35:41 -07:00
2026-09-09 02:35:41 -07:00
2026-09-07 08:08:41 -07:00
2026-09-09 02:35:41 -07:00
2026-08-29 12:33:44 +05:30
2026-09-03 14:18:25 -07:00
2026-08-22 16:07:12 +05:30