Skip to content

fix(agents): add channelData marker to exec-approval-unavailable payloads - #60445

Closed
qualiobra wants to merge 1 commit into
openclaw:mainfrom
qualiobra:feat/tool-only-exec-approval-allowlist
Closed

qualiobra wants to merge 1 commit into
openclaw:mainfrom
qualiobra:feat/tool-only-exec-approval-allowlist

Conversation

@qualiobra

Copy link
Copy Markdown

Summary

  • Problem: buildExecApprovalUnavailableReplyPayload returns { text: "..." } with no channelData marker, making exec-approval-unavailable payloads indistinguishable from regular assistant text at delivery gates.
  • Why it matters: In flows where delivery gates filter by payload type (e.g. the resolveToolDeliveryPayload group/native flow, and the proposed replyMode: "tool-only" gate in feat(agents): add replyMode tool-only to suppress auto-delivery #57914), unmarked unavailable payloads are silently dropped. This causes a total blackout: deterministicApprovalPromptSent is set despite the message never reaching the user, then all subsequent assistant text is also suppressed.
  • What changed: Added channelData.execApprovalUnavailable with the typed reason field to all return paths of buildExecApprovalUnavailableReplyPayload, and updated resolveToolDeliveryPayload to recognize the new marker alongside the existing execApproval check.
  • What did NOT change (scope boundary): No changes to the replyMode tool-only gate (that remains in feat(agents): add replyMode tool-only to suppress auto-delivery #57914). No interface changes, no config changes, no new abstractions.

AI-assisted: This PR was researched, planned, and implemented with AI assistance (Claude Opus 4.6 via OpenClaw).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: buildExecApprovalUnavailableReplyPayload was implemented as text-only, while its sibling buildExecApprovalPendingReplyPayload correctly sets channelData.execApproval. The unavailable path was never gated before, so the missing marker was harmless until delivery gates that filter by channelData were introduced.
  • Missing detection / guardrail: No type-level or runtime enforcement that system payloads include channelData markers. onToolResult returns Promise<void> with no delivery confirmation.
  • Prior context: buildExecApprovalPendingReplyPayload (line 254) correctly sets channelData.execApproval. The unavailable builder (line 322) was likely written before the channelData-based gating pattern was established.
  • Why this regressed now: Not a regression per se — the missing marker was always present but only became observable when resolveToolDeliveryPayload (and the proposed tool-only gate) started filtering tool results by channelData shape.
  • If unknown, what was ruled out: N/A — root cause is clear.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/infra/exec-approval-reply.tool-only.test.ts (6 tests for builder channelData), src/auto-reply/reply/dispatch-from-config.tool-only.test.ts (4 tests for delivery gate)
  • Scenario the test should lock in: buildExecApprovalUnavailableReplyPayload always produces channelData.execApprovalUnavailable with the correct reason on ALL return paths (sentApproverDms and main). resolveToolDeliveryPayload passes unavailable payloads through instead of dropping them.
  • Why this is the smallest reliable guardrail: Unit tests on the builder function directly verify the payload shape. Dispatch tests verify the gate behavior with the marker present.
  • Existing test that already covers this (if any): exec-approval-reply.test.ts:329-339 — updated from toEqual({ text }) to include the new channelData.
  • If no new test is added, why not: N/A — new tests added.

User-visible / Behavior Changes

  • Users on platforms without native exec approval support will now correctly see the "exec approval unavailable" message instead of experiencing a silent blackout where no messages are delivered.

Diagram (if applicable)

Before:
[exec tool] -> buildUnavailablePayload -> { text: "..." }
           -> resolveToolDeliveryPayload -> no execApproval marker -> DROPPED
           -> deterministicApprovalPromptSent = true -> ALL TEXT SUPPRESSED

After:
[exec tool] -> buildUnavailablePayload -> { text: "...", channelData: { execApprovalUnavailable: { reason } } }
           -> resolveToolDeliveryPayload -> execApprovalUnavailable marker found -> DELIVERED
           -> user sees the unavailable message

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS (Darwin 25.3.0, arm64)
  • Runtime/container: Node v25.6.1
  • Model/provider: Any (payload-level fix, model-independent)
  • Integration/channel (if any): Any channel without native exec approval (e.g. WhatsApp, platforms with approvals disabled)
  • Relevant config (redacted): execApprovals configured but no approval route available

Steps

  1. Configure OpenClaw with exec approvals enabled but no approval client available
  2. Trigger an exec tool call requiring approval
  3. Before fix: silent blackout (no message delivered, all subsequent text suppressed)
  4. After fix: user sees the "exec approval unavailable" message with the reason

Expected

  • User receives the exec-approval-unavailable message explaining how to set up approval

Actual

  • Before fix: total blackout — no message delivered, deterministicApprovalPromptSent silences everything

Evidence

  • Failing test/log before + passing after
  • Updated existing test at exec-approval-reply.test.ts:329-339 (was toEqual({ text }), now includes channelData)
  • New unit tests: 6 in exec-approval-reply.tool-only.test.ts, 4 in dispatch-from-config.tool-only.test.ts

Human Verification (required)

  • Verified scenarios: Code review of all 3 changed files, verified line numbers with grep against upstream, confirmed test assertions match expected payload shapes
  • Edge cases checked: sentApproverDms path (early return), all 3 reason types, dual-marker edge case (both execApproval and execApprovalUnavailable)
  • What you did not verify: Full E2E through pi-embedded-subscribe handlers (requires full PI runtime). Runtime verification on a live instance pending.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: shouldSuppressLocalExecApprovalPrompt in exec-approval-local.ts passes hint.kind: "approval-pending" for all payloads including unavailable ones. If a future plugin uses hint.kind for suppression decisions, unavailable payloads could be incorrectly suppressed.

    • Mitigation: No plugin currently implements shouldSuppressLocalPayloadPrompt. The channelData marker (execApprovalUnavailable vs execApproval) provides a reliable distinguishing mechanism at the payload level. Tracked as tech debt TD-1 for a future hint.kind: "approval-unavailable" addition.
  • Risk: onToolResult returns Promise<void> — no delivery confirmation. deterministicApprovalPromptSent is set regardless of whether delivery succeeded.

    • Mitigation: This PR ensures the specific execApprovalUnavailable payload passes through gates. The general onToolResult delivery confirmation gap is tracked as tech debt TD-2.

@greptile-apps

greptile-apps Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes buildExecApprovalUnavailableReplyPayload to include a channelData.execApprovalUnavailable marker (mirroring the existing execApproval marker on the pending path), and updates resolveToolDeliveryPayload in dispatch-from-config.ts to pass those payloads through instead of suppressing them. The fix is minimal, well-scoped, and backed by new unit tests covering all reason variants and both builder return paths.

Confidence Score: 5/5

Safe to merge — the core fix is correct and well-tested; the only finding is a P2 test performance antipattern in the new test file.

All findings are P2 (test style). The production code changes in exec-approval-reply.ts and dispatch-from-config.ts are correct, minimal, and consistent with existing patterns. No logic, security, or data-integrity concerns.

src/auto-reply/reply/dispatch-from-config.tool-only.test.ts — minor vi.resetModules() antipattern per project guidelines, but does not affect correctness.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/dispatch-from-config.tool-only.test.ts
Line: 237-246

Comment:
**`vi.resetModules()` + `await import()` in `beforeEach` antipattern**

This file uses `vi.hoisted(...)` for static mock definitions but then calls `vi.resetModules()` and reimports four heavy modules (`dispatch-from-config`, `inbound-dedupe`, `acp/control-plane/manager`, `plugins/conversation-binding`) in every `beforeEach`. The project guidelines call this out explicitly as a test performance antipattern: `acpManagerTesting.resetAcpSessionManagerForTests()` and `pluginBindingTesting.reset()` can be called on statically-imported references without module teardown. Consider importing once in `beforeAll` and resetting mock state + calling the `__testing` reset functions directly in `beforeEach` instead.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(agents): add channelData marker to e..." | Re-trigger Greptile

Comment on lines +237 to +246
let acpManagerTesting: typeof import("../../acp/control-plane/manager.js").__testing;
let pluginBindingTesting: typeof import("../../plugins/conversation-binding.js").__testing;

function createDispatcher(): ReplyDispatcher {
return {
sendToolResult: vi.fn(() => true),
sendBlockReply: vi.fn(() => true),
sendFinalReply: vi.fn(() => true),
waitForIdle: vi.fn(async () => {}),
getQueuedCounts: vi.fn(() => ({ tool: 0, block: 0, final: 0 })),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 vi.resetModules() + await import() in beforeEach antipattern

This file uses vi.hoisted(...) for static mock definitions but then calls vi.resetModules() and reimports four heavy modules (dispatch-from-config, inbound-dedupe, acp/control-plane/manager, plugins/conversation-binding) in every beforeEach. The project guidelines call this out explicitly as a test performance antipattern: acpManagerTesting.resetAcpSessionManagerForTests() and pluginBindingTesting.reset() can be called on statically-imported references without module teardown. Consider importing once in beforeAll and resetting mock state + calling the __testing reset functions directly in beforeEach instead.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/dispatch-from-config.tool-only.test.ts
Line: 237-246

Comment:
**`vi.resetModules()` + `await import()` in `beforeEach` antipattern**

This file uses `vi.hoisted(...)` for static mock definitions but then calls `vi.resetModules()` and reimports four heavy modules (`dispatch-from-config`, `inbound-dedupe`, `acp/control-plane/manager`, `plugins/conversation-binding`) in every `beforeEach`. The project guidelines call this out explicitly as a test performance antipattern: `acpManagerTesting.resetAcpSessionManagerForTests()` and `pluginBindingTesting.reset()` can be called on statically-imported references without module teardown. Consider importing once in `beforeAll` and resetting mock state + calling the `__testing` reset functions directly in `beforeEach` instead.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — moved dynamic imports to beforeAll and removed vi.resetModules() from beforeEach. The beforeEach now only resets mock state and calls __testing reset functions. Pushed in amended commit.

@qualiobra
qualiobra force-pushed the feat/tool-only-exec-approval-allowlist branch from d5ee9bc to e9453d1 Compare April 3, 2026 17:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9453d11f5

ℹ️ 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".

Comment on lines +257 to +260
vi.resetModules();
({ dispatchReplyFromConfig } = await import("./dispatch-from-config.js"));
({ resetInboundDedupe } = await import("./inbound-dedupe.js"));
({ __testing: acpManagerTesting } = await import("../../acp/control-plane/manager.js"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop resetting and re-importing dispatch module per test

AGENTS.md explicitly warns against vi.resetModules() plus await import(...) inside beforeEach for heavy modules, and this new suite does both for dispatch-from-config on every case. That forces repeated module-graph reloads in a known hotspot test surface, which increases CI runtime and memory pressure without improving coverage; this setup should be switched to one-time imports (or beforeAll) with per-test mock/state resets instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the same push — vi.resetModules() removed, imports moved to beforeAll, beforeEach only resets mock state now.

…oads

buildExecApprovalUnavailableReplyPayload returns text-only payloads
with no channelData marker. This makes them indistinguishable from
regular assistant text in delivery gates (e.g. the proposed replyMode
tool-only gate in #57914, and the existing resolveToolDeliveryPayload
group/native flow).

Without a marker, these payloads are silently dropped, which causes a
total blackout: deterministicApprovalPromptSent is set despite the
message never reaching the user, then all subsequent assistant text is
also suppressed.

Fix: add channelData.execApprovalUnavailable with the reason to all
return paths, and update resolveToolDeliveryPayload to recognize it.

Co-authored-by: Aurora <[email protected]>
@qualiobra
qualiobra force-pushed the feat/tool-only-exec-approval-allowlist branch from e9453d1 to 7f8251b Compare April 3, 2026 18:02
ericyoshida pushed a commit to ventopayai/openclaw that referenced this pull request Apr 23, 2026
Update the tool-only replyMode gate to also pass through payloads
with channelData.execApprovalUnavailable, matching the marker added
in openclaw#60445. Without this, approval-unavailable notifications are
silently dropped in tool-only mode, causing a total blackout.

Co-authored-by: Aurora <[email protected]>
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open, but not merge-ready: current main still has the missing unavailable-approval marker problem, while this branch is now conflicting, lacks after-fix real behavior proof, and does not cover the newer shared approval-payload gates on main.

Root-cause cluster
Relationship: canonical
Canonical: #60445
Summary: This PR remains the canonical open implementation attempt for the generic missing exec-approval-unavailable payload marker; related approval and tool-only items are adjacent or partial overlaps, not merged replacements.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

Yes, source-level: current main builds unavailable approval replies without channelData, while dispatch suppression gates recognize only channelData.execApproval. I did not run a live gateway/channel reproduction in this read-only review.

Is this the best way to solve the issue?

No. The marker is the right fix direction, but the current branch is stale and must update the shared current-main approval-payload gates rather than only the old local delivery branch.

Security review:

Security review cleared: The diff only changes TypeScript reply-payload routing and tests; it does not touch dependencies, workflows, secrets, permissions, install scripts, or generated code.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-03T17:21:55Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

Codex review notes: model internal, reasoning high; reviewed against c29e1fe764f3.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 19, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels May 19, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 10, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 22, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 23, 2026
@clawsweeper clawsweeper Bot removed the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

This branch had an error being deployed

1 failed deployment
qa-live-shared — 7f8251b7 Deployed May 19, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #22727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant