The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(telegram): accept the update claim when a retired adapter forwards a hold
kshitijk4poord87a031fe144
diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.pyindex 0758bf9e51a..dd04f470795 100644--- a/plugins/platforms/telegram/adapter.py+++ b/plugins/platforms/telegram/adapter.py@@ -820,8 +820,10 @@ class TelegramAdapter(BasePlatformAdapter):"[Telegram] Discarding inbound under non-retryable fatal (%s, %d chars)", where, len(getattr(event, "text", None) or ""))returnsuccessor = getattr(self, "_held_inbound_successor", None)- if successor is not None and successor() is not None: # retired by a runner rebuild (#132829)- successor()._adopt_held_event(event, where=f"{where}-forwarded", schedule=schedule)+ target = successor() if successor is not None else None+ if target is not None: # retired by a runner rebuild (#132829)+ self._accept_update() # the claim being dispatched is ours, not the successor's+ target._adopt_held_event(event, where=f"{where}-forwarded", schedule=schedule)returnheld = getattr(self, "_held_inbound_events", None)if held is None:diff --git a/tests/gateway/test_telegram_text_batching.py b/tests/gateway/test_telegram_text_batching.pyindex 2e2a5162c45..0c2a045b66a 100644--- a/tests/gateway/test_telegram_text_batching.py+++ b/tests/gateway/test_telegram_text_batching.py@@ -198,7 +198,11 @@ class TestHoldInboundAcrossReconnect:@pytest.mark.asyncioasync def test_late_teardown_salvage_on_retired_adapter_reaches_replacement(self):"""Teardown of a rebuilt-away adapter can salvage a batch after the replacement drained (#132829)."""+ from contextvars import ContextVar+ from plugins.platforms.telegram.update_admission import _Claim+old, new = _make_adapter(), _make_adapter()+ old._update_admission = ContextVar("claim", default=_Claim("1:1", None))old._mark_disconnected()new.adopt_held_inbound(old)old._pending_text_batches["k"] = _make_event("late-salvage")@@ -209,6 +213,7 @@ class TestHoldInboundAcrossReconnect:old.handle_message.assert_not_called()assert [c.args[0].text for c in new.handle_message.call_args_list] == ["late-salvage"]assert old._held_inbound_events == []+ assert old._update_admission.get().accepted # receipt recorded: no replay after restart@pytest.mark.asyncioasync def test_flush_during_disconnect_holds_popped_event(self):