fix(gateway): serialize startup auto-resume before inbound - #46074
Conversation
Verification: LGTM — clean startup-restore serializationReviewed the full diff. The race condition is clear: platform adapters start receiving inbound messages as soon as they connect, but restart-interrupted sessions aren't auto-resumed until The fix introduces a startup-restore gate that:
The Test coverage is solid — two async tests covering the gate-queue and wait-then-drain scenarios. The early-exit path (startup failure → Also bundled: Telegram rich messages default-on (removes |
9402bd4 to
9dc6804
Compare
🔎 Lint report:
|
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/gateway/test_restart_resume_pending.py:1245: [invalid-assignment] invalid-assignment: Object of type `def fake_handle_message(event: MessageEvent) -> CoroutineType[Any, Any, None]` is not assignable to attribute `handle_message` of type `def handle_message(self, event: MessageEvent) -> CoroutineType[Any, Any, None]`
✅ Fixed issues: none
Unchanged: 5725 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
…rch#46074) Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have completed, preventing duplicate agents for the same session after a restart.
Summary
Gateway startup now queues real inbound messages until restart-interrupted auto-resume turns have been scheduled and completed, preventing duplicate agents for the same session after a restart.
Changes
gateway/run.py: adds a startup restore gate, tracks startup auto-resume tasks, waits for their adapter-level processing tasks, then drains queued inbound messages in order.tests/gateway/test_restart_resume_pending.py: covers real inbound queuing during restore and verifies queued messages replay only after the synthetic resume turn finishes.Validation
py_compile gateway/run.py tests/gateway/test_restart_resume_pending.pyscripts/run_tests.sh tests/gateway/test_restart_resume_pending.pyscripts/run_tests.sh tests/gateway/test_platform_reconnect.py tests/gateway/test_restart_resume_pending.pyFixes #45682.
Infographic