Repository navigation
Conversation
Adds a new replyMode option to agent defaults that suppresses automatic text delivery (block replies, streaming, and final replies). Only explicit message tool sends are delivered. Use case: shared-session setups (e.g. single WhatsApp number) where plain-text auto-replies could leak to unintended recipients. Three enforcement points in dispatch-from-config.ts: - onToolResult: skip text-only payloads (media still delivered) - onBlockReply: skip all streaming blocks - final replies loop: iterate empty array in tool-only mode Closes #32884 Closes #50207
Related IssuesThis PR addresses the core problem described across several open issues:
How this PR relatesThis implements what #25592 commenters called Option 3 (explicit send semantics) — the agent's bare text output is suppressed when It's been running in production on a WhatsApp shared-session setup since February 9, 2026 — zero narration leaks across 7+ weeks of daily use with Claude Opus 4.6. What this does NOT solve
|
Greptile SummaryThis PR introduces a new Key changes:
Findings:
Confidence Score: 5/5
Prompt To Fix All With AIReviews (1): Last reviewed commit: "feat(agents): add replyMode tool-only to..." | Re-trigger Greptile |
| elevatedDefault: z | ||
| .union([z.literal("off"), z.literal("on"), z.literal("ask"), z.literal("full")]) | ||
| .optional(), | ||
| replyMode: z.enum(["auto", "tool-only"]).optional().default("auto"), |
There was a problem hiding this comment.
Zod schema type inconsistency with TypeScript declaration
.optional().default("auto") changes the Zod output type to "auto" | "tool-only" (never undefined), but AgentDefaultsConfig in types.agent-defaults.ts declares the field as replyMode?: "auto" | "tool-only" (optionally undefined). This creates a mismatch between the Zod-inferred type and the hand-written TypeScript type.
Every other similar optional field in this schema (e.g. verboseDefault, elevatedDefault, blockStreamingDefault) uses just .optional() with no .default(). The inconsistency means:
- Code reading from a Zod-parsed config can assume
replyModeis always"auto"or"tool-only", yet the TypeScript type says it may beundefined. - The
?? "auto"fallbacks indispatch-from-config.tsbecome redundant (though harmless) after Zod parsing.
To stay consistent with the rest of the schema, either drop .default("auto"):
| replyMode: z.enum(["auto", "tool-only"]).optional().default("auto"), | |
| replyMode: z.enum(["auto", "tool-only"]).optional(), |
…and keep the ?? "auto" guards in dispatch-from-config.ts as-is, OR keep .default("auto") and remove the ? from the TypeScript type declaration in types.agent-defaults.ts so both agree that the field is always present after parsing.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/zod-schema.agent-defaults.ts
Line: 168
Comment:
**Zod schema type inconsistency with TypeScript declaration**
`.optional().default("auto")` changes the Zod output type to `"auto" | "tool-only"` (never `undefined`), but `AgentDefaultsConfig` in `types.agent-defaults.ts` declares the field as `replyMode?: "auto" | "tool-only"` (optionally `undefined`). This creates a mismatch between the Zod-inferred type and the hand-written TypeScript type.
Every other similar optional field in this schema (e.g. `verboseDefault`, `elevatedDefault`, `blockStreamingDefault`) uses just `.optional()` with no `.default()`. The inconsistency means:
- Code reading from a Zod-parsed config can assume `replyMode` is always `"auto"` or `"tool-only"`, yet the TypeScript type says it may be `undefined`.
- The `?? "auto"` fallbacks in `dispatch-from-config.ts` become redundant (though harmless) after Zod parsing.
To stay consistent with the rest of the schema, either drop `.default("auto")`:
```suggestion
replyMode: z.enum(["auto", "tool-only"]).optional(),
```
…and keep the `?? "auto"` guards in `dispatch-from-config.ts` as-is, OR keep `.default("auto")` and remove the `?` from the TypeScript type declaration in `types.agent-defaults.ts` so both agree that the field is always present after parsing.
How can I resolve this? If you propose a fix, please make it concise.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c87b7d3460
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if ((cfg.agents?.defaults?.replyMode ?? "auto") === "tool-only" && !hasMedia) { | ||
| return; |
There was a problem hiding this comment.
Allow exec-approval payloads through tool-only gate
When agents.defaults.replyMode is set to "tool-only", this early return suppresses every non-media onToolResult payload before resolveToolDeliveryPayload runs, which bypasses the existing channelData.execApproval exception path. In approval-required flows, the pending-approval prompt is text/interactive without media, so users never receive the approval message and cannot approve/deny the command, leaving those tool runs blocked.
Useful? React with 👍 / 👎.
Addresses Greptile review: every other optional field in the schema uses just .optional() without .default(). The ?? 'auto' fallbacks in dispatch-from-config.ts already handle the undefined case correctly.
|
Good catch on the |
When replyMode is tool-only, the early return in onToolResult suppresses every non-media payload before resolveToolDeliveryPayload runs. This bypasses the existing channelData.execApproval exception path, so users never receive exec approval prompts and commands stay blocked forever. Fix: check for execApproval in channelData before suppressing, same pattern already used downstream in resolveToolDeliveryPayload. Addresses review feedback on PR #57914.
|
Fixed in 86eee89 — exec-approval payloads now pass through the tool-only gate. The What changed:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86eee89012
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if ((cfg.agents?.defaults?.replyMode ?? "auto") === "tool-only" && !hasMedia && !isExecApproval) { | ||
| return; |
There was a problem hiding this comment.
Permit exec-unavailable prompts in tool-only mode
This guard drops all text-only tool results in tool-only mode unless channelData.execApproval is present, which unintentionally suppresses exec-approval unavailable notifications emitted by buildExecApprovalUnavailableReplyPayload (those payloads are text-only). In approval-required environments where no approval route exists (or only approver DMs were sent), users now receive no explanation and command attempts appear to fail silently, which breaks command UX and troubleshooting.
Useful? React with 👍 / 👎.
|
Update: The exec-approval-unavailable payload issue flagged in review has been addressed in a separate upstream PR: #60445 That PR adds Once #60445 is merged, this PR's tool-only gate ( This keeps the two PRs independent and mergeable in any order. |
Update the tool-only replyMode gate to also pass through payloads with channelData.execApprovalUnavailable, matching the marker added in #60445. Without this, approval-unavailable notifications are silently dropped in tool-only mode, causing a total blackout. Co-authored-by: Aurora <[email protected]>
|
Updated the tool-only gate to recognize The gate now checks for both |
|
Addressed review feedback:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d170ba1e2e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const isToolOnlyMode = (cfg.agents?.defaults?.replyMode ?? "auto") === "tool-only"; | ||
|
|
||
| let queuedFinal = false; | ||
| let routedFinalCount = 0; | ||
| for (const reply of replies) { | ||
| for (const reply of isToolOnlyMode ? [] : replies) { |
There was a problem hiding this comment.
Enforce tool-only mode before ACP dispatch
replyMode: "tool-only" is only applied in the non-ACP delivery loop (isToolOnlyMode ? [] : replies), but tryDispatchAcpReply(...) can return earlier in the same function; in ACP-enabled sessions this bypasses all new suppression logic and still delivers projected block/final text. That means users who enable tool-only mode to prevent narration leakage in shared sessions will still leak assistant text whenever the turn is handled by ACP.
Useful? React with 👍 / 👎.
tryDispatchAcpReply runs before the tool-only gates, so ACP-enabled sessions bypass all replyMode suppression. This adds replyMode awareness to the ACP delivery coordinator: - Filter in deliver(): suppress block payloads and text-only final payloads when replyMode is tool-only, while allowing tool summaries, media, and error payloads through - Guard identity notices emission in tool-only mode - Guard finalizeAcpTurnOutput to prevent wasted TTS synthesis - Pass replyMode to both main and tail ACP dispatch calls - Fix missing suppressUserDelivery in tail dispatch (pre-existing bug) Co-authored-by: Aurora <[email protected]>
New commit: enforce tool-only mode in ACP dispatch pathAddresses Codex review finding: What changed (3 files, +33 lines, 6 new tests):
Tests: 6 new test cases covering the tool-only filter matrix (block suppressed, tool delivered, text-only final suppressed, media final delivered, error final delivered, auto mode preserved). AI-assisted (Aurora + Claude Opus 4.6). Adversarial review completed (2 rounds, GPT 5.4). |
All review conversations addressed
All findings have been addressed. Resolving these review conversations. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f0255a7ab
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (params.replyMode === "tool-only") { | ||
| if (kind === "block") { | ||
| return false; | ||
| } | ||
| if (kind === "final") { |
There was a problem hiding this comment.
Suppress ACP tool summaries in tool-only mode
When agents.defaults.replyMode is "tool-only", this guard suppresses only block and text-only final payloads, so all kind === "tool" payloads still get delivered. In ACP flows, createAcpReplyProjector emits status/tool-call summary text through deliver("tool", ...), so ACP-enabled sessions continue auto-sending generated narration/status text instead of only explicit message tool sends. This leaks text in the exact shared-session scenario tool-only is meant to protect.
Useful? React with 👍 / 👎.
ACP projector emits status narration and tool call summaries via
deliver("tool", ...). These are auto-generated text that should be
suppressed in tool-only mode, not real tool execution results.
Addresses Codex P1 review finding on PR #57914.
Co-authored-by: Aurora <[email protected]>
|
Fixed in latest push — ACP tool summaries now suppressed in tool-only mode. The Test added verifying the suppression + orthogonality with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 518d5e80bd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let queuedFinal = false; | ||
| let routedFinalCount = 0; | ||
| for (const reply of replies) { | ||
| for (const reply of isToolOnlyMode ? [] : replies) { |
There was a problem hiding this comment.
Deliver media/error finals in tool-only mode
When agents.defaults.replyMode is "tool-only", this loop is forced to iterate over [], so all non-ACP final replies are skipped before sendFinalPayload runs. That unintentionally drops legitimate final payloads that carry mediaUrl/mediaUrls or isError (for example media directives or user-facing failure messages produced by the normal getReplyFromConfig path), so users can get a silent turn instead of the expected media/error output; ACP delivery already has explicit media/error exceptions, so this creates an inconsistent regression specific to the non-ACP path.
Useful? React with 👍 / 👎.
Selective final replies filter for tool-only modePushed What changed
WhyThe previous filter was too narrow in both paths:
Interactive-only finals (buttons/selects without text) and channelData-only finals (channel-specific rich content) are legitimate user-visible output that should not be suppressed. Co-authored-by: Aurora [email protected] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9fe3a83dfa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -165,6 +165,7 @@ export const AgentDefaultsSchema = z | |||
| elevatedDefault: z | |||
| .union([z.literal("off"), z.literal("on"), z.literal("ask"), z.literal("full")]) | |||
| .optional(), | |||
| replyMode: z.enum(["auto", "tool-only"]).optional(), | |||
There was a problem hiding this comment.
Regenerate config baseline after adding replyMode schema key
This schema addition changes the public config surface, but the generated baseline artifacts were not updated in the same commit. As a result, the config drift gate (pnpm config:docs:check, used in workflow sanity checks) will detect docs/.generated/config-baseline.json / .jsonl drift and fail until those files are regenerated and committed alongside the schema change.
Useful? React with 👍 / 👎.
Replace the blanket isToolOnlyMode ? [] : replies skip with a selective filter using a shared isNonTextVisibleFinal() helper. Text-only finals are suppressed while media, error, interactive, and channelData finals pass through. Applied to both non-ACP and ACP delivery paths for consistency. Addresses Codex review finding on PR #57914. Co-authored-by: Aurora <[email protected]>
9fe3a83 to
c8d92eb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8d92eb33d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| (cd?.execApproval && typeof cd.execApproval === "object") || | ||
| (cd?.execApprovalUnavailable && typeof cd.execApprovalUnavailable === "object"); | ||
| if ( | ||
| (cfg.agents?.defaults?.replyMode ?? "auto") === "tool-only" && | ||
| !hasMedia && |
There was a problem hiding this comment.
Allow exec-unavailable text payloads in tool-only mode
In tool-only mode this guard only exempts tool results with media or channelData.execApproval*, so plain-text exec-approval-unavailable notices are still dropped and the user gets no feedback when a command requires approval but no approval route is available. Fresh evidence: emitToolResultOutput calls onToolResult(buildExecApprovalUnavailableReplyPayload(...)), and buildExecApprovalUnavailableReplyPayload returns text-only payloads (no channelData), so isExecApprovalPayload is false and the early return suppresses the message.
Useful? React with 👍 / 👎.
Addressing latest Codex review findingsP2 — Config baseline drift: Will regenerate P1 — exec-unavailable text payloads: This is already addressed by the companion PR #60445, which adds TTS finding from our own adversarial review: Suppressing TTS synthesis of text-only finals in tool-only mode is intentional behavior. TTS audio is the same information as text — if text leaks to the wrong recipient, audio would too. The message tool handles explicit audio delivery to the correct recipient. |
When replyMode is tool-only, the early return in onToolResult suppresses every non-media payload before resolveToolDeliveryPayload runs. This bypasses the existing channelData.execApproval exception path, so users never receive exec approval prompts and commands stay blocked forever. Fix: check for execApproval in channelData before suppressing, same pattern already used downstream in resolveToolDeliveryPayload. Addresses review feedback on PR openclaw#57914.
…port feat(agents): backport replyMode "tool-only" from upstream openclaw#57914
|
Thanks for the context here. I did a careful shell check against current Current main already covers the PR’s intended safe-delivery behavior through the shipped source-delivery/send-policy path instead of a new Best possible solution: Close this PR as implemented by the existing source-delivery controls. Keep the current What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Codex review notes: model gpt-5.5, reasoning high; reviewed against f256eeba431b; fix evidence: release v2026.4.14, commit f256eeba431b. |
Summary
replyModeoption ("auto" | "tool-only") toagents.defaults. When set to"tool-only", auto-delivery of assistant text is suppressed at three enforcement points indispatch-from-config.ts. Only explicitmessagetool sends reach the channel.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
N/A — this is a new feature, not a regression fix.
Regression Test Plan (if applicable)
N/A — new feature. However, the enforcement is narrow enough that a unit test in
dispatch-from-config.test.tsmockingcfg.agents.defaults.replyMode = "tool-only"and asserting thatonToolResult/onBlockReply/ final-reply-loop produce no outbound calls would be the appropriate coverage.User-visible / Behavior Changes
agents.defaults.replyMode("auto" | "tool-only", default"auto")"tool-only":onToolResult: text-only payloads are suppressed (media payloads still delivered)onBlockReply: all streaming blocks are suppressed"auto"— zero behavior change for existing usersDiagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
{ "agents": { "defaults": { "replyMode": "tool-only" } } }Steps
agents.defaults.replyModeto"tool-only"inopenclaw.jsonExpected
messagetool sends reach WhatsAppActual
Evidence
replyMode: "tool-only"Human Verification (required)
tsgounrelated to this change).AI Disclosure
Review Conversations
Compatibility / Migration
agents.defaults.replyMode(default"auto")Risks and Mitigations
"tool-only"but agent prompt does not include message tool instructions, resulting in silent agent."auto"(zero behavior change). Documentation should note that"tool-only"requires the agent to use the message tool explicitly.