Skip to content

The agent that grows with you

test(gateway): trim replay-stamp tests to the flush invariant

kshitijk4poorcb3142d3257b
diff --git a/gateway/run.py b/gateway/run.py
index 2faf45ddb93..7fd9b016334 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -1148,6 +1148,8 @@ def _build_replay_entry(
entry[_rkey] = _rval
if preserve_timestamp and msg.get("timestamp"):
entry["timestamp"] = msg["timestamp"]
+ # Replay rewrites are view-only: keep the durable-row stamp so marker-only
+ # flushes skip rows already in state.db (#121462/#123462).
if msg.get("_db_persisted"):
entry["_db_persisted"] = True
return entry
diff --git a/tests/gateway/test_gateway_history_persistence_stamp.py b/tests/gateway/test_gateway_history_persistence_stamp.py
index 86ceaf4fba0..949e1fb5547 100644
--- a/tests/gateway/test_gateway_history_persistence_stamp.py
+++ b/tests/gateway/test_gateway_history_persistence_stamp.py
@@ -3,21 +3,6 @@ from agent.session_persistence import _db_flush_collect
from gateway.run import _build_gateway_agent_history
-def test_build_gateway_agent_history_preserves_db_persisted_marker():
- """Verify plain user and assistant rows preserve the _db_persisted marker (#123462)."""
- stored = [
- {"role": "user", "content": "first", "_db_persisted": True, "timestamp": 1.0},
- {"role": "assistant", "content": "reply", "_db_persisted": True},
- ]
- history, _ = _build_gateway_agent_history(stored)
-
- assert len(history) == 2
- assert history[0]["role"] == "user"
- assert history[0].get("_db_persisted") is True
- assert history[1]["role"] == "assistant"
- assert history[1].get("_db_persisted") is True
-
-
def test_db_flush_collect_does_not_recollect_gateway_history_rows():
"""Verify tool turn flushes do not re-append rebuilt user/assistant rows to state.db (#123462)."""
stored = [