Skip to content

fix(auto-reply): hand completed source replies to queued successors - #127967

Closed
HermanZeng wants to merge 16 commits into
openclaw:mainfrom
HermanZeng:fix/reply-completion-handoff-126813
Closed

HermanZeng wants to merge 16 commits into
openclaw:mainfrom
HermanZeng:fix/reply-completion-handoff-126813

Conversation

@HermanZeng

@HermanZeng HermanZeng commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #126813

What Problem This Solves

Queued followups can replay a predecessor message-tool-only reply when they lose the narrow fact that its final source reply was already delivered. Preserve that one-shot completion fact through the existing reply-operation and mailbox owners without changing delivery authority or durable recovery.

Evidence

Current budget-only follow-up

Current head 9536ed14351879f75b70d702ae03eaa33bde2ebd, tree
58614a47159fb1730c27904c77df4de9f6eaf7bc, has the single published parent
e61baabb585bb49c0bd84c52f82aea0c80768bb4. Only the existing test-line ceiling
changed. No production/test bytes, checker, timeout, model request or main
integration changed in this follow-up.

CI on the preceding head
measured 6,311,267 / ceiling 6,311,177 / delta +617 / over 90 against a later
prepared base fefc2fb01ca30aa29d8b56156a895484e1ccc5d6. The other nine
independent baseline checks passed. That is a test-budget failure signature,
not a claim that every functional check was green. The original failure remains
retained; a new main merge was not used to chase this queued comparison tree.

The three scoped PRs now deliberately use identical single-line 6,313,000
ceilings. Same-pattern Git numstat checks found their test paths disjoint, with
retained deltas 617 + 498 + 694 = 1,809. This CI result and the document PR's
6,311,148 / +498 result both imply an arithmetic comparison count of 6,310,650.
Thus 6,310,650 + 1,809 + 541 = 6,313,000. This is explicit one-time budget
planning, not an independently measured main count or a tested combined branch.
The bounded 541 reserve accommodates observed queue-time movement; identical
bytes also avoid scalar conflicts between these three proposed changes. No
automatic growth or guarantee about all future main changes is introduced.
The owner explicitly permits a manual ceiling increase justified in the PR.

The counted test corpus is unchanged. Its actual earlier native count remains
6,311,155; the new ceiling gives arithmetic slack 1,845. Native owner
scalar parsing, identical-budget byte checks, unchanged-corpus checks and
whitespace checks passed; this is reuse of that count, not a newly executed
full-tree counter. Normal commit hooks ran. Independent P0-P3 review covered the
complete three budget-only deltas and publication helpers with no actionable
finding (Codex-app narrative review, inherited model identity unverified; not
CLI/helper attestation). New-head CI remains separate.

All source/runtime/model evidence below retains its original commit and limits.
The real Telegram/model A/B/C plus ninety-second no-fourth-reply proof is still
missing. Earlier timeouts and failed proofs are not erased, and no new hosted
review or merge is implied.

Retained prior-head implementation, validation and failed proof history

The following description is retained as a historical record for its named commits. Its original “current”, “now” and “final” wording refers to those earlier candidates, not to the integration identified above. Earlier failures remain failures; earlier green CI is not current-head CI.

Fixes #126813

What Problem This Solves

Queued followups can replay a predecessor message-tool-only reply when they lose the narrow fact that its final source reply was already delivered. Preserve that one-shot completion fact through the existing reply-operation and mailbox owners without changing delivery authority or durable recovery.

Evidence

Current candidate after the confirmed budget conflict

Current head: normal merge e61baabb585bb49c0bd84c52f82aea0c80768bb4, tree
b07d61d278b9125fddaf7c2603770fadf3593057. Ordered parents are the published
budget follow-up 43022bd833c57efc50d75c16078bdddb4e967650 and the fixed main
snapshot a9b037d25c98aefd761ddb9bdcb0636d92ebe540. This integration was
selected for an actual merge conflict after main changed the budget, not merely
because main had advanced. No history was rewritten and this PR's production
and test bytes were preserved.

The PR's stored base SHA still reported a1859e5, while GraphQL's actual
baseRef.target had advanced to a9b037d. Main replaced the earlier reserve
comments and 6,310,000 ceiling with the single line 6310560. The preceding
budget-only repair and its real failed CI evidence remain retained below; that
repair was not mislabeled a product fix or erased after the subsequent conflict.

The only content conflict in the normal merge was the budget file. The ten
non-budget feature/test paths have identical upstream blobs at the previous and
new fixed bases. All ten current feature/test files also match their previously
reviewed 2daae272 source bytes. The complete current PR delta against a9b037d
is those ten files plus the one-line budget adjustment. All incoming main-owned
changes were preserved; no feature, test, checker or authority guard was edited.

The documented budget owner allows an increase with a PR justification. This
candidate uses main's comment-free format and raises 6,310,560 to 6,311,177,
exactly the retained +617 regression lines. The actual native integrated-tree
check passed at 6,311,155, with 22 slack. The scalar proposal is not called
the measured count, and main's value is not called an independently executed
main count: its own observed ratchet was skipped. No timeout, assertion or
coverage was removed to fit the limit. Whitespace checks passed; commit hooks
remained enabled.

