Skip to content

fix(inbound): keep polling while turns are active - #226

Closed
NewFuture wants to merge 15 commits into
Tencent:mainfrom
New-Future:fix/durable-inbound-polling
Closed

fix(inbound): keep polling while turns are active#226
NewFuture wants to merge 15 commits into
Tencent:mainfrom
New-Future:fix/durable-inbound-polling

Conversation

@NewFuture

@NewFuture NewFuture commented Jul 12, 2026

Copy link
Copy Markdown

Refs #201

Problem

The Weixin monitor awaited processOneMessage inside the long-poll loop. A long OpenClaw turn therefore stopped later polling, so ordinary mid-run messages and /approve plugin: commands could not reach core until the active reply finished.

Minimal fix

  • Keep polling after each successful getUpdates response instead of awaiting full message processing.
  • Preserve ordinary-message preprocessing order in one in-memory lane, releasing that lane as soon as OpenClaw accepts or queues the turn.
  • Give only /approve plugin: an independent in-memory lane so approval commands are not blocked by an active ordinary turn.
  • Treat /approve plugin: entered while replying to a quoted message as a command while retaining the quote in the agent-visible body.
  • Pass best-effort reply admission callbacks to newer OpenClaw hosts; older hosts may ignore the optional fields and retain their prior serial behavior.
  • Keep queued-followup tool progress open until core reports lifecycle completion.
  • Skip queued inbound work that has not started when the monitor is aborted; already-running handlers remain best-effort.
  • Capture context tokens synchronously in polling order before detached processing starts.
  • Leave queue, steer, follow-up, approval parsing, authorization, and resolution entirely to OpenClaw core.

Scope

The final diff contains three files:

  • src/monitor/monitor.ts
  • src/monitor/monitor.test.ts
  • src/messaging/process-message.ts

It intentionally has:

  • no plugin-local durable inbox, replay records, tombstones, or persistence
  • no OpenClaw version/capability gate
  • no dependency or package.json change
  • no new configuration
  • no OpenClaw core change

Validation

  • Focused compatibility/monitor/inbound/command/progress tests: 54/54
  • Typecheck: pass
  • Build: pass
  • Full suite: 394/398; all four failures exactly match the existing Windows baseline (one path-separator assertion and three first-import timeouts)
  • Package dry-run: 116 entries
  • Diff hygiene: pass
  • PR CI: pass
  • Final post-push review at 4a32aaf: no new findings

Live deployment

  • Deployed head 4a32aaf to CT101 on the existing OpenClaw 2026.7.1-beta.6; OpenClaw was not upgraded.
  • Archive SHA-256: 22b6b62ce2697ee2e268a26f50de8bf43317e89cedc15e253f93aeccc426c76f.
  • Installed monitor/process/compat/channel hashes match the archive exactly.
  • The removed inbound-inbox.js implementation is absent from the installed plugin.
  • The local operator TLS patch hash remains unchanged.
  • CT101 and HA are started; local and public health/readiness are healthy.
  • Both Weixin cursor files resumed updating after restart.
  • plugin.approval.list works and is empty; no inbound failure markers were observed.
  • Rollback backup: /home/node/.openclaw/backups/lifecycle-fix-20260716T021812Z.
  • Final post-deployment review: no new findings.

NewFuture and others added 5 commits July 12, 2026 14:55
Persist inbound batches before advancing the cursor, then transfer durable ownership when OpenClaw starts or queues the turn. Keep the existing serial fallback when durable ingress is unavailable and refresh context tokens at actual delivery time.

Refs Tencent#201

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass the account ID through local slash-command sends so replies resolve the newest context token admitted from the current polling batch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revert slash reply accountId token-refresh wiring and restore devDependency openclaw version to avoid widening this fix PR scope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rediscover approvals that were released by another manager and keep same-session lanes blocked while any other owner still holds a live claim, with focused regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revert token freshness-related messaging changes and tests while keeping durable ingress, approval lane prioritization, and lifecycle handoff behavior for midrun steering and approvals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@NewFuture
NewFuture force-pushed the fix/durable-inbound-polling branch from 86e6287 to 3ccf15b Compare July 12, 2026 16:30
NewFuture and others added 5 commits July 13, 2026 22:00
Restore standard channel registration and message dispatch so the fix no longer depends on trusted host-only queue APIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Persist each polled batch before advancing its cursor, then dispatch asynchronously through the existing core path so steer remains core-owned and plugin approvals are not blocked by ordinary turns.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Share admission, retry, and processed state across overlapping monitor instances so hot reload preserves backoff and finalizes successful records without replaying Agent work. Keep recent tombstones for the full retention window and retain natural message ordering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Release the ordered inbox lane only after beta.6+ adopts or queues a turn, retain queued follow-ups until completion, and keep older hosts on the serial compatibility path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass the durable admission lifecycle to plugin approval messages on supported hosts so they can reach core command handling before the pending approval expires. Core remains responsible for authorization and resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
NewFuture

This comment was marked as outdated.

NewFuture and others added 5 commits July 15, 2026 11:13
Keep inbox retries ordered and idempotent across restarts by persisting admission order and deriving a stable MessageSid. Narrow approval matching, retain tombstones from completion time, and remove unrelated dependency and cursor changes from the PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep polling while OpenClaw owns an active turn, serialize ordinary preprocessing only until core admission, and give plugin approvals an independent lane. Remove the plugin-local durable inbox and version gate so queue and steer semantics remain in core.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the current Weixin message text for CommandBody while retaining quoted context in Body, so reply-style approval commands remain visible to OpenClaw core.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the enriched quoted body as BodyForAgent while CommandBody carries only the current message text for slash-command parsing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Skip not-yet-started inbound work after monitor abort, and keep reply progress open until Core completes a queued follow-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@NewFuture

Copy link
Copy Markdown
Author

Closing this draft so the validated three-file fix can be resubmitted from a clean branch with a single focused commit, following the repository conventional commit and PR style.

@NewFuture NewFuture closed this Jul 16, 2026
@NewFuture

Copy link
Copy Markdown
Author

Replaced by #228, submitted from a clean branch with one focused commit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant