Skip to content

feat: let message-tool deployments keep unsent finals private - #203501

Open
jzmudzinski wants to merge 2 commits into
openclaw:mainfrom
jzmudzinski:fix/strict-private-replies
Open

jzmudzinski wants to merge 2 commits into
openclaw:mainfrom
jzmudzinski:fix/strict-private-replies

Conversation

@jzmudzinski

@jzmudzinski jzmudzinski commented Nov 22, 2026 •

Copy link
Copy Markdown

Related: #159230

What Problem This Solves

With messages.visibleReplies: "message_tool", final assistant text is private: only message(action=send) reaches the chat. When a required turn ends with a final but no send, OpenClaw runs one recovery turn that quotes the private final back to the model and asks it to send it, then posts a fixed English notice ("No answer was returned. Ask again if you still need one.") if that also fails. Deployments that use the final as a private scratchpad (support agents, ambient Slack/Telegram rooms) have no way to turn this off, so private notes can be republished into DMs and channel threads, and customers get an English system notice in their own-language chat. Reports in the issue cover WhatsApp/Telegram DMs and Slack channel threads on 2026.9.x–2026.10.8.

User Impact

User impact: operators can set messages.strandedReplyRecovery: "off" to keep unsent finals private. The turn then ends quietly: no recovery turn, no missing-answer notice, and the existing metadata-only source-reply/private-final warning in the Gateway log. The default ("retry") is unchanged, so existing deployments behave exactly as before; no migration.

Why This Change Was Made

Product direction (the issue is labeled needs-product-decision): this follows the ClawSweeper recommendation, an explicit opt-in strict privacy setting that keeps today's recovery default.

  • One decision owner: resolveStrandedReplyRecovery now reads the setting and returns kept-private; all three callers (direct reply, queued follow-up, and the second-miss diagnostic) already go through it, so no caller re-implements the policy.
  • The queued follow-up path treats a kept-private final as an intentional outcome, so it neither fails the reply operation with the missing-answer error nor appends the notice.
  • The operator warning moved from deliverFollowupDecision to the decision itself (as the direct path already does), so "off" and "retry" log the same metadata-only line. This also keeps followup-delivery.ts under the 700-line cap.

Alternatives considered:

  • Make "off" the default for message_tool. Rejected for now: weaker tool-callers rely on the retry to avoid silently lost answers, and changing upgrade behavior is a maintainer call. The new key makes flipping the default a one-line change later.
  • A third visibleReplies value (for example "message_tool_strict"). Rejected: it couples two concerns and touches every visibleReplies comparison, the group override, and Doctor previews.
  • Per-agent or per-channel override. Not added, because visibleReplies itself is root-level only; it can follow the same shape if needed.

Scope of the guarantee: "off" covers stranded-final recovery only. An answer produced by isolated settled-turn finalization (#184830) is a separate path and can still be delivered; the help text and docs say so explicitly. Localization of host notices is also out of scope.

Evidence

Real model on an isolated Gateway

Built from this branch (pnpm build:runtime, Node 26.13.1). Each run used a fresh isolated Gateway: its own HOME, OPENCLAW_STATE_DIR and config in a temp dir, a free loopback port, token auth, started with a clean environment (env -i). No other Gateway or state was touched. Model openai/gpt-5.4-mini (via the Codex harness the Gateway auto-enabled). The workspace AGENTS.md told the agent never to call message and to end every turn with a final starting PRIVATE NOTE:. One WebChat turn (chat.send, "Hi! What is the capital of France?"), then chat.history after 75 s.

Config Recovery turn Sent to chat Notice Gateway log
visibleReplies: "message_tool" (default retry) yes message(send): "The capital of France is Paris." (the private final, republished) no private-final warning
same + strandedReplyRecovery: "off" no nothing no private-final warning
chat.history readout
### default (retry)
user      :: Hi! What is the capital of France?
assistant :: PRIVATE NOTE: The capital of France is Paris.
assistant :: [toolCall:message]
assistant :: The capital of France is Paris.
toolResult:: Sent visible reply to the current source conversation via internal-ui.
log: [source-reply/private-final] agent produced a private final reply without calling the configured delivery tool (message_tool_only); response kept private and not delivered to the source channel sessionKey=agent:main:main channel=webchat chars=45

### strandedReplyRecovery: "off"
user      :: Hi! What is the capital of France?
assistant :: PRIVATE NOTE: The capital of France is Paris.
log: [source-reply/private-final] agent produced a private final reply without calling the configured delivery tool (message_tool_only); response kept private and not delivered to the source channel sessionKey=agent:main:main channel=webchat chars=45

Not covered live: Slack/Telegram channels (the decision is channel-independent and the same code path runs for WebChat), and the second-miss diagnostic for a retry that was already queued before the setting changed (covered by the retry=true regression below).

Upgrade from the latest stable (2026.11.6)

One isolated state directory and config, used by both versions in turn: [email protected] installed from npm into a temp prefix, then this branch's build (d63cd7ccab8; the follow-up commit only changes help text and docs). Same isolated setup as above (own HOME, state, config, port, env -i), same model and workspace AGENTS.md, config messages.visibleReplies: "message_tool" with no strandedReplyRecovery key.

Phase Version What happened
1 2026.11.6 Private final stranded → recovery turn → message(send) "The capital of France is Paris." (the reported behavior)
2 branch, same state and config Startup upgraded the state (state/openclaw.sqlite v36, agent database v38, previous files kept as *.pre-2026.11.6-…). Phase 1 history intact. With no new key, default recovery still runs: "The capital of Italy is Rome." republished
3 branch, after openclaw config set messages.strandedReplyRecovery off Applied by hot reload ("No gateway restart needed"; [reload] config change applied (dynamic reads: messages.strandedReplyRecovery …)). The turn ends with the private final only: no recovery turn, no send, no notice. Phases 1–2 history intact
chat.history after phase 3
user      :: Phase 1 (stable): what is the capital of France?
assistant :: PRIVATE NOTE: The capital of France is Paris.
assistant :: [toolCall:message]
assistant :: The capital of France is Paris.
toolResult:: Sent visible reply to the current source conversation via internal-ui.
user      :: Phase 2 (branch, default): what is the capital of Italy?
assistant :: PRIVATE NOTE: The capital of Italy is Rome.
assistant :: [toolCall:message]
assistant :: The capital of Italy is Rome.
toolResult:: Sent visible reply to the current source conversation via internal-ui.
user      :: Phase 3 (branch, off): what is the capital of Spain?
assistant :: PRIVATE NOTE: The capital of Spain is Madrid.

Regression tests

New cases fail on origin/main and pass with this change:

  • agent-runner.private-final.runreplyagent.test.ts — "keeps the final private with no retry or notice when recovery is off" for a first miss (base: retry enqueued) and a leftover retry run (base: missing-answer notice).
  • followup-delivery.test.ts — "keeps a stranded final private when strandedReplyRecovery is off" with and without final payloads (base: retry-source-delivery; without the fix the payload-less case also gets the notice and a failed operation).
Commands
pnpm test src/auto-reply/reply/stranded-reply-recovery.test.ts src/auto-reply/reply/followup-delivery.test.ts \
  src/auto-reply/reply/followup-runner.test.ts src/auto-reply/reply/agent-runner.private-final.runreplyagent.test.ts \
  src/auto-reply/reply/queue.authority.test.ts src/config/schema.help.quality.test.ts src/config/schema.test.ts \
  src/config/schema.base.generated.test.ts src/config/schema.field-metadata.test.ts
pnpm tsgo && pnpm tsgo:core:test
pnpm exec oxlint <changed files>; pnpm format:check; pnpm format:docs:check; git diff --check
pnpm config:schema:check; pnpm config:docs:gen   # baseline hash + count updated for the new key

@clawsweeper

clawsweeper Bot commented Nov 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Nov 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds messages.strandedReplyRecovery so operators can disable stranded-final retries and their missing-answer notices while preserving recovery by default.

Example: A message-tool turn ends with “PRIVATE NOTE: The capital of France is Paris.” without calling message(action=send).

  • Before: OpenClaw starts a recovery turn that can publish the answer.
  • After: With messages.strandedReplyRecovery set to off, that recovery is skipped and a metadata-only warning is logged.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused implementation with useful production evidence and no definite findings; product direction remains unresolved and exact-head CI awaits workflow approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded isolated Gateway runs exercise chat.send and chat.history with a real model, showing recovery under the default and no retry, send, or notice with off; the shared-state upgrade preserves history and default behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: Recovery can ask the model to publish a final intended as private notes and can post an unwanted English notice into the source conversation.
Reason: The opt-out has concrete user value and preserves existing defaults, but introduces a public policy choice; isolated finalization and notice localization remain outside its scope.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it provides a focused opt-out that current main lacks, but adding this recovery policy still needs a maintainer decision.

Reviewed head: 7e5b32daba43c806bde2d287e9b4bf0977ae27b5
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should OpenClaw add messages.strandedReplyRecovery: off to suppress stranded-final recovery and its notice while leaving isolated settled-turn finalization unaffected?
  • Recommendation: Approve the scoped opt-out: Accept the documented silence tradeoff for deployments that explicitly enable off, keeping retry as the default.
  • Why: The implementation follows a concrete deployment need, but the new public setting changes an intentionally designed reply obligation and has no recorded maintainer approval.

Before merge

  • Await maintainer action - Approve the awaiting GitHub Actions workflows for the reviewed head so required CI can run.

Findings

None.

Agent review details

How this fits together

The shared reply-recovery owner consumes terminal reply facts, delivery evidence, and configuration; foreground and queued reply paths consume its recovery decision before source delivery.

flowchart TD
  A[Agent terminal result] --> B[Reply completion facts]
  B --> C[Shared stranded recovery decision]
  D[Messages configuration] --> C
  C --> E[Recovery retry or notice]
  C --> F[Private final and operator warning]
  E --> G[Source conversation]
Loading

Technical review

Best possible solution:

Approve the narrowly documented opt-out while retaining default recovery and tracking isolated finalization separately.

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

Current-main source deterministically retries an eligible unsent final; the contributor also supplies isolated real-model Gateway output demonstrating that behavior.

Is this the best way to solve the issue?

The existing shared recovery owner is the smallest appropriate implementation boundary, and the documentation accurately limits the guarantee to this recovery path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Default stranded-final recovery changes intended behavior with a stated reason (Recover stranded message-tool finals by default #99536: Prevent successful message-tool turns from silently losing substantive answers through a guarded retry and sanitized failure notice.)
  • Shared recovery decision and queued delivery keeps the original intent (0776872: Share foreground recovery policy with queued follow-up execution instead of copying it.)
  • Explicit silence and terminal reply facts keeps the original intent (bd5f760: Distinguish deliberate NO_REPLY, missing results, and undelivered answers through canonical terminal classification.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0776872 adds src/auto-reply/reply/stranded-reply-recovery.ts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0776872712de; files: src/auto-reply/reply/stranded-reply-recovery.ts)

PR surface

Source +18, Tests +61, Docs +1, Generated +1. Total +81 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 37 19 +18
Tests 5 63 2 +61
Docs 2 2 1 +1
Config 0 0 0 0
Generated 3 4 3 +1
Other 0 0 0 0
Total 17 106 25 +81

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
New configuration surface 1 optional setting messages.strandedReplyRecovery accepts retry or off; omission preserves existing recovery.

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Have the feature owner decide whether to accept the scoped recovery opt-out.
  • Approve the awaiting GitHub Actions workflows and obtain the required exact-head CI result.

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 (4 earlier review cycles)
  • reviewed 2026-11-22T14:06:52.689Z sha d63cd7c :: needs real behavior proof before merge. :: [P2] [P2] Limit the documented privacy guarantee to stranded recovery
  • reviewed 2026-11-22T14:51:39.745Z sha d78be73 :: ready, awaiting a maintainer decision. :: none
  • reviewed 2026-11-26T09:46:51.676Z sha 3ff8827 :: blocked before merge. :: none
  • reviewed 2026-11-27T19:59:30.812Z sha 2e0941d :: blocked before merge. :: none

Reviewed November 29, 2026, 5:48 AM ET / 10:48 UTC (Revision 5).

@jzmudzinski

Copy link
Copy Markdown
Author

@clawsweeper re-review

Addressed: the help text and both config docs now limit off to stranded-final recovery and name isolated settled-turn finalization (#184830) as unaffected (d78be73). Added a latest-stable upgrade run (2026.11.6 → this branch on one state directory) to the PR body: the state upgrades, earlier history survives, default recovery is unchanged, and off applies through hot reload.

@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. 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 Nov 22, 2026
@jzmudzinski
jzmudzinski force-pushed the fix/strict-private-replies branch from d78be73 to 3ff8827 Compare November 26, 2026 08:55
@jzmudzinski

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jzmudzinski

Copy link
Copy Markdown
Author

@steipete decision needed: messages.strandedReplyRecovery: "off" lets message-tool-only deployments skip stranded-final recovery (no re-prompt to publish, no fixed English notice). Default unchanged. OK to add this opt-out?

@jzmudzinski

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Add messages.strandedReplyRecovery ("retry" default, "off"). With "off", a message_tool run that ends with final text but no message(action=send) keeps that text private: no recovery turn re-prompts the model to publish it, and no missing-answer notice is posted to the chat. The Gateway still logs the metadata-only private-final warning.

Related: openclaw#159230
@jzmudzinski
jzmudzinski force-pushed the fix/strict-private-replies branch from 2e0941d to 7e5b32d Compare November 29, 2026 10:42
@jzmudzinski

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

This branch has not been deployed

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant