The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): gate record-less visible-text match on _already_sent
teknium146e7ad8e12bf
diff --git a/gateway/stream_consumer.py b/gateway/stream_consumer.pyindex 0cc69e1722b..65572c1b660 100644--- a/gateway/stream_consumer.py+++ b/gateway/stream_consumer.py@@ -668,7 +668,11 @@ class GatewayStreamConsumer:# does not contain the completed response has demonstrably NOT# delivered it (first-edit prefix, mid-stream truncation) — the# flag alone must not suppress the corrective send.- if self.has_delivered_text(final_text):+ # ``_already_sent`` gates the visible-text match: draft frames+ # set ``_last_sent_text`` for dedupe but are ephemeral (they+ # deliberately do not set ``_already_sent``), so draft-only+ # visibility must not count as durable delivery.+ if self._already_sent and self.has_delivered_text(final_text):return True# The one legitimately ambiguous case keeps legacy trust: a# timed-out full-final send may have reached the platformdiff --git a/tests/gateway/test_silent_partial_delivery_95382.py b/tests/gateway/test_silent_partial_delivery_95382.pyindex ed602ae7c5b..1f410637714 100644--- a/tests/gateway/test_silent_partial_delivery_95382.py+++ b/tests/gateway/test_silent_partial_delivery_95382.py@@ -74,6 +74,7 @@ def _make_consumer(adapter=None, **overrides):consumer._stream_ledger = ""consumer._initial_reply_to_id = Noneconsumer.metadata = None+ consumer._already_sent = Truefor key, value in overrides.items():setattr(consumer, key, value)return consumerdiff --git a/tests/gateway/test_stale_finalize_suppression.py b/tests/gateway/test_stale_finalize_suppression.pyindex bc833a1fc3d..679e4f7e3e1 100644--- a/tests/gateway/test_stale_finalize_suppression.py+++ b/tests/gateway/test_stale_finalize_suppression.py@@ -382,6 +382,7 @@ class TestDeliveredFinalMatches:def test_no_record_but_visible_final_returns_true(self):"""Ambiguous-dedup control: visible text equals the final answer."""consumer = _consumer()+ consumer._already_sent = Trueconsumer._last_sent_text = FULL_RESPONSEassert consumer.delivered_final_matches(FULL_RESPONSE) is True