Independent P0-P3 integration assessment found no actionable issue. It reused the
prior complete feature review and independently checked every frozen feature
blob, the new-base delta and budget conflict resolution. This was a Codex-app
narrative assessment with inherited model identity unverified, not CLI/helper
attestation. Transitive upstream inputs did change: previous owner, consumer,
static and isolated HTTP Gateway results keep their exact historical source
identities below, and are not relabeled executions of this new merge. No new
runtime build or model proof is claimed for e61baabb; new-head CI is separate.

Real Telegram/model A/B/C, the ninety-second no-fourth-reply observation and exact
live request/directive counts remain outstanding. The earlier cold Gateway
timeout remains unexplained; the later passing replay is not claimed as its
causal repair. This conflict resolution does not close either proof gap and
does not request another maintainer ping or hosted review.

Retained prior-head implementation, validation and failed proof history

The following description is retained as a historical record for its named commits. Its original “current”, “now” and “final” wording refers to those earlier candidates, not to the integration identified above. Earlier failures remain failures; earlier green CI is not current-head CI.

Fixes #126813

What Problem This Solves

Queued followups can replay a predecessor message-tool-only reply when they lose the narrow fact that its final source reply was already delivered. Preserve that one-shot completion fact through the existing reply-operation and mailbox owners without changing delivery authority or durable recovery.

Evidence

Current candidate and narrow CI follow-up

Current head: 43022bd833c57efc50d75c16078bdddb4e967650, tree
62c3103a4cfb0798ad2172eb3a699c0d66df2910. This is a normal single-parent
follow-up to 2daae272fcae8e4cb5901b24e7a48dc857ee4e89, not another main merge
or history rewrite. Its only change is the test-line budget and its justification;
all production and test bytes remain identical to that reviewed integration.

The exact previous-head CI job
failed the test-lines checker at 6,311,134 lines, ceiling 6,310,000, PR delta
+617. Its synthetic merge was 93ed7b33388b5f6f9da61f031102e6134fba5eea
against prepared base 76fc97e3765d8865a00e036e9868927ca6f1910e, not the
local integration's fixed a1859e5 tree. The native failure classifier marks
this new; it is not relabeled an inherited failure. The other nine independent
baseline checks passed; the second red check was the aggregate CI gate.

The documented test-line owner permits a justified manual ceiling increase.
The ceiling now matches the observed CI total exactly: 6,311,134. No test,
assertion, checker, timeout or CI requirement was removed or weakened. This is
zero slack for that observed synthetic merge, not a claim about a future moving
base. The actual local native counter passed at 6,305,200, with 5,934 slack under
the new ceiling; those different tree measurements are not conflated. Whitespace
checks passed, and the complete budget-only delta received independent P0-P3
review with no actionable findings (Codex-app narrative assessment, inherited
model identity unverified; not CLI/helper attestation).

The original integrated owner, consumer, static and uninstrumented HTTP Gateway
proofs remain bound to their exact source freeze / 2daae272 integration, as
retained below. They were not rerun at this budget-only commit, and the earlier
unknown cold timeout remains a failure. Real Telegram/model A/B/C plus the
ninety-second no-fourth-reply proof is still outstanding; this budget repair
does not close it. New-head CI and maintainer review remain independent gates.

Retained prior-head implementation, validation and failed proof history

The following description is retained as a historical record for its named commits. Its original “current”, “now” and “final” wording refers to those earlier candidates, not to the integration identified above. Earlier failures remain failures; earlier green CI is not current-head CI.

Fixes #126813

What Problem This Solves

Queued followups can replay a predecessor message-tool-only reply when they lose the narrow fact that its final source reply was already delivered. Preserve that one-shot completion fact through the existing reply-operation and mailbox owners without changing delivery authority or durable recovery.

Evidence

October 29 integration status

The integration is normal merge commit
2daae272fcae8e4cb5901b24e7a48dc857ee4e89, tree
23f05d096587a4c9326faec295566718cecdd384, with ordered parents prior head
639e809b03c2c5bfa533ef0fb1e40d932113e202 and fixed main
a1859e5195f6e74f1980192bdf291c0193e940a1. Commit hooks remained enabled;
the reviewed and tested source fingerprints were preserved. New-head hosted CI
must be evaluated separately after publication.

The two production overlaps merged automatically. Static full-diff inspection
preserved the existing cleanup source handoff and adopted-only runtime fragment,
and preserved incoming source admission, collaborative-steering fallback and
recovery-memory-flush state. No additional production repair, scheduler, state
owner or test layer was added. The sole content conflict was the test-line ceiling;
it is resolved to main's exact 6310000 file and its bounded reserve explanation,
without another increase. The native integrated-tree count passed at 6,305,200
lines, leaving 4,800 reserve under that unchanged 6,310,000 ceiling.

Against this fixed main, the candidate remains seven production files (+278/-3)
and three test files (+617/-0), ten files total (+895/-3); the budget file has no
candidate delta. The handoff owner, producer, core/followup integration and owner/
Gateway test bytes are unchanged. The two overlapping runtime files additionally
contain their main-owned changes. The initial static-only checkpoint is superseded
by the bounded integrated validation below; it was not itself runtime proof.

Prior eleven-case controller proof and the 41AF isolated HTTP Gateway A/B/C proof
remain historical evidence, not current-head execution. The prior seven-file/128
assertions and successful report-only recovery do not erase the original aggregate
command's exit 2. All earlier product reds, setup/quiet-control/type failures and
budget overflow remain documented in the existing evidence section and retained
artifacts; this addendum does not replace them.

The maintained Telegram readiness owner was checked without acquiring credentials.
The explicit broker pair is absent, and its current supported discovery returned
all three launchers unavailable. This is a local readiness gap, not a reported
permission denial or proof that credentials do not exist. No lease, login,
installation, paid model call, live scenario or retired Desktop/Mantis validation
was attempted. Repaired-head Telegram/model A/B/C plus the ninety-second no-fourth-
reply observation and exact live request/directive counts remain outstanding.
No additional maintainer ping or hosted re-review is used as a substitute for
that missing real-channel proof.

Integrated local validation

Using the explicitly qualified Windows Node 24.22.1 and repository-pinned pnpm
12.15.0, the own-worktree normal frozen install passed. All ordinary preparation,
native compiler, SDK declaration and Gateway runtime owners ran without skips or
manual stamps. These results were collected on the staged integration's exact
source freeze, which the normal merge commit preserves; they are not new-head
hosted CI or a claim that every runtime artifact was freshly produced at that
commit. An independent full ten-file P0-P3 source assessment found no actionable
findings. It was a Codex-app narrative subagent review with unverified inherited
model identity, not a CLI/helper pass or enforced-isolation attestation.

  • The unchanged eleven-case real-controller owner file passed once.
  • Seven consumer files passed in four separate native configuration commands:
    35 unit-fast, 45 infra, 35 auto-reply and 14 prefix-stability cases, 129 total.
    The current main suite has fourteen prefix cases; the old 128-case evidence is
    historical. No cross-configuration aggregate or report-only replay was needed.
  • Strict/no-unused ten-root types passed (41.75 seconds, empty compiler output;
    no stdout log was invented). Type-aware lint passed through the normal owner
    (267.48 seconds including 13,817 SDK declaration files). Ten-file formatting
    and whitespace checks passed. These are scoped, not whole-repository checks.
  • The native test-line check against fixed main with --no-merge-base passed:
    6,305,200 lines, main's unchanged 6,310,000 ceiling, 4,800 reserve. No budget
    increase, guard change or test deletion was made.
  • The final ordinary, uninstrumented Gateway A/B/C case passed on the original
    exact 41AF9D4908E8013D930C1DA0AE4256BE66FE498BA412C77F954802D40F7A0676
    fixture: 21,031 ms test time, Vitest 89.65 seconds, command wall 137.37 seconds.
    Its original 120-second limit and all assertions remain. It verified three
    execution requests in A/B/C order, predecessor counts 0/1/1, fresh input and
    visible replies once, drained claims, no extra replies, exact initial owned
    source mirror metadata, and no fixture errors. This is isolated synthetic HTTP
    Gateway proof, not Telegram, a real model or the ninety-second observation.

Retained unknown timeout and diagnostic limitation

The first ordinary Gateway command on this integration exited 1 after the
original 120-second test timeout (139,431 ms test time). Its JSON and complete
log remain byte-identical. No specific blocked await or product defect was
established. The server-import timing is a process-relative total, not a
187-second import; the reported import itself was 1.4 ms.

One explicitly authorized changed-input diagnostic passed with existing startup
and timeline logging plus temporary test-only phase statements. Its native
timeline recorded 558 events, 266 balanced span groups, no span errors, Gateway
readiness and three successful HTTP requests. Canonical E2E configuration kept
console output silent, so those temporary console statements did not yield a
last-begin/end inventory. They do not locate the original timeout. No second
diagnostic or larger timeout was used.

All forty-four temporary lines were removed, exact original bytes were restored,
and the separately authorized ordinary run above confirmed the final source.
Neither later pass erases the initial red or proves a causal repair for it.

Final source checks matched all eleven frozen source/test/budget hashes, with
zero unstaged, untracked or unmerged items and no generated tracked drift. All
gate command sessions joined. Native Windows wrappers retained their exact
namespaces where non-group descendant extinction could not be certified;
bounded process queries do not claim global cleanup. Normal merge publication
verifies the exact committed blobs, tree and ordered parents without force
rewriting history. New-head CI and the real-channel requirement remain separate
outstanding evidence.

Retained prior-head implementation, validation and failed proof history

The following description is retained as a historical record for its named commits. Its original “current”, “now” and “final” wording refers to those earlier candidates, not to the integration identified above. Earlier failures remain failures; earlier green CI is not current-head CI.

Fixes #126813

Human-led, AI-assisted: I led and actively contributed throughout this work, including problem selection, architecture, implementation, code-level decisions and review, test design, edge-case analysis, and final validation. Codex assisted with portions of code drafting and editing, test execution, and adversarial review. I reviewed and approved every material code, design, test, and evidence change.

What Problem This Solves

A queued request can replay the preceding message-tool-only answer because it loses the fact that its predecessor already delivered its final source reply. The next eligible request should receive that narrow completion fact while still answering its own fresh request, including an explicit request to repeat the prior answer.

This is a process-local handoff, not durable restart recovery or a guarantee that every model will obey the instruction. Delivery authorization, ordering, retry, cancellation, refusal and restart policy remain with their existing owners. The repaired-head real Telegram/model A/B/C recording and 90-second no-replay observation are still missing; local HTTP boundary coverage does not fulfill that requirement.

Implementation

  • Record only successful, settled, canonical current-source delivery against the actual reply operation. Publish synchronously through the existing successor barrier before mailbox wake/selection, rather than capturing recipients in an after-clear callback. After-clear retains only drain scheduling. The real Gateway reproduction established why this ordering matters: B had already been claimed when the old snapshot captured only C.
  • Use existing controller custody, physical mailbox, claim and source identities. Consumption and predecessor replacement require actual source adoption. A consumed-but-unadopted preparation failure cannot erase the earlier fact; custody itself is not delivery authorization.
  • Fence the one-shot fact by actual pending input membership, session key/incarnation, lifecycle generation and delivery target: channel, recipient, account, thread, chat, reply anchor/policy/type. A mismatch drops the instruction, not the user's queued request. Do not broaden recipients to arbitrary already-claimed inputs.
  • Add the fragment only to the current request after adoption; preserve user transcript bytes and stable system/tool definitions. Two private WeakMap projections hold operation completion/publication and mailbox predecessor/recipient facts. No new scheduler, durable queue schema, configuration or competing state owner is introduced.

This migrates to maintained controller, preparation, delivery and runtime-context owners; it does not restore retired admission/registry/prompt or Telegram Desktop/Mantis machinery. The former single-consumer target helper is inlined and the canonical reply-anchor owner is reused. Separate explicit-route producer PR #148721 is not absorbed, and its production-room issue is not claimed solved.

Candidate identity and review

Final head: 639e809b03c2c5bfa533ef0fb1e40d932113e202; tree: b1e2ee23aea1677526014e49ae44671ae124639d. Final-head hosted CI remains to be observed after publication; earlier green CI is not relabeled as this head's result.

The previous published head is 4d3b1169f3f15fd65c6827bd362c9f357a66c080. Normal merges 50a979820a03e95439cb85d2f9f1280adc57e20c and 57a23a9f1e7eeb716597ec16394a02e232c4b406 integrate fixed snapshots a6be2f6aee7fd9782563d54e33e4b60995853008 and f39b480c874d8acdae73f3b1c060dbd6cfc7a052; the final repair is a normal child of 57a23a9f. No force rewrite is used. Old-head CI is historical evidence, not final-head CI.

The old-head durable review identified lost context across preparation failure and a false-green mock of a retired compaction export. Current tests use the maintained export and require actual invocation without hidden preparation errors/failure payloads. Its isolated fixture response is not proof that the real compaction engine succeeded.

The default and permitted fallback CLI reviewers failed without producing reports. With explicit user approval, an independent Codex-app subagent reviewed the complete eleven-file candidate, entire tests and lifecycle/delivery/context owners for P0–P3 findings, then reviewed subsequent fixture deltas; no actionable issue was found. Model identity was not independently verified. This is a narrative assessment, not a CLI pass or helper-enforced isolation/frozen-input/structured-result attestation.

Evidence

  • 11 real-controller owner cases passed on the before-selection publication repair. They retain collect/drain-selected custody, refusal/retry, consumed-but-unadopted failure, adopted terminal failure/no-delivery replacement, canceled pending input, later ordinary input and route/room-event controls.
  • The final supported ordinary A/B/C Gateway case passed on fixture hash 41AF9D4908E8013D930C1DA0AE4256BE66FE498BA412C77F954802D40F7A0676 (20,517 ms test time; Vitest 87.18 s, including native worker preparation). It used a real isolated Gateway, maintained dispatcher/durable ingress, controller drain, serialized local HTTP Responses requests, actual message(action=send, final=true) source sink and public chat.history. With A held while B/C deferred, it observed one execution request each in A/B/C order, predecessor counts 0/1/1, each fresh input and visible reply once, no extra visible reply, empty claims, and exactly one A foreground mirror carrying real final/source-owned metadata with no additional callbacks or fixture errors. The final commit preserves the reviewed/tested source bytes; normal commit hooks ran without changing their hashes.
  • Seven consumer files / 128 cases passed in four original native reports, including preparation, existing followup/successor barrier, delivery evidence, runtime context and prefix stability. The original multi-group wrapper nevertheless exited 2 because native report aggregation hit a Vite configuration-loading timeout. A separate supported report-only replay of the same blobs/config exited 0; its seven-file/128-case inventory matched the originals exactly, with zero errors and normally ended captures. No tests were rerun and the failed original index/exit remain retained.
  • Final static checks passed: targeted ten-root strict/no-unused types (exit 0, 9.51 s), type-aware lint through the normal repository owner, ten-file format check and git diff --check. Types first exposed an invalid test-only legacy CommandSource: "message" value (exit 2). The one-line correction is explicit undefined, matching the real non-slash WebChat producer and overriding the helper's text-command default. Both inputs normalize to the same normal-message context; independent review verified the exact one-line delta. No cast, type widening or production guard change was used. The final Gateway above was rerun on this corrected input and passed; the prior type failure and older passing hash remain separate records. The successful type command emitted no output, so its exit metadata is retained rather than inventing a stdout log.
  • Final native test-line measurement: 6,286,563 lines, +617 PR test lines against fixed f39b480c with --no-merge-base. The first final count exited 1 because it exceeded the previous candidate's 6,286,555 ceiling by 8. The ceiling is explicitly adjusted to exactly 6,286,563, with zero slack: +617 regression lines and +359 lines already beyond the fixed base's 6,285,587 ceiling in the comparison tree. The 359-line split is arithmetic, not a separately executed red-main run. The documented ratchet policy permits a justified manual increase; no test deletion or disabled guard is used. Independent scalar review found no actionable issue, and the same native checker passed after the scalar change (exit 0, 5.0 s; actual 6,286,563, ceiling 6,286,563, slack 0). The original failed count is retained.

The Gateway is a fixed-response HTTP boundary fixture, not a real model, Telegram transport, public chat.send mode selection, optional/quiet Gateway proof, or 90-second observation. Execution requests exclude separately handled background conversation-label requests; total endpoint traffic is not claimed to be three. This fixture uses transient runtime carriers. Append-only providers must preserve historical carriers; whole-history marker counts are not current-turn fragment counts.

Retained failures and counterevidence

Earlier failed runs remain failed. The first exit-1 Gateway capture was incomplete, so no specific assertion/cause is attributed to it. Subsequent unchanged-120-second timeouts localized B to admission; the fixture had defaulted ordinary synthetic input to authorized text-command metadata, which correctly waited for A. Correcting that input exposed the real missing-B-directive defect: A's settled/ok canonical delivery and all B identity/target guards were valid, but publication was too late to include B. Temporary state/phase probes were removed before the repair and passing probe-free regression.

Later fixture failures were an incorrect zero-callback expectation (the existing owner intentionally emits A's already-owned UI transcript mirror), duplicate unique session labels, and an unsupported direct-WebChat room_event/NO_REPLY quiet combination. The diagnostic identified the extra request as quiet A, not B/C replay: direct WebChat requires a result, and NO_REPLY may legitimately trigger finalization. The invalid quiet combination was removed, not relabeled as passing negative proof; all eleven supported controller cases remain. The legitimate A mirror is now checked exactly, without filtering away extra callbacks. The final typecheck failure and its correction are recorded above rather than hidden by transpile-only success.

An earlier intended-cause mutation removed only the adoption gate: the actual unadopted-preparation-failure case then lost A's fact and failed; restoring exact bytes passed. This is a causal counterfactual, not an old-base red run. Generic preflight retry semantics were not widened. The native Windows wrappers retained their exact temporary namespaces where non-group descendant completion could not be globally certified; no cleanup success is inferred.

Outstanding repaired-head real-channel proof

Use only maintained .agents/skills/telegram-e2e-userbot: hold A's provider response, accept fresh B/C as pending followups, release A, and attach sanitized exact-head artifacts/counts showing:

  • Exactly one visible A/B/C reply each, in order.
  • No replay/fourth reply for 90 seconds.
  • Exactly three provider requests; B and C each contain the completed-predecessor directive exactly once.

The existing environment check found no supported Convex broker launcher/connection. It did not attempt login, install a broker, acquire credentials or run the live channel; this is an environment/access gap, not an observed permission rejection. No new paid calls, duplicate maintainer ping or hosted re-review is requested as a substitute. Attach the actual repaired-head proof before requesting @clawsweeper re-review.

Historical evidence, not current proof

  • Published 4d3b1169 on snapshot cddf5165 had CI run 33261641621 with 258 completed contexts and zero failures, plus 218 related local tests and old owner-clear/collect checks. Older green 32797492241 and 32584209718 likewise do not certify this integration.
  • Historical Telegram recording 32583508198, behavior head 44d8d8277f31af9d968e175420f7528dc95df905, observed both lanes answering initial/fresh queued input, with completion context only in the candidate. Subsequent fencing/architecture changes mean it is not repaired-head proof. feat(qa): add Convex-leased Telegram userbot proof #131715 retired Desktop/Mantis; it is not requested again.
  • Old producer-removal and retired-owner tests remain historical, not execution of current modules. A prior Windows SQLite .shm cleanup EBUSY also reproduced alone; later historical Linux success does not erase it.
  • The reporter's optional production diagnostic request remains in the existing comment. No new fleet adoption or production-room success is claimed.

@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@HermanZeng
HermanZeng marked this pull request as ready for review August 22, 2026 15:52
@clawsweeper clawsweeper Bot added 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 22, 2026
@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR carries confirmed source-reply completion through the follow-up queue into the next eligible request’s runtime context.

Example: A delivers its answer while requests B and C wait in followup mode.

  • Before: B receives the ordinary delivery hint without knowing A already answered and may replay A’s answer.
  • After: B receives one completed-predecessor directive while retaining its own request, and B’s completion can supply the corresponding context to C.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful owner-boundary repair with two unresolved correctness/validation findings; the new state is process-local and requires no migration.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An agent can answer the preceding question again when a queued peer message starts after its reply was already delivered.
Reason: The handoff addresses a demonstrated core workflow problem, while the reporter’s explicit-route Slack case also needs the separately tracked producer repair.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this PR contains useful work for a current queue-context defect, but both previously reported P2 findings remain unresolved.

Priority: P2
Reviewed head: 4d3b1169f3f15fd65c6827bd362c9f357a66c080

Before merge

  • Add real behavior proof - The completion producer, queue and admission have mocked integration coverage, but the full body explicitly treats earlier Telegram proof as historical after predicate changes. gorkem2020’s real Slack candidate port observed no handoff for explicit-route sends. Attach a successful repaired-head run showing one A reply, fresh B and C replies, their predecessor directives and no replay; redact private identifiers, IPs, endpoints and credentials. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve the predecessor claim across retryable preflight failures (P2) - This existing finding remains unresolved. When preflight throws an error that buildPreflightCompactionFailureText does not format, admission sets turn.preflightError and still reaches this consumer. consumeQueuedReplyCompletionHandoff deletes the queue claim before rejecting the failed operation. executeFollowupTurn then throws preflightError, and createFollowupRunner restores the request for retry; its newly registered after-clear callback also replaces the predecessor with no delivery. B consequently executes on retry without A’s completion context. Preserve the claim and avoid predecessor replacement until this retryable preparation path has succeeded.
  • Mock the compaction export actually called by admission (P2) - This existing finding remains unresolved. Production imports runSessionCompactionIfNeeded, but this factory exports only runPreflightCompactionIfNeeded. Calling the missing mock export throws inside admission’s preflight catch. Because buildPreflightCompactionFailureText always returns a payload and the fake operation.fail does not update result, the new context assertions can pass through a failed-preflight turn without invoking state.preflight. Mock the current export and verify successful admission has neither preflightError nor preflightFailurePayload.
  • Complete next step - Resolve GitHub’s reported merge conflicts against current main, preserving its current queue lifecycle and prompt-assembly owners.

Findings

  • [P2] Preserve the predecessor claim across retryable preflight failures — src/auto-reply/reply/followup-turn-admission.ts:474-477
  • [P2] Mock the compaction export actually called by admission — src/auto-reply/reply/followup-turn-admission.handoff.test.ts:29-31

Tests

  • Missing end-to-end proof: Missing successful repaired-path A→B→C channel evidence, including explicit-route delivery, and a regression showing the predecessor survives retryable preflight failure.
Agent review details

How this fits together

The shared auto-reply pipeline turns settled agent delivery evidence into queue-owned context, then passes that context through successor admission to the model.

flowchart LR
  A[Agent execution] --> B[Confirmed source delivery]
  B --> C[Reply operation completion]
  C --> D[Follow-up queue]
  D --> E[Successor admission]
  E --> F[Runtime model context]
  F --> G[Current request reply]
Loading

Technical review

Best possible solution:

Retain the producer-owned ephemeral handoff, preserve it across retryable preparation, and integrate it with current main’s queue and prompt owners.

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

The report supplies a concrete delivered-reply/queued-peer sequence, and current main still composes the bare delivery hint without predecessor completion context; this read-only review executed no target code.

Is this the best way to solve the issue?

The operation→queue→admission boundary is the right location because transcript inference cannot establish exact predecessor delivery, but the implementation consumes that fact before retryable preparation is settled.

Full review comments:

  • [P2] Preserve the predecessor claim across retryable preflight failures — src/auto-reply/reply/followup-turn-admission.ts:474-477
    This existing finding remains unresolved. When preflight throws an error that buildPreflightCompactionFailureText does not format, admission sets turn.preflightError and still reaches this consumer. consumeQueuedReplyCompletionHandoff deletes the queue claim before rejecting the failed operation. executeFollowupTurn then throws preflightError, and createFollowupRunner restores the request for retry; its newly registered after-clear callback also replaces the predecessor with no delivery. B consequently executes on retry without A’s completion context. Preserve the claim and avoid predecessor replacement until this retryable preparation path has succeeded.
    Confidence: 0.99
  • [P2] Mock the compaction export actually called by admission — src/auto-reply/reply/followup-turn-admission.handoff.test.ts:29-31
    This existing finding remains unresolved. Production imports runSessionCompactionIfNeeded, but this factory exports only runPreflightCompactionIfNeeded. Calling the missing mock export throws inside admission’s preflight catch. Because buildPreflightCompactionFailureText always returns a payload and the fake operation.fail does not update result, the new context assertions can pass through a failed-preflight turn without invoking state.preflight. Mock the current export and verify successful admission has neither preflightError nor preflightFailurePayload.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0a80f9e0b10e.

Provenance checked

  • Per-turn message-tool-only guidance keeps the original intent (4e6933c: The prior repair restored per-turn delivery guidance after directly addressed turns silently produced private final text.)
  • Canonical queued execution keeps the original intent (f8cc39c: Queued turns were converged onto shared execution, accounting and delivery owners to prevent drift.)
  • Queue delivery identity keeps the original intent (c67dc59: Route and thread evidence prevent queued work from suppressing or misrouting another reply.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/auto-reply/reply/followup-turn-admission.handoff.test.ts src/auto-reply/reply/followup-runner.handoff.test.ts src/auto-reply/reply/queue.drain-restart.test.ts src/auto-reply/reply/queue.collect.test.ts
  • pnpm test src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts -t "hands a confirmed source reply"
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f8cc39c adds src/auto-reply/reply/followup-runner.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f8cc39ce6213; files: src/auto-reply/reply/followup-runner.ts)
  • Ayaan Zaidi: Raw commit 4e6933c adds src/auto-reply/reply/prompt-prelude.ts:151 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4e6933c84f18; files: src/auto-reply/reply/prompt-prelude.ts)
  • sandieman2: Raw commit c67dc59 adds src/auto-reply/reply/queue/drain.ts:123 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c67dc59b02b0; files: src/auto-reply/reply/queue/drain.ts)

PR surface

Source +274, Tests +1214. Total +1488 across 18 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 10 325 51 +274
Tests 8 1215 1 +1214
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 1540 52 +1488

Review metrics

Metric Value Why it matters
Production versus test LOC Production +325/-51, net +274; tests +1215/-1, net +1214. The growth introduces a previously absent causal fact across operation, queue and admission ownership; route-key extraction also removes duplicated logic. A net-neutral change cannot carry that missing fact without replacing an equivalent existing mechanism.

Root-cause cluster

Relationship: same_root_cause
Canonical: #126813
Summary: This PR addresses missing immediate-predecessor context; explicit-route source classification is a separate prerequisite for the reporter’s Slack case.

Members:

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

Labels

Label changes:

  • add P2: Duplicate-answer prevention matters for configured multi-agent follow-up queues, with a bounded affected workflow.
  • remove P1: Current review triage priority is P2, so this older priority label is no longer current.

Label justifications:

  • P2: Duplicate-answer prevention matters for configured multi-agent follow-up queues, with a bounded affected workflow.
  • merge-risk: 🚨 message-delivery: The unresolved retry defect removes completion context before the restored successor executes, permitting the duplicate-answer behavior this PR targets.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-25T01:31:10.371Z sha 138b970da9b33d1400016c4a54fd1d0477ba9bf8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-25T02:03:05.051Z sha 138b970da9b33d1400016c4a54fd1d0477ba9bf8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T16:04:46.441Z sha 4d3b116 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T16:19:17.813Z sha 4d3b116 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-29T22:18:27.908Z sha 4d3b116 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T12:05:37.349Z sha 4d3b116 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T20:59:49.290Z sha 4d3b116 :: needs real behavior proof before merge. :: [P1] Recognize explicit-route source replies before minting the handoff
  • reviewed 2026-10-02T21:30:13.874Z sha 4d3b116 :: needs real behavior proof before merge. :: [P2] Preserve the predecessor claim across retryable preflight failures | [P2] Mock the compaction export actually called by admission

Reviewed October 18, 2026, 1:44 AM ET / 05:44 UTC (Revision 23).

@HermanZeng
HermanZeng force-pushed the fix/reply-completion-handoff-126813 branch from 44d8d82 to c3fb297 Compare August 22, 2026 16:16
@HermanZeng

Copy link
Copy Markdown
Contributor Author

@gorkem2020 Thank you for offering to run diagnostics on a candidate fix. The exact candidate head is now c3fb29731b586996ed905a244bed42a856adb3ac (PR #127967), and its source review found no correctness issue; exact-head CI is running after the three deterministic CI findings were fixed.

If you still have access to the affected multi-agent room, a redacted candidate run would be especially valuable. Please verify the checked-out SHA first with git rev-parse HEAD, then capture only:

  • the source delivery, queued peer arrival, drain, and successor-delivery timestamps;
  • outbound counts over a 90-second observation window: preceding answer = 1, current/follow-up answer = 1, unsolicited replay = 0;
  • a redacted tail of the successor provider input showing that the fresh queued request is preserved and the phrase "immediately preceding turn already delivered" is present once;
  • whether a fresh question and an explicit request to repeat or discuss the prior answer are both still answered normally.

Please do not include tokens, the full system prompt, real user or room IDs, auth/profile data, or unredacted payloads. A simple pass/fail summary plus the sanitized counts and timestamps is sufficient.

@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Aug 22, 2026
@HermanZeng
HermanZeng force-pushed the fix/reply-completion-handoff-126813 branch from c3fb297 to 29b020c Compare August 22, 2026 16:59
@HermanZeng

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The requested rebase is complete at exact head 29b020c80531e6458f197267e86112245565095e on current main 70c2be7e6aab3e983ca0053b965b7b8812a62378.

git range-diff marks the reviewed pre-rebase commit and final commit as patch-equivalent (=): 13 files, +1265/-10, with no scope or implementation change. Final exact-head hosted CI completed with zero failures and a successful openclaw/ci-gate: https://github.com/openclaw/openclaw/actions/runs/32586389925. The previously accepted maintainer-owned Telegram Desktop proof, proof: sufficient, and screenshot evidence remain linked in the updated PR body.

@clawsweeper

clawsweeper Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 22, 2026
@openclaw-mantis

openclaw-mantis Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Mantis could not complete this proof. Open the failed job.

@HermanZeng
HermanZeng force-pushed the fix/reply-completion-handoff-126813 branch from 29b020c to 7bc5e69 Compare August 23, 2026 13:49
@clawsweeper clawsweeper Bot added 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 23, 2026
@HermanZeng
HermanZeng force-pushed the fix/reply-completion-handoff-126813 branch from 138b970 to 4d3b116 Compare August 29, 2026 15:57
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Aug 29, 2026
@HermanZeng

Copy link
Copy Markdown
Contributor Author

@obviyus, when convenient, could you please help with one corrected exact-head proof request for this P1 delivery fix?

#131715 has retired the old Mantis/Desktop proof route, so the command in my earlier ping is now obsolete. #127967 is rebased onto the repository-owned .agents/skills/telegram-e2e-userbot harness at exact head 4d3b1169f3f15fd65c6827bd362c9f357a66c080; hosted CI is fully green (258 completed checks, zero failures): https://github.com/openclaw/openclaw/actions/runs/33261641621.

Could you run the new userbot harness on this exact head for the three-turn followup scenario? Hold A's provider response; send fresh B and C requests while A is active; after both are queued, install the drain hold and require pending: 2; then release A and the drain. The pass contract is:

  • exactly one visible A_REPLY_ONCE, one fresh B_REPLY_FRESH, and one fresh C_REPLY_FRESH, in order;
  • no replay or fourth SUT reply during a 90-second observation window; and
  • exactly three provider requests, with B and C each preserving their current request and containing the completed-predecessor directive exactly once.

Please include the exact SHA, scenario action results, redacted Telegram counts/order, and redacted provider-request counts. This verifies both the one-shot A→B transfer and B→C replacement on the current head. Thank you—there is no need to use the retired @openclaw-mantis telegram desktop proof workflow.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 29, 2026
@gorkem2020

Copy link
Copy Markdown
Contributor

Apologies for the silence since the 22nd. The offer stands, with one constraint I should have stated then: our multi-agent fleet runs the 2026.6.10 line, so an exact candidate head from current main cannot be dropped in on its own; it needs the core upgrade we have been holding back while we split off a separate production instance. That split landed this week, so the upgrade window on the multi-agent (development) fleet is next, within the coming week or two.

Plan for the run: deploy the exact head you name at that time, verify it with git rev-parse HEAD, replay the room pattern that produced the duplicate answers (a slow tool-heavy turn overlapping a queued peer message), and post redacted timestamps for source delivery, queued peer arrival, drain and successor delivery, plus outbound message counts per turn. If the head moves before then, tell me which one to test and I will use that. I will post here when the window is scheduled.

@gorkem2020

gorkem2020 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Candidate run on our multi-agent room, as promised. Short version: the port builds, typechecks and passes your tests on 2026.9.2, but on our install the handoff never fires, because the source run's message-tool send is not recorded as completed source-reply delivery evidence.

Setup

  • Fleet: OpenClaw 2026.9.2 (3928bad), pi-runtime agents in Docker sandboxes, Slack socket mode, private room with two agents and one human. Queue mode set to followup for the run so that a mid-turn peer message becomes a queued successor instead of being steered into the active run (with the default steer, all four of our earlier attempts were steered and no successor ran).
  • Candidate: the 9 commits of this PR cherry-picked onto v2026.9.2 with three conflict adaptations, plus one fixture adjustment for the newer createMinimalRun tool-authority binding. Branch: candidate/127967-on-2026.9.2. pnpm tsgo green, all eight test files this PR touches green, full auto-reply-reply shard green apart from one pre-existing failure that also fails on the pristine tag.
  • Pattern per run: agent A posts a tool-heavy research question to agent B (web search, source citations), then a short peer acknowledgement 12 seconds later, while B's turn is still running. B replies through the message tool (action: send to the room channel). Message ids and user ids redacted below; times are local, seconds resolution.

Pristine 2026.9.2, followup mode (two runs)

  • Run A: question 22:01:10, peer ack 22:01:24 (queued), B's answer posted 22:01:54, source run completed 22:02:02, successor run 22:02:02 to 22:02:21. Successor prompt carried the peer ack plus the bare "final assistant text is not automatically delivered" hint and no completed-reply fact. B's successor completion: "Already posted the ... research in the main channel" (kept internal, no repost this time).
  • Run B: question 22:06:02, peer ack 22:06:15, answer 22:06:28, successor answered the ack at 22:06:56. Same prompt shape.

Candidate, followup mode (two runs)

  • Run C: question 22:11:02, peer ack 22:11:15, answer 22:11:31, source run completed 22:11:38, successor 22:11:39 to 22:12:03. Successor prompt: peer ack plus the bare delivery hint, no handoff directive.
  • Run D: unmentioned variant (plain message event instead of app_mention), same result.

Why the directive never appears on our install (corrected 2026-09-08)
The gateway's message-tool-only outcome store logs every one of B's room replies as outcome: "mute", on pristine and candidate alike, although the send visibly landed. mute means hasCompletedSourceReplyDeliveryEvidence(result) is false, so recordSourceReplyEvidence never mints the fact and consumeQueuedReplyCompletionHandoff has nothing to hand over. My first reading blamed the sandboxed tool path for losing the source-turn correlation; that was wrong, the source turn id is present. Replaying the shipped predicate against the captured tool calls shows the real cause: B's model always names its route (channel, target, accountId) in the message call, and isDeliveredMessageToolOnlySourceReplyResult rejects any explicit-route send unless the allowExplicitSourceRoute rescue from #113554 fires, which it does not for an ordinary explicit channel send on the embedded path (account and thread identity axes). Agent A, whose model sends implicitly, records tool_delivered for the same kind of reply in the same room. Details, permalinks and the replay are in #142037. Net effect for this PR is unchanged: an explicit-route agent never produces the evidence, so the handoff fact is never minted for it; letting the fact also accept a delivered send whose receipt resolves to the source route would close that gap.

Happy to re-run with any instrumentation you want, and the branch above is yours to diff for the adaptations.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Oct 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L and removed size: XL labels Oct 27, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @HermanZeng for the investigation and detailed handoff work. The queue-owner fix has landed in #189240, with your coauthor credit preserved. Its regression was red on pre-fix main and green with the fix, preserving fresh successor requests and ordered, one-time queue execution. Closing this as superseded.

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

Labels

gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

3 participants