Skip to content

fix(auto-reply): suppress fallback for accepted busy turns - #115181

Closed
VACInc wants to merge 1 commit into
openclaw:mainfrom
VACInc:fix/busy-followup-fallback
Closed

VACInc wants to merge 1 commit into
openclaw:mainfrom
VACInc:fix/busy-followup-fallback

Conversation

@VACInc

@VACInc VACInc commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

When a second message is accepted by an already-running agent—either steered into the active run or queued as a follow-up—the current dispatch returns no immediate reply by design. Finalization mistook that accepted turn for an empty model completion and sent the generic “No reply was generated...” fallback. This patch carries an in-memory accepted-admission marker through the existing reply invocation and suppresses that false fallback until the accepted work produces its normal reply.

Closes #115171.

Root Cause

The concrete before path is:

  1. A visible channel turn owns the session reply lane.
  2. A second message arrives while that run is active.
  3. runReplyAgent successfully steers the message or enqueueFollowupRun(...) accepts it for deferred execution.
  4. runReplyAgent returns undefined because no immediate second-dispatch payload should be sent.
  5. finalizeDispatchAndAudit sees zero reply counts and no observed delivery, cannot distinguish accepted busy-run work from a genuinely empty model completion, and emits NO_VISIBLE_REPLY_FALLBACK_TEXT.
  6. That erroneous newer visible fallback can advance the foreground freshness fence and suppress the first run's real completed answer as stale.

Source proof on current main:

  • Successful steering returns undefined from agent-runner-run.ts.
  • Successful follow-up enqueue also returns undefined.
  • The no-visible-reply gate in dispatch-from-config.finalize.ts previously had no admission-state input.
  • reply-operation-run-state.ts already carries invocation-local admission facts for heartbeat ownership; this patch extends that internal contract rather than adding a new global registry or delivery mechanism.

No model failure occurs on the affected path. The second turn was accepted by active-run processing.

What changed

  • Create or reuse one per-dispatch ReplyOperationRunState.
  • Pass the same object through the internal reply-options symbol.
  • Record { status: "accepted", mode: "steer" } only after steering succeeds.
  • Record { status: "accepted", mode: "followup" } only after follow-up enqueue succeeds.
  • Exclude an accepted active-run turn from both the core generic-fallback gate and the channel-level fallback-eligibility flag.
  • Leave rejected, deduplicated, aborted, and queue-overflow admissions unchanged.

User impact

Rapid consecutive messages no longer receive a false model-failure notice merely because the newer message was accepted by the active run. The existing foreground-fence policy is unchanged; this removes the erroneous newer visible delivery that could make the earlier real answer lose that fence.

Genuine empty model completions still receive the existing fallback.

Real behavior proof

Observed before behavior

A real Telegram direct conversation reproduced the sequence: a second message sent while the first was still active received the generic no-reply fallback; the first answer appeared only after the subsequent interaction. The private screenshot is not attached because it contains chat/account identifiers.

Redacted Gateway correlation from a second live recurrence:

08:06:49  first inbound turn received
08:08:12  second inbound turn received while the first agent run remained active
08:08:14  second dispatch completed in 1.2s with no agent-turn/model timing
08:08:14  one outbound text send completed (the generic fallback observed in chat)
08:12:56  first agent turn completed after 365s
08:12:57  first dispatch logged "visible channel turn dispatched with no queued reply payloads"

This establishes the patch boundary directly: the second dispatch produced a visible fallback without running a model, then the earlier real completion had no queued visible payload.

After-patch focused proof

Commands:

pnpm vitest run \
  src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts \
  src/auto-reply/reply/dispatch-from-config.test.ts

node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.e2e.config.ts \
  src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts \
  -t "dispatches a declined steer once with its source-turn identity"

Copied results from rebased head 12e0379e2aa5:

Test Files  2 passed (2)
Tests       305 passed (305)

Test Files  1 passed (1)
Tests       1 passed | 119 skipped (120)

