Skip to content

fix(reply): let active turns reach queue policy - #89238

Closed
darinkishore wants to merge 1 commit into
openclaw:mainfrom
darinkishore:codex/reply-queue-policy-admission
Closed

darinkishore wants to merge 1 commit into
openclaw:mainfrom
darinkishore:codex/reply-queue-policy-admission

Conversation

@darinkishore

Copy link
Copy Markdown

Summary

  • let same-session visible turns reach active-run queue policy even while a reply operation is active
  • keep the existing Slack routed-thread bypass behavior intact
  • preserve serialization for different non-Slack routed threads

Why

messages.queue.mode = "steer" can only work if the inbound visible turn reaches active-run queue policy while the original turn is still active. In the failing path, iMessage could receive and queue the inbound message during the active run, but dispatch admission waited for the active reply operation to go idle before get-reply-run could resolve steer/followup/collect behavior.

This does not replace #73365. That PR covers lifecycle-aware injection once a message reaches the active-run steering path. This PR fixes the earlier admission fence that can keep same-session visible turns from reaching that path at all.

Refs #48003.
Refs #54488.

Validation

  • node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.test.ts (190 passed)

Same-session visible turns could be received promptly but still sit behind dispatch admission until the active reply operation went idle. That meant messages.queue.mode=steer never got a chance to inject into the active embedded run; the turn only reached get-reply-run after the original run completed.

Tried treating this as iMessage inbound debounce first, but live stability events showed message.received and message.queued happened during the shell sleep. The hold was later: dispatch admission waited for the active reply operation before queue policy resolution.

This keeps the Slack routed-thread bypass as-is, keeps different non-Slack routed threads serialized, and only lets visible turns in the same route thread pass through to the active-run queue policy. That lets steer/followup/collect/interrupt own the active-run decision instead of the admission fence preempting it.

Scaffolding: this is source-level and tested in the vendored checkout. The installed OpenClaw bundle still needs a build/install or hot patch before the live gateway uses it.
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR has been inactive for a while and still is not in a landable state.

Close this external PR as abandoned: its head has had no substantive activity for 31 days, remains conflicting and waiting on the author, and the unchanged head still has the previously reported correctness blocker. The fix direction and Telegram proof remain useful, so a corrected rebased submission would be welcome.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #48003
Summary: This PR is a candidate fix for the earlier reply-admission portion of the canonical steer-mode report; adjacent lane-starvation and mid-stream injection items require broader or different behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as inactive for now. If you pick the work back up, push a rebased branch with green checks and reopen (or open a fresh PR) and it will be reviewed again.

Review details

Best possible solution:

Rebase the narrow admission change onto current main, return or preserve an explicit accepted-active-queue outcome that suppresses no-visible fallbacks, retain cross-route serialization and the Slack exception, and add focused Feishu-fallback and Slack non-regression coverage before rerunning the existing Telegram proof.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: the current admission path waits on the active reply operation before queue policy can resolve a same-session visible turn, and the focused test demonstrates the blocked-versus-admitted boundary. Mantis also supplied native Telegram proof, though the exact iMessage path was not shown live.

Is this the best way to solve the issue?

No in its current form: moving the admission boundary is a plausible narrow fix, but it must carry an explicit accepted-queue result through dispatch so downstream channels do not mistake successful steering or queueing for an empty reply.

Security review:

Security review cleared: The two-file runtime-and-test diff adds no dependency, workflow, permission, secret, artifact-download, or supply-chain surface, and no concrete security regression was found.

AGENTS.md: found and applied where relevant.

What I checked:

  • Abandonment conditions: The head commit is unchanged since June 1, 2026; the last substantive review/proof activity was June 15, 2026, 31 days ago. On July 16, 2026 the PR is non-draft, merge-conflicting, labeled waiting on author and stale, and has no assignee, requested reviewer, or human maintainer engagement in the supplied timeline. (067f73db1a93)
  • Unresolved prior blocker: The current head is identical to the previously reviewed SHA. The new admission bypass can accept an active-queue turn without distinguishing that outcome downstream, leaving noVisibleReplyFallbackEligible true when the queue handler returns no final reply; Feishu can consequently send its immediate no-visible-reply fallback even though the message was accepted. (src/auto-reply/reply/dispatch-from-config.ts:1273, 067f73db1a93)
  • Affected channel consumer: Feishu consumes the no-visible-reply eligibility flag to produce a fallback response, making the missing accepted-queue result state observable rather than merely internal bookkeeping. (extensions/feishu/src/bot.ts:101, 990e8d24b0d6)
  • Current-main necessity check: Merged work at Restore Telegram /steer for active Codex runs #98126 handles active non-streaming steering after a message reaches reply handling and explicitly leaves earlier ordinary-message admission/serialization unresolved. It therefore overlaps but does not supersede this PR's central admission fix. (src/auto-reply/reply/agent-runner.ts, 8d9a7ab2cab6)
  • Real behavior proof: Mantis supplied native Telegram Desktop baseline and candidate recordings for close-together messages at this exact head, and the proof workflow reported a successful candidate result. The proof remains reusable after correcting and rebasing the patch. (067f73db1a93)
  • Codex steering contract checked: OpenAI Codex app-server documentation at codex-rs/app-server/README.md:305 defines turn/steer as appending user input to a currently in-flight turn, consistent with the need for OpenClaw admission to reach queue policy while that turn remains active.

