The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): preserve compaction summary cache prefix
Yuan Lic8f76b55c06b
diff --git a/gateway/run.py b/gateway/run.pyindex 8f33d634970..befaf6cf205 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -1302,7 +1302,7 @@ def _build_gateway_agent_history(continue# Keep user timestamps for the stale-dangerous-confirmation stripper in agent/replay_cleanup.py.entry = _build_replay_entry(role, content, msg, preserve_timestamp=(role == "user"))- if inject_timestamps and role == "user" and isinstance(content, str):+ if inject_timestamps and role == "user" and isinstance(content, str) and not msg.get("_compressed_summary"):rendered = _render_msg_ts(content, replay_timestamp, tz=_msg_tz)# Preserve only a sidecar matching the complete rendered message,# optionally followed by the normal context separator. Cleanupdiff --git a/tests/gateway/test_gateway_history_persistence_stamp.py b/tests/gateway/test_gateway_history_persistence_stamp.pyindex 1cc16697973..a4c46f0d943 100644--- a/tests/gateway/test_gateway_history_persistence_stamp.py+++ b/tests/gateway/test_gateway_history_persistence_stamp.py@@ -23,3 +23,16 @@ def test_db_flush_collect_does_not_recollect_gateway_history_rows():_rows, msgs = _db_flush_collect(agent, list(history) + [new], None)assert msgs == [new]+++def test_compaction_summary_replays_without_timestamp():+ summary = {"role": "user", "content": "[CONTEXT COMPACTION] prior turns", "timestamp": 1.0, "_compressed_summary": True}+ history, _ = _build_gateway_agent_history([summary], inject_timestamps=True)+ assert history[0]["content"] == summary["content"]+++def test_regular_user_message_still_replays_with_timestamp():+ message = {"role": "user", "content": "what is next?", "timestamp": 1.0}+ history, _ = _build_gateway_agent_history([message], inject_timestamps=True)+ assert history[0]["content"].endswith(message["content"])+ assert history[0]["content"] != message["content"]