Skip to content

feat(weixin): prioritize final replies over transient progress - #89407

Open
Akie-Star wants to merge 1 commit into
NousResearch:mainfrom
Akie-Star:fix/weixin-final-response-priority
Open

Akie-Star wants to merge 1 commit into
NousResearch:mainfrom
Akie-Star:fix/weixin-final-response-priority

Conversation

@Akie-Star

Copy link
Copy Markdown

Summary

  • add an opt-in platforms.weixin.extra.final_response_priority transport gate
  • mark tool progress, interim commentary (including GatewayStreamConsumer), background-review notifications, and Weixin fallback heartbeats as transient_progress
  • preserve final replies and the existing lifecycle/status/approval/clarify/error metadata paths
  • distinguish an intentionally suppressed progress send from a message that actually reached the platform, so delivery reconciliation can never suppress an identical final reply
  • document the option in the English and Simplified Chinese Weixin guides

Why

Weixin/iLink cannot edit ordinary chat bubbles and has a tight send budget. In a shared Desktop/Weixin session, routine progress can consume that budget before the canonical final reply is ready. The adapter needs an explicit, opt-in boundary that drops only messages the gateway has classified as transient, before connection checks or any iLink call.

This complements #89180, which suppresses periodic cross-process lease-wait refreshes on non-editing chat adapters. It does not duplicate or modify that lease-refresh logic.

Delivery semantics

  • The option defaults to false; existing Weixin behavior is unchanged.
  • Suppression requires metadata to be a dictionary and metadata["transient_progress"] is True. Values such as False, 1, or "true" are not suppressed.
  • A suppressed send returns success=True to acknowledge an intentional no-op and prevent generic progress retries, plus raw_response.suppressed=true to state that no platform message was created.
  • GatewayStreamConsumer excludes suppressed commentary from its delivered-text ledger. If commentary text is later reused as the final reply, the final still reaches iLink.
  • Existing positional GatewayStreamConsumer construction remains compatible; the new optional metadata argument is appended after all existing parameters.

Tests

Local Windows verification:

280 passed, 2 deselected
81 passed, 1 xfailed (existing suppression/duplicate-reply matrix)

The two deselected cases are pre-existing Windows Path.as_uri() backslash-encoding assertions unrelated to this change. Focused regressions cover:

  • adapter call counts for enabled/disabled priority mode
  • exact-boolean metadata boundaries, including non-dict input
  • streamed commentary metadata vs final metadata
  • suppressed commentary followed by an identical final reply
  • legacy positional constructor compatibility
  • Slack/thread routing metadata preservation

Related: #89166, #21126
Complements: #89180

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter area/config Config system, migrations, profiles P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 18, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

Well-engineered quota-preservation feature: the gateway stamps only genuinely non-final sends via one shared helper, the Weixin adapter's suppression is strictly gated on is True (junk-value matrix tested), the stream consumer gains a separate commentary_metadata lane so finals keep clean metadata, and — the subtle part most implementations miss — a suppressed commentary send never enters _delivered_commentary_texts, so it can't accidentally suppress the final reply whose text matches (that exact scenario has its own test). Docs in both locales spell out what stays deliverable. Items:

  • gateway/platforms/weixin.py:1922 — nit — suppressing long-running heartbeats means hours of silence on an opted-in adapter; consider having the suppression path bump a counter surfaced in status output (progress_suppressed: N) so "is it still alive?" remains answerable without re-enabling progress.

  • gateway/run.py:5347 — nit — _interim_assistant_cb now wraps every interim send in _transient_progress_metadata(...); the helper allocates a fresh dict per call — fine at this frequency, just noting it's on the streaming hot path.

No blocking issues found.

— reviewer-b (automated review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/wecom WeCom / WeChat Work adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants