Repository navigation
fix: keep recovery prompts out of Claude chat history - #207128
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 real behavior proof before merge. What this changesThe PR marks stranded-reply recovery prompts as host input while preserving reply obligations and second-miss diagnostics. Example: A Claude CLI turn produces “The answer is ready.” without calling the required message tool.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR addresses a source-confirmed attribution bug still present on current main, using a focused producer-owned fix with no identified correctness findings. Reviewed head: Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe reply-recovery producer creates a queued model turn, the CLI adapter translates its provenance into synthetic input, and Gateway history omits Claude's native meta rows. flowchart LR
A[Undelivered final] --> B[Recovery producer]
B --> C[Queued host turn]
C --> D[CLI execution adapter]
D --> E[Claude synthetic input]
E --> F[Native meta row]
F --> G[Gateway history projection]
Technical reviewBest possible solution: Keep attribution at the recovery producer and reuse the existing synthetic-input contract while retaining delivery obligations and diagnostics. Do we have a high-confidence way to reproduce the issue? Current-main source establishes inherited human provenance reaching ordinary Claude input and an importer that accepts the resulting unmarked user row; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete repair: correct provenance at its producer, preserve the resolved reply expectation, and retain the recovery-specific diagnostic without adding text filters or another history owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 595c201f9f79. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +6, Tests +73. Total +79 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel 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 Reviewed November 27, 2026, 9:23 PM ET / November 28, 2026, 02:23 UTC. |
…provenance - Revert the retry's internal_system provenance and the missing-reply-notice guard change: the retry keeps the human turn's inputProvenance, so requester identity, continuation and MCP requester checks see the same input as before. - The CLI candidate sets promptOrigin "host" from the existing FollowupRun.strandedReplyRetry flag; the plugin runner marks host input from it or from host-generated provenance, so Claude Code saves the retry as a meta row and chat.history no longer shows it as the operator's message. - One regression test at the CLI dispatch boundary; drop the PR's other tests.
|
Evidence for head fdb0d4c (main = 450c4b6). Gateway + Control UI built in a secretless node:24.22.1 container; agent Regression test agent-runner-execution-cli-sessions.test.ts (#206304): fails with the candidate line removed (- "promptOrigin": "host"), passes at head. Pre-push: 10 touched/importer test files, 272 tests passed. |
|
Landed in 0edb7c5. With a |
Root cause: src/agents/cli-runner/execute-plugin.ts:481 marks CLI input as host-generated only from the run's input provenance, but the stranded-reply retry (src/auto-reply/reply/stranded-reply-recovery.ts:56-89) correctly keeps the human turn's provenance, so Claude Code saves the retry prompt as a plain user row and chat.history shows it as the operator's own message. Fixes openclaw#206304 Thanks @fray-ai for the report and the precise code trace, and @Tosko4 for the first fix in this PR. ## What Problem This Solves With a `claude-cli` agent and `messages.visibleReplies: "message_tool"`, a turn that ends with plain text queues the stranded-reply retry (`[System] Your previous reply was not delivered ...`). That retry reached Claude Code as ordinary user input, Claude stored it as a normal user row, and the Control UI drew it as a right-aligned operator bubble. ## User Impact The retry no longer appears as a message the operator wrote. The delivered reply still arrives. An operator who types the same `[System] ...` text still sees it as their own message, and existing history is not rewritten. Nothing changes for the embedded runtime or for permissions. ## Why This Change Was Made - The CLI candidate sets `promptOrigin: "host"` from the existing `FollowupRun.strandedReplyRetry` flag (`agent-runner-cli-candidate.ts`). `RunCliAgentParams` carries that one optional field, with the same value type `CliBackendExecuteContext.promptOrigin` already uses. - The plugin CLI runner marks host input when that field is set or when the provenance is host-generated, as before (`execute-plugin.ts`). The Claude backend then sends `isSynthetic: true`, Claude saves an `isMeta` row, and the existing history import skips it. - The retry's `inputProvenance` is unchanged (`external_user`). The first version of this PR switched it to `internal_system`; that value feeds requester-profile, continuation, collaborative-steering and personal-MCP requester checks (`reply-tool-authority.ts:353`, `reply-tool-authority-inbound.ts:83/116/214`, `agent-bundle-mcp-webchat-requester.ts:42`), reply threading and model urgency. Those changes are reverted, together with the `missingReplyNoticeAllowed` change it needed. - No text classification: an operator who types the same `[System] ...` text still sees their own bubble. Existing history is not rewritten. Production: +9/-1 lines in 3 files. Tests: one regression at the CLI dispatch boundary (+18); the PR's other tests are dropped. ## Evidence Built Gateway + Control UI from `4e9cab516ac9` (main) and this head in a secretless node:24.22.1 container. Agent `main` runs on `claude-cli` with a stand-in `claude` that writes a real Claude Code project JSONL (synthetic input -> `isMeta`) and calls the real OpenClaw MCP `message` tool; agent `embedded` runs on the OpenClaw runtime with a scripted model. Real Chromium (Playwright 1.64.1) drives WebChat sessions. Screenshots and the full table: openclaw#207128 (comment) | case | main | this PR | |---|---|---| | claude-cli stranded once: operator bubble with retry text (live / reload) | 1 / 1 | 0 / 0 | | same: delivered reply "Delivered answer P206304." | shown | shown | | same: chat.history retry row | `role: user`, no provenance, importedFrom claude-cli | absent (meta row skipped) | | Claude stdin for retry | `isSynthetic` absent | `isSynthetic: true` | | control: operator types the identical `[System] ...` text | own bubble, `external_user` | own bubble, `external_user` | | control: retry also ends with plain text (second miss) | retry shown as operator bubble; retry final shown; no "No answer" notice | no operator bubble; retry final shown; no "No answer" notice (same as main) | | control: embedded (non-CLI) agent, stranded once | no retry bubble, delivered | identical | Regression test `agent-runner-execution-cli-sessions.test.ts` "sends a stranded-reply retry as host input without changing its provenance (openclaw#206304)": fails with the candidate line removed (`- "promptOrigin": "host"`), passes at head. ## Merge danger Two-way door: no stored state, schema, config or protocol change; a revert fully restores the old behavior. Blast radius: only stranded-reply retries on plugin CLI backends (Claude CLI) change their native input marker. Co-authored-by: Ayaan Zaidi <[email protected]>
Root cause: src/agents/cli-runner/execute-plugin.ts:481 marks CLI input as host-generated only from the run's input provenance, but the stranded-reply retry (src/auto-reply/reply/stranded-reply-recovery.ts:56-89) correctly keeps the human turn's provenance, so Claude Code saves the retry prompt as a plain user row and chat.history shows it as the operator's own message. Fixes #206304 Thanks @fray-ai for the report and the precise code trace, and @Tosko4 for the first fix in this PR. ## What Problem This Solves With a `claude-cli` agent and `messages.visibleReplies: "message_tool"`, a turn that ends with plain text queues the stranded-reply retry (`[System] Your previous reply was not delivered ...`). That retry reached Claude Code as ordinary user input, Claude stored it as a normal user row, and the Control UI drew it as a right-aligned operator bubble. ## User Impact The retry no longer appears as a message the operator wrote. The delivered reply still arrives. An operator who types the same `[System] ...` text still sees it as their own message, and existing history is not rewritten. Nothing changes for the embedded runtime or for permissions. ## Why This Change Was Made - The CLI candidate sets `promptOrigin: "host"` from the existing `FollowupRun.strandedReplyRetry` flag (`agent-runner-cli-candidate.ts`). `RunCliAgentParams` carries that one optional field, with the same value type `CliBackendExecuteContext.promptOrigin` already uses. - The plugin CLI runner marks host input when that field is set or when the provenance is host-generated, as before (`execute-plugin.ts`). The Claude backend then sends `isSynthetic: true`, Claude saves an `isMeta` row, and the existing history import skips it. - The retry's `inputProvenance` is unchanged (`external_user`). The first version of this PR switched it to `internal_system`; that value feeds requester-profile, continuation, collaborative-steering and personal-MCP requester checks (`reply-tool-authority.ts:353`, `reply-tool-authority-inbound.ts:83/116/214`, `agent-bundle-mcp-webchat-requester.ts:42`), reply threading and model urgency. Those changes are reverted, together with the `missingReplyNoticeAllowed` change it needed. - No text classification: an operator who types the same `[System] ...` text still sees their own bubble. Existing history is not rewritten. Production: +9/-1 lines in 3 files. Tests: one regression at the CLI dispatch boundary (+18); the PR's other tests are dropped. ## Evidence Built Gateway + Control UI from `450c4b640ed6` (main) and this head in a secretless node:24.22.1 container. Agent `main` runs on `claude-cli` with a stand-in `claude` that writes a real Claude Code project JSONL (synthetic input -> `isMeta`) and calls the real OpenClaw MCP `message` tool; agent `embedded` runs on the OpenClaw runtime with a scripted model. Real Chromium (Playwright 1.64.1) drives WebChat sessions. Screenshots and the full table: #207128 (comment) | case | main | this PR | |---|---|---| | claude-cli stranded once: operator bubble with retry text (live / reload) | 1 / 1 | 0 / 0 | | same: delivered reply "Delivered answer P206304." | shown | shown | | same: chat.history retry row | `role: user`, no provenance, importedFrom claude-cli | absent (meta row skipped) | | Claude stdin for retry | `isSynthetic` absent | `isSynthetic: true` | | control: operator types the identical `[System] ...` text | own bubble, `external_user` | own bubble, `external_user` | | control: retry also ends with plain text (second miss) | retry shown as operator bubble; retry final shown; no "No answer" notice | no operator bubble; retry final shown; no "No answer" notice (same as main) | | control: embedded (non-CLI) agent, stranded once | no retry bubble, delivered | identical | Regression test `agent-runner-execution-cli-sessions.test.ts` "sends a stranded-reply retry as host input without changing its provenance (#206304)": fails with the candidate line removed (`- "promptOrigin": "host"`), passes at head. ## Merge danger Two-way door: no stored state, schema, config or protocol change; a revert fully restores the old behavior. Blast radius: only stranded-reply retries on plugin CLI backends (Claude CLI) change their native input marker. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0edb7c5) Co-authored-by: RomneyDa <[email protected]>
Root cause: src/agents/cli-runner/execute-plugin.ts:481 marks CLI input as host-generated only from the run's input provenance, but the stranded-reply retry (src/auto-reply/reply/stranded-reply-recovery.ts:56-89) correctly keeps the human turn's provenance, so Claude Code saves the retry prompt as a plain user row and chat.history shows it as the operator's own message. Fixes #206304 Thanks @fray-ai for the report and the precise code trace, and @Tosko4 for the first fix in this PR. With a `claude-cli` agent and `messages.visibleReplies: "message_tool"`, a turn that ends with plain text queues the stranded-reply retry (`[System] Your previous reply was not delivered ...`). That retry reached Claude Code as ordinary user input, Claude stored it as a normal user row, and the Control UI drew it as a right-aligned operator bubble. The retry no longer appears as a message the operator wrote. The delivered reply still arrives. An operator who types the same `[System] ...` text still sees it as their own message, and existing history is not rewritten. Nothing changes for the embedded runtime or for permissions. - The CLI candidate sets `promptOrigin: "host"` from the existing `FollowupRun.strandedReplyRetry` flag (`agent-runner-cli-candidate.ts`). `RunCliAgentParams` carries that one optional field, with the same value type `CliBackendExecuteContext.promptOrigin` already uses. - The plugin CLI runner marks host input when that field is set or when the provenance is host-generated, as before (`execute-plugin.ts`). The Claude backend then sends `isSynthetic: true`, Claude saves an `isMeta` row, and the existing history import skips it. - The retry's `inputProvenance` is unchanged (`external_user`). The first version of this PR switched it to `internal_system`; that value feeds requester-profile, continuation, collaborative-steering and personal-MCP requester checks (`reply-tool-authority.ts:353`, `reply-tool-authority-inbound.ts:83/116/214`, `agent-bundle-mcp-webchat-requester.ts:42`), reply threading and model urgency. Those changes are reverted, together with the `missingReplyNoticeAllowed` change it needed. - No text classification: an operator who types the same `[System] ...` text still sees their own bubble. Existing history is not rewritten. Production: +9/-1 lines in 3 files. Tests: one regression at the CLI dispatch boundary (+18); the PR's other tests are dropped. Built Gateway + Control UI from `450c4b640ed6` (main) and this head in a secretless node:24.22.1 container. Agent `main` runs on `claude-cli` with a stand-in `claude` that writes a real Claude Code project JSONL (synthetic input -> `isMeta`) and calls the real OpenClaw MCP `message` tool; agent `embedded` runs on the OpenClaw runtime with a scripted model. Real Chromium (Playwright 1.64.1) drives WebChat sessions. Screenshots and the full table: #207128 (comment) | case | main | this PR | |---|---|---| | claude-cli stranded once: operator bubble with retry text (live / reload) | 1 / 1 | 0 / 0 | | same: delivered reply "Delivered answer P206304." | shown | shown | | same: chat.history retry row | `role: user`, no provenance, importedFrom claude-cli | absent (meta row skipped) | | Claude stdin for retry | `isSynthetic` absent | `isSynthetic: true` | | control: operator types the identical `[System] ...` text | own bubble, `external_user` | own bubble, `external_user` | | control: retry also ends with plain text (second miss) | retry shown as operator bubble; retry final shown; no "No answer" notice | no operator bubble; retry final shown; no "No answer" notice (same as main) | | control: embedded (non-CLI) agent, stranded once | no retry bubble, delivered | identical | Regression test `agent-runner-execution-cli-sessions.test.ts` "sends a stranded-reply retry as host input without changing its provenance (#206304)": fails with the candidate line removed (`- "promptOrigin": "host"`), passes at head. Two-way door: no stored state, schema, config or protocol change; a revert fully restores the old behavior. Blast radius: only stranded-reply retries on plugin CLI backends (Claude CLI) change their native input marker. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0edb7c5) Follow-ups: 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048) [separately ordered lane row]; a736683 fix: show context usage during Claude CLI turns (#207036) [not selected for this narrow backport]; 75ad0b7 fix(voice): answer phone, meeting and FaceTime consults on Claude CLI agents (#202209) [not selected for this narrow backport]; b9ddb61 fix: keep saved system-event automations running after an upgrade (#207275) [not selected for this narrow backport] Release adaptation: Propagate host prompt origin at the stable CLI backend input owner while preserving original human provenance. Co-authored-by: RomneyDa <[email protected]>


![main: operator-typed [System] text](https://private-user-images.githubusercontent.com/22031114/721984758-5c4dd1a4-5c62-40e9-ae05-40be5d7a1bd8.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTYwMjQ3MDUsIm5iZiI6MTc5NjAyNDQwNSwicGF0aCI6Ii8yMjAzMTExNC83MjE5ODQ3NTgtNWM0ZGQxYTQtNWM2Mi00MGU5LWFlMDUtNDBiZTVkN2ExYmQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTMwVDA3NDAwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUzN2VjODIxNzEwOTdmMTYxZGNlYzBmODk2MzMzZDAyMGQzYTU1ZTVkOTA0NTMyYzM0YWRjNjFkYzVjMDM2MjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.AH-LMVBSJ_ESHOV5Oc_zxgMaPCoUnSCNMHd38ZxLRBA)
![fix: operator-typed [System] text still own bubble](https://private-user-images.githubusercontent.com/22031114/721984767-8f5a7e24-cd0a-46f3-bde4-7df09b69d138.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTYwMjQ3MDUsIm5iZiI6MTc5NjAyNDQwNSwicGF0aCI6Ii8yMjAzMTExNC83MjE5ODQ3NjctOGY1YTdlMjQtY2QwYS00NmYzLWJkZTQtN2RmMDliNjlkMTM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjExMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYxMTMwVDA3NDAwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZhMDA3NTFiMWEwZDVlZThiY2ZmMWE4MDliYTUzNzBkMmFjMzkwZjBjZjJjOTU0N2FiMzUyOTVhZDlkZjIxYmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9._XgS5fayBls6tmoq-K1KEve0EkZWE1rKsUNiG67NLOY)




Root cause: src/agents/cli-runner/execute-plugin.ts:481 marks CLI input as host-generated only from the run's input provenance, but the stranded-reply retry (src/auto-reply/reply/stranded-reply-recovery.ts:56-89) correctly keeps the human turn's provenance, so Claude Code saves the retry prompt as a plain user row and chat.history shows it as the operator's own message.
Fixes #206304
Thanks @fray-ai for the report and the precise code trace, and @Tosko4 for the first fix in this PR.
What Problem This Solves
With a
claude-cliagent andmessages.visibleReplies: "message_tool", a turn that ends with plain text queues the stranded-reply retry ([System] Your previous reply was not delivered ...). That retry reached Claude Code as ordinary user input, Claude stored it as a normal user row, and the Control UI drew it as a right-aligned operator bubble.User Impact
The retry no longer appears as a message the operator wrote. The delivered reply still arrives. An operator who types the same
[System] ...text still sees it as their own message, and existing history is not rewritten. Nothing changes for the embedded runtime or for permissions.Why This Change Was Made
promptOrigin: "host"from the existingFollowupRun.strandedReplyRetryflag (agent-runner-cli-candidate.ts).RunCliAgentParamscarries that one optional field, with the same value typeCliBackendExecuteContext.promptOriginalready uses.execute-plugin.ts). The Claude backend then sendsisSynthetic: true, Claude saves anisMetarow, and the existing history import skips it.inputProvenanceis unchanged (external_user). The first version of this PR switched it tointernal_system; that value feeds requester-profile, continuation, collaborative-steering and personal-MCP requester checks (reply-tool-authority.ts:353,reply-tool-authority-inbound.ts:83/116/214,agent-bundle-mcp-webchat-requester.ts:42), reply threading and model urgency. Those changes are reverted, together with themissingReplyNoticeAllowedchange it needed.[System] ...text still sees their own bubble. Existing history is not rewritten.Production: +9/-1 lines in 3 files. Tests: one regression at the CLI dispatch boundary (+18); the PR's other tests are dropped.
Evidence
Built Gateway + Control UI from
450c4b640ed6(main) and this head in a secretless node:24.22.1 container. Agentmainruns onclaude-cliwith a stand-inclaudethat writes a real Claude Code project JSONL (synthetic input ->isMeta) and calls the real OpenClaw MCPmessagetool; agentembeddedruns on the OpenClaw runtime with a scripted model. Real Chromium (Playwright 1.64.1) drives WebChat sessions. Screenshots and the full table: #207128 (comment)role: user, no provenance, importedFrom claude-cliisSyntheticabsentisSynthetic: true[System] ...textexternal_userexternal_userRegression test
agent-runner-execution-cli-sessions.test.ts"sends a stranded-reply retry as host input without changing its provenance (#206304)": fails with the candidate line removed (- "promptOrigin": "host"), passes at head.Merge danger
Two-way door: no stored state, schema, config or protocol change; a revert fully restores the old behavior. Blast radius: only stranded-reply retries on plugin CLI backends (Claude CLI) change their native input marker.