Observed after behavior:

  • A successful real enqueueFollowupRun mock path stamps accepted/followup.
  • A successful steering path stamps accepted/steer.
  • Dispatch finalization receives that same state object.
  • An accepted active-run turn queues no generic fallback and does not advertise channel-level fallback eligibility.
  • The existing direct empty-completion tests still deliver the generic fallback.

Live deployment state

The patch was deployed as an oc-update --skip-codex overlay to a real multi-channel Gateway on 2026-07-28. The wrapper rebuilt from source and reported:

applied: #115181 fix(auto-reply): suppress fallback for accepted busy turns
Replacement Gateway verified
oc-update completed successfully

Independent post-update checks observed the replacement service active/running, NRestarts=0, port 18789 listening, configuration audit clean, and RPC read healthy on version 2026.7.2.

The deployed pre-rebase commit and refreshed PR commit have the same stable patch ID (40db31cbf7686f9302fb37e790f2cb9a0496676b), so the behavior-changing diff is identical. A fresh two-message channel reproduction after deployment remains pending; no claim of live after-fix channel proof is made yet.

Verification

pnpm vitest run src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts src/auto-reply/reply/dispatch-from-config.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts -t "dispatches a declined steer once with its source-turn identity"
pnpm exec oxlint --type-aware <all changed TypeScript files>
pnpm tsgo:core
git diff --check origin/main...HEAD
  • Rebased cleanly onto upstream main 5087e654773; refreshed head 12e0379e2aa5.
  • Focused tests: 306 passed.
  • Targeted type-aware Oxlint: passed.
  • Core TypeScript check: passed.
  • git diff --check: passed.
  • Secret scan: clean.
  • Fable review via Claude CLI found the initially missed successful-steer sibling path; it was incorporated.
  • Final mandatory independent review after that correction: clean, no actionable findings, correctness confidence 0.91.
  • Performance: no waits, network calls, storage operations, timers, retries, polling, or model work were added. The hot-path cost is one small invocation-local object when absent, two synchronous property writes on accepted busy paths, and one property read during finalization.

What was not tested

  • The exact after-patch two-message Telegram sequence has not yet been repeated on a live channel. The overlay is now deployed, but fresh visible proof requires sending real user messages while a model turn is active.
  • The full agent-runner.runreplyagent.e2e.test.ts file is not green on current main in this environment: 53 failures include default-agent session-key errors and two existing 120-second cases. The exact changed steering case passes in isolation, and the two focused suites pass.
  • A follow-up accepted and later removed by configured queue-overflow policy remains owned by queue policy and may be silent; this patch does not redefine queue-drop UX.
  • Rejected/deduplicated enqueues are not marked accepted. Their fallback policy is intentionally unchanged and should be evaluated separately from this observed successful-admission bug.

AI Assistance

Codex traced and implemented the admission/finalization contract. Fable reviewed the first patch via Claude CLI and identified the successful-steer sibling path; that finding was addressed before the final clean review.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 28, 2026
@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 8:26 AM ET / 12:26 UTC.

ClawSweeper review

What this changes

The PR marks busy turns accepted by steering or follow-up queuing so reply finalization suppresses the false generic no-reply fallback while the active run owns delivery.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep this PR open: it targets the linked active bug with a focused internal admission-state handoff, and the patch appears to preserve the generic fallback for genuine empty completions. It still needs after-fix real-channel proof before merge because the submitted evidence for the changed behavior is limited to tests and mocked dispatch paths.

Priority: P1
Reviewed head: 3866b63df5cdf16e6daf583baaff9a23dba50a16

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and has meaningful targeted coverage, but real after-fix behavior proof is still the merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR includes useful before-state Gateway correlation, but its after-fix evidence is focused tests and mocked resolver paths rather than a live accepted busy-turn channel run; add redacted runtime/channel evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR includes useful before-state Gateway correlation, but its after-fix evidence is focused tests and mocked resolver paths rather than a live accepted busy-turn channel run; add redacted runtime/channel evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Accepted-turn state is set after successful busy-run admission: The proposed patch records an accepted admission only after the steering path reports queued work or the follow-up enqueue succeeds, leaving rejected and aborted paths unchanged.
Final fallback is gated on the shared per-dispatch state: The finalizer now excludes accepted active-run turns from both generic fallback delivery and channel-level fallback eligibility, while its existing empty-completion conditions remain in place.
Dispatch-to-runner propagation is covered in the patch: The same invocation-local state is created or reused during request gathering and injected into the reply options passed to the resolver, avoiding a global registry or cross-session state.
Findings None None.
Security None None.

How this fits together

Auto-reply accepts inbound channel messages, invokes the agent runner, and finalizes any visible reply through the dispatcher. When a session already has an active run, the runner may steer or queue the new turn; this patch carries that accepted status to finalization so it does not mistake deferred work for an empty model result.

flowchart LR
  A[Inbound channel message] --> B[Reply dispatch]
  B --> C{Active session run?}
  C -->|No| D[Run agent and deliver reply]
  C -->|Yes| E[Steer or queue follow-up]
  E --> F[Accepted-turn state]
  D --> G[Dispatch finalization]
  F --> G
  G --> H[Fallback only for true empty completion]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR includes useful before-state Gateway correlation, but its after-fix evidence is focused tests and mocked resolver paths rather than a live accepted busy-turn channel run; add redacted runtime/channel evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P2) - Suppressing the visible fallback changes message-delivery behavior: a live after-fix busy-turn run should confirm that accepted work later produces the intended visible reply and that genuine empty completions still retain their fallback.
  • Resolve merge risk (P1) - The PR head is behind current main, so its merge result and focused proof should be refreshed against the current base before landing.
  • Complete next step (P2) - The remaining merge blocker is contributor-supplied real behavior proof, which an automated repair lane cannot produce for the contributor's live channel setup.
Agent review details

Security

None.

PR surface

Source +55, Tests +11. Total +66 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 7 57 2 +55
Tests 2 11 0 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 68 2 +66

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #115171
Summary: This PR is the proposed implementation for the active canonical report about accepted follow-up turns receiving a false no-reply fallback.

Members:

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

Mantis proof suggestion

A redacted Telegram Desktop recording would directly show the missing false fallback and the expected delivery outcome for the active and accepted turns. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: reproduce an active-turn follow-up and capture that the accepted second turn gets no generic fallback while the normal reply delivery still occurs.

Merge-risk options

Maintainer options:

  1. Add live busy-turn proof before merge (recommended)
    Record or provide redacted terminal/Gateway and channel evidence from an after-fix active-run follow-up or steer sequence, including the eventual visible reply.
  2. Accept delivery-risk with maintainer evidence
    A maintainer may accept the focused test proof only after independently validating that the production queue and foreground-delivery behavior matches the proposed invariant.
  3. Pause until a fresh reproduction is available
    Keep the linked bug and this draft PR open if a realistic active-run channel scenario cannot be exercised safely before merge.

Technical review

Best possible solution:

Keep one invocation-local admission signal, then demonstrate a redacted live two-message channel run showing that the accepted second turn receives no false fallback while the active and queued work retain their normal delivery behavior.

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

No high-confidence after-fix reproduction is provided yet. The source path and reported before-state logs make the busy-turn mechanism reproducible in principle, but the PR only supplies mocked/focused test proof after the change.

Is this the best way to solve the issue?

Yes, provisionally: carrying an invocation-local accepted-admission fact to the existing finalizer is narrower and safer than changing delivery counts or adding shared state. A live channel run is still needed to confirm the exact delivery contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4f6fc38a2204.

Labels

Label changes:

  • add P1: The reported bug can send a false failure message and interfere with delivery of a real active-turn reply in a normal channel workflow.
  • add merge-risk: 🚨 message-delivery: The patch deliberately suppresses an existing visible fallback based on queue or steer admission, so end-to-end delivery behavior needs live confirmation.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR includes useful before-state Gateway correlation, but its after-fix evidence is focused tests and mocked resolver paths rather than a live accepted busy-turn channel run; add redacted runtime/channel evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The reported regression is visible Telegram chat behavior and can be demonstrated in a short redacted Telegram Desktop recording.

Label justifications:

  • P1: The reported bug can send a false failure message and interfere with delivery of a real active-turn reply in a normal channel workflow.
  • merge-risk: 🚨 message-delivery: The patch deliberately suppresses an existing visible fallback based on queue or steer admission, so end-to-end delivery behavior needs live confirmation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR includes useful before-state Gateway correlation, but its after-fix evidence is focused tests and mocked resolver paths rather than a live accepted busy-turn channel run; add redacted runtime/channel evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The reported regression is visible Telegram chat behavior and can be demonstrated in a short redacted Telegram Desktop recording.

Evidence

What I checked:

  • Accepted-turn state is set after successful busy-run admission: The proposed patch records an accepted admission only after the steering path reports queued work or the follow-up enqueue succeeds, leaving rejected and aborted paths unchanged. (src/auto-reply/reply/agent-runner-run.ts:294, 3866b63df5cd)
  • Final fallback is gated on the shared per-dispatch state: The finalizer now excludes accepted active-run turns from both generic fallback delivery and channel-level fallback eligibility, while its existing empty-completion conditions remain in place. (src/auto-reply/reply/dispatch-from-config.finalize.ts:293, 3866b63df5cd)
  • Dispatch-to-runner propagation is covered in the patch: The same invocation-local state is created or reused during request gathering and injected into the reply options passed to the resolver, avoiding a global registry or cross-session state. (src/auto-reply/reply/dispatch-from-config.gather.ts:65, 3866b63df5cd)
  • Focused coverage spans both admission modes and finalization: The changed tests assert accepted follow-up and steering state, plus the no-fallback result when the resolver marks the invocation accepted; the PR body reports 306 focused tests passed. (src/auto-reply/reply/dispatch-from-config.hooks-and-send-policy.test-utils.ts:426, 3866b63df5cd)
  • The PR is the candidate fix for the active report: The linked issue describes the same successful-follow-up path and remains open pending a merge; this PR explicitly proposes the corresponding admission-to-finalization distinction. (3866b63df5cd)

Likely related people:

  • steipete: The available repository context identifies broad recent core and release ownership, but this read-only review could not establish a file-level auto-reply history trail; route with low confidence. (role: likely core runtime follow-up owner; confidence: low; files: src/auto-reply/reply/agent-runner-run.ts, src/auto-reply/reply/dispatch-from-config.finalize.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide redacted after-fix evidence from a real active-run steer or follow-up sequence, showing no generic fallback and the later expected visible reply.
  • Refresh the branch against current main and rerun the focused delivery checks on the resulting head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@VACInc
VACInc force-pushed the fix/busy-followup-fallback branch from 3866b63 to 12e0379 Compare July 28, 2026 12:54
@VACInc

VACInc commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Rebased cleanly onto current main (5087e654773); refreshed head: 12e0379e2aa5. The stable patch ID is unchanged from the deployed pre-rebase head.

Focused validation rerun: 305/305 admission/finalization tests passed; isolated steering E2E 1 passed (119 skipped); targeted type-aware Oxlint, core TypeScript check, and git diff --check passed. The PR body now records the successful live overlay deployment and RPC/service verification. Exact after-fix two-message channel proof remains pending and is not claimed.

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(auto-reply): suppress fallback for accepted busy turns This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@VACInc

VACInc commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Superseded by #115016. The accepted busy-turn implementation, tests, linked issue, deployment evidence, and review findings have been consolidated there to keep one user-facing fallback regression in one review lane.

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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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.

Queued follow-up emits false no-reply fallback while active turn is running

1 participant