Repository navigation
fix: restore missing Telegram replies in conversation context - #179399
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR restores confirmed final message-tool replies in session-generated conversation context and retains the history cache’s memory-pressure subscription. Example: Telegram delivers FIXED:166482 through message(action=send, final=true), then the user asks what 2 + 2 equals.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR repairs a demonstrated context-loss path still present on main; no actionable introduced defect was found, and exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared channel-turn preparation reads recent canonical transcript text and renders bounded conversation context for the next agent request. flowchart LR
A[Delivered message-tool reply] --> B[Canonical session transcript]
B --> C[Recent conversation reader]
C --> D[Shared channel preparation]
E[Native channel window] --> D
D --> F[Rendered agent input]
Technical reviewBest possible solution: Land the selective restoration through the existing transcript owner once required CI passes, while retaining the broader recap report for other causes. Do we have a high-confidence way to reproduce the issue? Current main’s filter demonstrably excludes final source-reply mirrors; supplied SQLite red/green results establish the failing channel-context path, without reviewer execution. Is this the best way to solve the issue? The focused opt-in reuses the existing terminal-delivery classifier and snapshot reader while preserving native-window ownership, bounds, and stored transcript bytes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 19395491ca6a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests +184, Docs +6. Total +199 across 7 files. Added test files: 1. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 22, 2026, 11:38 PM ET / October 23, 2026, 03:38 UTC (Revision 3). |
09149f3 to
f4c4222
Compare
|
@clawsweeper re-review Added the requested real behavior proof to the PR body for exact head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…aw#179399) * fix: restore missing Telegram replies in conversation context * fix: retain history cache pressure channel and SQLite test owners
Keep replay byte bounds with upstream delivered-message context. Preserve media grounding probes with the current classifier declarations. This merge includes upstream history-cache pressure-channel retention from openclaw#179399.
* fix: restore missing Telegram replies in conversation context * fix: retain history cache pressure channel and SQLite test owners Use a private equivalent terminal-source-reply predicate because the donor shared export is absent on this candidate. Keep the current bounded connection-owned history cache unchanged rather than replay donor-only pressure-channel architecture. Retain native-window and SQLite transcript assertions. (cherry picked from commit ca3f743) Co-authored-by: RomneyDa <[email protected]>
Related: #166482
What Problem This Solves
Fixes missing completed Telegram replies in restored conversation context, which can make an already answered request look pending on a later turn.
User Impact
Delivered final answers remain beside their questions when the next turn restores conversation context, preventing this source of repeated answers to old requests.
Why This Change Was Made
The shared recent-text reader discarded confirmed final message-tool replies as delivery bookkeeping. Session-generated chat windows now opt into those replies using the existing terminal-delivery metadata. Native channel windows continue to own their delivery history; progress updates and uncorrelated legacy mirrors remain excluded.
The cache keeps its existing memory-pressure subscription strongly referenced, preserving its behavior on Bun. No SQL schema or storage format changes.
Evidence
The SQLite → channel-turn → rendered-context regression was reproduced against unchanged production: both prior questions remained while both delivered final answers disappeared, for successful and aborted tool-result cases. The candidate tests retain native-window deduplication and verify that reading context does not rewrite stored history.
The focused regression and sibling checks cover the SQLite history reader, channel context restoration, memory-pressure eviction, native-window deduplication, and prompt-prefix stability. Targeted core lint and formatting checks pass. The independent diff review found no actionable P0–P2 findings. Broad local checks pass production and test-graph typechecking, but the unused-export scans report unrelated unchanged exports; exact-head PR CI is tracked below.
Against the merge base: production +9 lines, tests +184 lines, documentation +6 lines. The small production increase adds the explicit opt-in and retains the cache subscription; the simplification pass found no useful adjacent deletion without obscuring those responsibilities.
After merging current main, all 87 tests across seven files pass through the repository runner, including its final source-integrity verification (four Vitest shards, 1300.42 seconds). The two SQLite boundary cases fail on the unchanged base and pass with this fix. Exact-head CI is green on
daea9ae482446ee8775364fdd91dbbcf105a76c3(run 39895471108).A prior live Telegram run on
f4c4222c17b9recorded the delivered answer exactly once in the next accepted model input; details below preserve that evidence and its head. A fresh live channel round trip was not run in this pass because QA broker credentials are unavailable on the test host. This fix addresses one demonstrated cause of repeated recaps, so the broader issue remains related rather than closed.Thanks to @sobolevbel for the fix and original proof.
Previously recorded live Telegram + Codex proof on f4c4222
Executed on 2026-10-21 using an isolated Gateway built from
f4c4222c17b9e848042df04eb018eefed480a4d6, separate OpenClaw state/workspace/port, disabled cron/heartbeat, and the operator's Telegram bot. A human sent both messages from the real Telegram client. The agent used Codex app-server with an existing ChatGPT subscription. No personal conversation history was copied into the test state.Sanitized launch shape:
The two messages were sent in order, waiting for the first answer:
Observed Telegram replies:
FIXED:166482, then only4. The human confirmed both and supplied a screenshot of the two exchanges. Both turns ran in the same Gateway process, with no restart between them.The read-only transcript extraction checked the successful Telegram receipt and final delivery mirror, then read B2's
message.__openclaw.upstreamUserText. The Codex integration records this from the text inputs of the accepted nativeturn/startrequest (request boundary, transcript annotation). The full answer was absent from A2's input, so its later presence cannot be explained by replaying the first question.Redacted terminal output from that extraction:
{ "head": "f4c4222c17b9e848042df04eb018eefed480a4d6", "transport": "real Telegram Bot API; human Telegram client", "runtime": "Codex app-server; existing ChatGPT subscription", "sameGatewayProcessAcrossA2B2": true, "A2": { "inputContainsFullAnswer": false, "messageToolCalls": 1, "action": "send", "final": true, "successfulTelegramReceipt": true, "receiptHasMessageId": true, "finalSourceReplyMirrors": 1, "sourceTurnIdPresent": true, "toolCallIdMatchesMirror": true, "visibleReply": "FIXED:166482" }, "B2": { "unrelatedQuestion": "what is 2 + 2?", "acceptedCodexTurnInputCaptured": true, "restoredSessionLineMatchesMirrorId": true, "restoredAssistantAnswerOccurrences": 1, "fullAnswerOccurrencesInAcceptedUserInput": 1, "acceptedUserInputSha256": "109bb238acd37e09b7c4dbc501d64e86b729a8a8fccd7644bc2a47dc49fd2147", "visibleReply": "4", "humanConfirmedNoRepeatedOldAnswer": true } }Accepted B2 input excerpt, with the original mirror ID and timestamp replaced by aliases:
The extractor verified that this line refers to the actual A2 delivery-mirror event ID, and counted
FIXED:166482once across the entire accepted B2 user input. The exactly-once claim concerns this current input and its restored Conversation context, rather than historical tool-call arguments in the native thread.Proof boundaries: this is a patched-head live run; the before-fix failure is covered by the committed SQLite → channel-turn → context red/green regression. Restart recovery is not claimed: an earlier optional restart attempt failed before model inference and was excluded. The passing A2 → B2 pair used the ordinary consecutive-turn flow.
Cleanup completed: the original installed Gateway and its configuration were restored and verified healthy, the isolated Gateway and local collector exited, and temporary credential copies and their test backup were removed. Public output omits credentials, IPs, phone numbers, private endpoints, native IDs, and model identifiers.