Likely related people:

  • steipete: Recent current-main history attributes the caller-scoped reply admission timeout and adjacent queue-steering work to this contributor, making them a strong routing candidate for admission and fallback semantics. (role: recent reply-admission contributor; confidence: high; commits: 455d5e8, 90c46b9; files: src/auto-reply/reply/dispatch-from-config.ts, src/auto-reply/reply/reply-run-registry.ts)
  • dutifulbob: Feature history ties the reply-run registry and active-operation coordination used by the changed admission path to this contributor. (role: introduced reply-operation registry behavior; confidence: high; commits: 3f684a7; files: src/auto-reply/reply/reply-run-registry.ts, src/auto-reply/reply/dispatch-from-config.ts)
  • fuller-stack-dev: Multiple merged commits implementing and extending queue steering touch the invariant this PR is attempting to preserve. (role: queue-steering feature contributor; confidence: medium; commits: 70df54f, fd9e18d, e663b82; files: src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/dispatch-from-config.ts)
  • 100yenadmin: Authored the merged active non-streaming and Telegram/Codex steering work that explicitly documented the remaining earlier admission boundary. (role: recent adjacent steering contributor; confidence: medium; commits: 8d9a7ab2cab6; files: src/auto-reply/reply/agent-runner.ts, src/auto-reply/reply/reply-run-registry.ts, extensions/telegram/src/sequential-key.ts)

Codex review notes: model internal, reasoning high; reviewed against 990e8d24b0d6.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 1, 2026
@byungskers

Copy link
Copy Markdown

I like the admission-vs-queue-policy split here. One regression I'd be tempted to pin down before merge: an explicit non-regression test for the existing Slack routed-thread bypass path.

This patch still preserves that branch in code, but now that same-thread visible turns can also bypass waitForActive, having one focused “Slack still does the old thing” test would make the intent much easier to maintain.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Jun 15, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 15, 2026 11:03 Inactive
@openclaw-mantis

openclaw-mantis Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIFs for close-together Telegram messages and the resulting bot replies.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-89238/run-27574767486-1/index.json

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
@darinkishore
darinkishore marked this pull request as ready for review June 15, 2026 18:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 067f73db1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1283 to +1287
if (allowActiveQueuePolicy && admission.reason === "active-run") {
logVerbose(
`dispatch-from-config: allowing visible turn for ${dispatchOperationSessionKey} to reach active-run queue policy while a reply operation is active`,
);
return { status: "ready" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid treating queued active turns as empty replies

When this branch admits a visible turn only so the active-run queue policy can handle it, the normal steer/enqueue paths in runReplyAgent return undefined with zero final replies; dispatchReplyFromConfig then still sets noVisibleReplyFallbackEligible at src/auto-reply/reply/dispatch-from-config.ts:3008-3013. Feishu consumes that flag in extensions/feishu/src/bot.ts:101-109, so a second Feishu direct message during an active steer/followup run gets an immediate “no visible reply” fallback even though the message was accepted into the active run/queue. Please suppress the no-visible fallback for turns admitted through this active-queue-policy path, or return an explicit queued/steered result state.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 15, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 15, 2026
@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 15, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 15, 2026 20:38 Inactive
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 19, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper could not autoclose this item.

Reason: structured ClawSweeper close marker: close-required (sha=067f73db1a9327de695a876a38a5d706553e9626)

Usage: /autoclose <maintainer close reason>. I will close this item and any open same-repo items explicitly referenced in the command text.

This branch was previously deployed

1 inactive deployment
qa-live-shared — 067f73db Deployed Jun 15, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #177713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants