Repository navigation
fix(reply): preserve streamed partials on run failure - #117603
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 12:19 PM ET / 16:19 UTC. ClawSweeper reviewWhat this changesThe branch records successfully delivered partial replies, converts later non-heartbeat failures into a terminal error payload, and has Telegram append that notice to the existing streamed answer draft instead of clearing it or sending a duplicate message. Merge readinessKeep this PR open for normal merge review. The prior lifecycle-state finding is addressed: recovery now records Priority: P1 Review scores
Verification
How this fits togetherThe reply runner feeds streamed partials to channel callbacks and then returns a final payload or throws. Telegram maps those callbacks to one editable answer-draft message, so the failure path must retain delivery state and finalize that same message when a later run step fails. flowchart LR
A[Telegram inbound message] --> B[Reply runner]
B --> C[Awaited partial callback]
C --> D[Telegram answer draft]
B --> E{Run outcome}
E -->|Success| F[Normal final reply]
E -->|Failure after delivery| G[Terminal error payload]
G --> D
D --> H[One finalized visible message]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +101, Tests +247. Total +348 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the canonical core recovery with the Telegram in-place finalizer once the exact-head checks complete successfully; retain the explicit heartbeat, abort, no-visible-output, and failure-operation guards as the permanent boundary. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence. Current main rethrows the unexpected failure after an already delivered partial, while the branch’s focused runner, dispatch, and composed Telegram regressions exercise the repaired default draft path; this read-only review did not execute them locally. Is this the best way to solve the issue? Yes. The repair records delivery at the awaited callback boundary, recovers at the canonical reply owner, and lets Telegram finalize its existing draft, avoiding a channel-specific core workaround or duplicate fallback path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7fc1089d95c2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Blocking P1: the current patch still misses the exact default Telegram streaming path reported in #108586.
Therefore the ordinary reported scenario—visible Telegram draft, then an unexpected model failure—still follows the throw/cleanup path and loses the draft. The new runner test enables block streaming, while the Telegram test injects a final error payload directly; neither composes the actual reporter path. Please account for genuinely delivered |
|
Addressed in
Validation on this head:
I also updated the PR body with the exact commands and explicitly kept composed runtime evidence separate from the still-unavailable live Telegram transport proof. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
57c4cf3 to
6a67980
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
ac48001 to
ab609f0
Compare
|
Landed via squash on
Thanks @dineshsuthar123! |
…delta after a preview is visible (#171417) * fix(reply): stop re-sanitizing streamed Telegram replies on every delta #118349 made partial reply text a lazy getter so Telegram sanitizes it only when its draft stream flushes a preview. The visible-partial checks from #117603 read that text after every visible partial, which runs sanitizeUserFacingText over the whole cumulative reply on every model delta once a preview is visible (progress mode after any tool call, and partial mode). The checks only set a flag that never resets and that only failure handling reads, so stop reading once it is set. Both checks need this: the getter is memoized per payload, so either one reading it runs the sanitizer. On the Telegram dispatch path a 24k-character reply drops from about 1.0 s to 0.1 s of Gateway CPU, and from about 48 s to 1 s when a line starts with a Markdown link; Telegram sends are unchanged. * test(reply): bound lazy preview sanitization regressions Extend the Telegram-style visibility regressions to hundreds of deltas, including initially hidden or sanitizer-empty content and entity/markup boundaries. Preserve canonical whole-snapshot sanitization at consumption and the existing terminal failure recovery contract. Remove a duplicate comment without expanding production code. Original fix by @boeingchoco for #171416. Co-authored-by: boeingchoco <[email protected]> * test(reply): prepare session facts for recovery authorization CI exposed a recovery fixture calling the synchronous authorization consumer without preparing its session facts. Use the existing async owner and release the retained authorization after the test. Preserve the live authority assertion and every recovery assertion. --------- Co-authored-by: boeingchoco <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…delta after a preview is visible (openclaw#171417) * fix(reply): stop re-sanitizing streamed Telegram replies on every delta openclaw#118349 made partial reply text a lazy getter so Telegram sanitizes it only when its draft stream flushes a preview. The visible-partial checks from openclaw#117603 read that text after every visible partial, which runs sanitizeUserFacingText over the whole cumulative reply on every model delta once a preview is visible (progress mode after any tool call, and partial mode). The checks only set a flag that never resets and that only failure handling reads, so stop reading once it is set. Both checks need this: the getter is memoized per payload, so either one reading it runs the sanitizer. On the Telegram dispatch path a 24k-character reply drops from about 1.0 s to 0.1 s of Gateway CPU, and from about 48 s to 1 s when a line starts with a Markdown link; Telegram sends are unchanged. * test(reply): bound lazy preview sanitization regressions Extend the Telegram-style visibility regressions to hundreds of deltas, including initially hidden or sanitizer-empty content and entity/markup boundaries. Preserve canonical whole-snapshot sanitization at consumption and the existing terminal failure recovery contract. Remove a duplicate comment without expanding production code. Original fix by @boeingchoco for openclaw#171416. Co-authored-by: boeingchoco <[email protected]> * test(reply): prepare session facts for recovery authorization CI exposed a recovery fixture calling the synchronous authorization consumer without preparing its session facts. Use the existing async owner and release the retained authorization after the test. Preserve the live authority assertion and every recovery assertion. --------- Co-authored-by: boeingchoco <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes #108586.
Telegram's default answer-draft path disables block streaming, so visible partial text is delivered through
onPartialReply. If the model run then failed unexpectedly, the canonical runner did not know that Telegram had already shown output and the draft was cleared during cleanup.What Changed
onPartialReplycallback succeeds.Maintainer Follow-up
This head covers the exact default path called out in review:
disableBlockStreaming: truefor the default answer draft.onPartialReply.The composed Telegram ingress regression invokes the real buffered dispatch runtime. It no longer injects a final error payload directly.
Evidence
ab609f08e16: 2 passed; assertsrun_failedwhile the terminal reply remains deliverable.\n- Telegram composed draft + lane-delivery suites rerun onab609f08e16: 58 passed.\n- Focused oxfmt, oxlint,git diff --check, and full build: passed.Real Telegram transport proof
Run on rebased head
6a67980be3a1cb4003bc76e21abe0e925801efebwith a real Telegram QA user through TDLib, the real SUT bot, a temporary Gateway, and a mock Responses provider. The provider streamedOPENCLAW_PARTIAL_117603, waited six seconds, and completed successfully. A proof-only, uncommitted fault hook then threw from the same post-run usage-accounting boundary used by the red regression.The redacted TDLib recording completed with exactly one SUT message. Its final text retained the streamed partial and appended the terminal notice. It recorded no clear, deletion, or second SUT message.
{ "scenario": "telegram-group-partial-then-post-run-failure", "head": "6a67980be3a1cb4003bc76e21abe0e925801efeb", "transport": "real Telegram Bot API + TDLib", "faultBoundary": "post-run usage accounting", "recordingComplete": true, "sutMessageCount": 1, "finalText": "OPENCLAW_PARTIAL_117603\n\n⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.", "draftCleared": false, "duplicateMessage": false, "verdict": "pass" }Commands: