Skip to content

The agent that grows with you

test(compressor): use ABSORBED_MESSAGE_UIDS and _template_visible_role in the replay-uid test

kshitijk4poord40c6c646b26
diff --git a/tests/agent/test_cron_inflight_prompt_reappend.py b/tests/agent/test_cron_inflight_prompt_reappend.py
index 8f34d1182b5..7c52a31a7ff 100644
--- a/tests/agent/test_cron_inflight_prompt_reappend.py
+++ b/tests/agent/test_cron_inflight_prompt_reappend.py
@@ -364,7 +364,12 @@ def test_flagged_scaffolding_row_is_never_the_inflight_task():
def test_replay_replaces_surviving_user_row_with_same_message_uid():
"""A protected copy of the in-flight request must not remain active beside its replay."""
- from agent.context_compressor import _INFLIGHT_TASK_REPLAY_HEADER, COMPRESSED_SUMMARY_METADATA_KEY
+ from agent.context_compressor import (
+ _INFLIGHT_TASK_REPLAY_HEADER,
+ COMPRESSED_SUMMARY_METADATA_KEY,
+ _template_visible_role,
+ )
+ from agent.message_metadata import ABSORBED_MESSAGE_UIDS
uid = "request-uid"
carrier = {
@@ -378,7 +383,7 @@ def test_replay_replaces_surviving_user_row_with_same_message_uid():
)
def holders(rows):
- return [m for m in rows if uid == m.get("message_uid") or uid in m.get("_absorbed_message_uids", ())]
+ return [m for m in rows if uid == m.get("message_uid") or uid in m.get(ABSORBED_MESSAGE_UIDS, ())]
matching = holders(out)
assert len(matching) == 1
@@ -390,11 +395,7 @@ def test_replay_replaces_surviving_user_row_with_same_message_uid():
messages[1] = {**messages[1], "message_uid": uid}
compressed = _compress(messages)
assert len(holders(compressed)) == 1
- visible = [
- m["role"]
- for m in compressed[1:]
- if not (m["role"] == "tool" or (m["role"] == "assistant" and m.get("tool_calls")))
- ]
+ visible = [r for r in map(_template_visible_role, compressed[1:]) if r is not None]
assert visible[0] == "user", visible
assert all(a != b for a, b in zip(visible, visible[1:])), visible
assert JOB_SENTINEL in _text(compressed[_handoff_idx(compressed)]).split(_SUMMARY_END_MARKER)[-1]