feat: auto-flush cached outbound messages + user-visible stuck/anomaly notices - #7
Open
xwh5 wants to merge 3 commits into
Open
feat: auto-flush cached outbound messages + user-visible stuck/anomaly notices#7xwh5 wants to merge 3 commits into
xwh5 wants to merge 3 commits into
Conversation
When WeChat's 10-consecutive-message send limit is hit, remaining outbound segments are cached in pendingOutbound and previously only delivered on the next user message or an explicit /next. Add wechat.autoFlushMs (default 60s, 0 disables): on the first cache hit the bridge arms a timer and flushes cached messages automatically when it elapses — no user message required. If the limit still holds after a flush (more than 10 segments cached), the timer re-arms for another round until everything is delivered. The flush waits for any in-flight outbound send on the same contextToken to settle first, so messages never reorder with an agent reply. The 10-msg-limit warning text now says messages will auto-resend when the feature is enabled, instead of asking for a manual /next.
- SessionManager: onNotify callback; the 5-minute stuck-turn timeout now tells the user the agent was unresponsive before force-finalizing - SessionManager: SSE event pipeline outages (reconnecting > 60s) send a warning, recovery sends an OK notice - monitor: WeChat-channel session expiry, repeated poll failures (backoff) and recovery are pushed to the user instead of only logs - bridge: wires both callbacks through sendReply (best-effort, contextToken falls back to the most recent user message) - tests: test-stuck-notices.mjs (stuck timeout, outage threshold, recovery, no-op when onNotify omitted); 588 tests pass
OpenCode servers retry failed model calls internally and emit session.status=retry; when the retry also fails the turn ends with zero output and the user sees only the WeChat typing indicator before silence (e.g. rate-limited or unpaid models). - AccumulatedTurn.retried flag set when session.status=retry arrives mid-turn - finalizeTurn: zero-output turn that was retried now sends "❌ Agent 请求失败…" instead of dropping the turn silently - tests: 2 new cases (retry-failure notice, no false positives for plain zero-output turns); 590 tests pass
Owner
|
@xwh5 我在本地拉了 PR head build,然后在真实微信里端到端试了 auto-flush 场景。 结果:失败。 触发 10 条限制后等了 60 秒,微信端没收到缓存的那批消息。 我有个疑问: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two user-experience fixes for the WeChat bridge:
Auto /next (auto-continue) — WeChat caps consecutive messages per turn at 10. Previously the user had to manually send
/nextto flush the cached remainder. Now the bridge automatically flushes cached outbound segmentswechat.autoFlushMs(default 60s) after the queue settles, and keeps re-arming while messages remain cached. Setwechat.autoFlushMs: 0to disable and keep the manual/nextbehavior.User-visible stuck/anomaly notices — Previously a stuck agent turn (5 min without events) was silently force-finalized and channel failures only showed in logs. Now:
⚠️ Agent 已 N 分钟无响应(可能卡住)…before the turn is ended⚠️ Agent 事件连接异常…; recovery sends✅ Agent 事件连接已恢复。Changes
src/config.ts: newwechat.autoFlushMsoption (default 60000, 0 disables)src/bridge.ts: auto-flush timer (scheduleAutoFlush/runAutoFlush), wired at all five cache points;msgLimitNotice()text now matches auto-flush state; wires bothonNotifycallbacks (session + monitor) throughsendReply(best-effort)src/server/session.ts:onNotifyopt; stuck-timeout notice before force-finalize;handlePipelineStatusoutage (60s threshold) / recovery noticessrc/weixin/monitor.ts:onNotifyopt; session-expired / backoff / recovery noticessrc/__tests__/test-auto-flush.mjs(7 tests),src/__tests__/test-stuck-notices.mjs(4 tests); full suite 588 passingREADME.md: documented auto-continue and the new noticesCommits
fc0e287feat: auto-flush cached outbound messages (auto /next)361aa0ffeat: notify user about stuck turns and channel anomalies