fix(gateway): stop lease-wait refreshes flooding non-editing chat adapters - #89180
fix(gateway): stop lease-wait refreshes flooding non-editing chat adapters#89180liuhao1024 wants to merge 1 commit into
Conversation
…pters Cross-process session turn lease waits emit a periodic 'Still waiting' refresh roughly every 15s. On adapters without send_or_update_status the status path falls back to a plain send, so each refresh landed as another standalone chat message — eight messages for a two-minute wait on WeCom/Weixin/QQ/Signal-class adapters, drowning the eventual delivery. Extract the refresh wording into a module-level template constant and derive a compile-once matcher from it, then suppress the periodic refresh in the status callback when the adapter cannot update the status in place. Adapters that can (Telegram, Slack) keep refreshing the existing bubble. The initial wait notice and the lease-timeout warning use different wording and are always delivered.
Reviewed by reviewer-e (AI automated review). Clean fix for notification flooding with the right single-source discipline: the refresh wording moves into |
Rebuild NousResearch#100386 as an append-only composition instead of replacing contributor history with a single-author squash. The second-parent train preserves: - David Dudok de Wit's NousResearch#97846/NousResearch#98073 continuity and messaging commits through exact source head 6fb588d. - jugol's source-authored NousResearch#96162 forward port at 22b26d0. - liuhao1024's NousResearch#89180 lease-refresh fix through the adapted source-authored replay 6a74634. The lease-status extraction at e3ec744 keeps gateway/run.py from growing, keeps run_agent.py shrinking, and preserves the original import seams and behavior. This merge commit changes no bytes relative to its second parent. Its first parent is the published NousResearch#100386 head, so the correction is forward-only: no force-push, rebase, amend, or source-history rewrite. Related: NousResearch#97681 Fixes: NousResearch#89166
What does this PR do?
While a durable session's cross-process turn lease is held by another Hermes process, the waiting process emits an initial "Another Hermes process is using this session…" notice once, then a periodic "Still waiting… (Ns)" refresh roughly every 15s. That refresh only makes sense on surfaces that can update the initial notice in place. On adapters without
send_or_update_status(WeCom, Weixin, QQ, Signal, … — allSUPPORTS_MESSAGE_EDITING = False) the status path falls back to a plainadapter.send, so every refresh landed as another standalone chat message: a two-minute wait produced eight separate messages that drowned the eventual delivery.This PR suppresses the periodic refresh when the adapter cannot update the status in place:
_COMPRESSION_PROGRESS_STATUS_RE, fix(gateway): suppress routine pre-API compression chatter on chat platforms #69550) and gates it on adapter capability in the status callback.The initial wait notice and the lease-timeout warning use different wording and are always delivered, on every platform.
Related Issue
Fixes #89166
Type of Change
Changes Made
SESSION_TURN_LEASE_WAIT_REFRESH_STATUS_TEMPLATE: the periodic refresh wording as a format template; the emit site now formats it instead of an inline f-string._session_turn_lease_refresh_re(): lazy compile-once regex derived from that template via the existing_status_template_to_regexhelper (lazy because this module never imports run_agent at module scope)._should_suppress_lease_wait_refresh(adapter, message): True only when the adapter has no callablesend_or_update_statusAND the message is the periodic refresh._status_callback_sync: early-returns (with a debug log) when that helper says the refresh would flood this adapter.Related but distinct from #12610 (which suppresses ALL lifecycle events on the email platform by platform enum): this change is scoped to the single periodic lease-wait refresh template and keys off adapter capability, so every other lifecycle status keeps flowing to non-editing platforms.
How to Test
Manual repro from the issue: open the same durable session from Desktop and send a DM through a WeCom/Weixin gateway while Desktop holds the turn; previously each 15s tick posted a new chat message, now only the single initial wait notice appears (and the lease-timeout warning if the wait exceeds the budget).
Fail-on-main check: with the source changes stashed, the new suite fails at collection (the gate and template constant do not exist on main).
Checklist