Repository navigation
fix(approvals): let OpenClaw change approvals complete in chat - #157947
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. Reviewed September 25, 2026, 4:41 AM ET / 08:41 UTC (Revision 6). ClawSweeper reviewWhat this changesThe branch sends delegated OpenClaw change approvals to the requesting chat when no native card handles them and lets Merge readiness✅ Ready for maintainer review Keep open. Current main still leaves these chat approvals without a fallback, while this PR addresses the gap. The latest revision also resolves the earlier near-deadline expiry finding. Priority: P1 Review scores
Verification
How this fits togetherAn agent’s proposed config or service change enters the Gateway approval manager. The Gateway delivers a decision request to an approval surface, checks the reviewer’s current authority, then applies the change and reports its outcome. flowchart LR
A[Agent change request] --> B[Gateway approval]
B --> C{Native card available?}
C -->|Yes| D[Native chat card]
C -->|No| E[Requesting chat fallback]
D --> F[Approval decision]
E --> F
F --> G[Live reviewer check]
G --> H[Change and chat outcome]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +279, Tests +479, Docs +9, Other +152. Total +919 across 30 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep native cards and the requesting-chat fallback under the existing Gateway approval owner, with current reviewer custody checked before the change is applied and one accurate terminal chat outcome. Do we have a high-confidence way to reproduce the issue? Yes. Current main explicitly disables fallback delivery and routes Is this the best way to solve the issue? Yes. The branch extends the existing approval forwarder and canonical resolver, with reviewer authority rechecked at the final decision boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 74b9103096c6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Deliver delegated OpenClaw change approvals to the requesting chat through the shared approval forwarder when no native card owns it, and let /approve resolve them canonically after confirming the pending owner. Update the openclaw tool and gateway prompt copy to point at in-chat approval.
0e66040 to
f1ecfc9
Compare
|
Landed in a71e556. Bug: an OpenClaw change requested from chat (config, restart, plugins, channels, agents) only reached chats with a native approval card. Everywhere else the agent's tool call waited until the 10-minute expiry, and Fix:
Proof:
|
…law#157947) ## What Problem This Solves Fixes: when an agent asks OpenClaw to change config, restart, or manage plugins/channels/agents, the approval never reaches chats without a native approval card, and `/approve <id>` rejects it. The agent's tool call then blocks until the 10-minute expiry, and users are sent to the Control UI or a terminal to approve a change they asked for in chat. ## User Impact User impact: every approval an agent needs can be completed in the chat where it was requested. - Native approval cards (Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Teams, iMessage, Google Chat) keep owning their chats. - Every other requesting chat now gets the change summary with **Allow once** / **Deny** buttons where the channel renders them, plus a `/approve <id> allow-once|deny` line. - `/approve` now resolves OpenClaw change approvals, not only exec and plugin approvals. No config options, protocol, or schema changes. ## Why This Change Was Made Delegated OpenClaw changes ("system-agent" approvals) already had native cards (openclaw#134670). Two gaps remained outside those cards: - **Request delivery.** The request was created with delivery turned off, so the shared approval forwarder never posted a fallback. The forwarder now has a system-agent strategy that always targets the requesting chat and is suppressed whenever that chat's native card handles the request. It uses the same typed-button payload and resolved/expired messages as exec and plugin approvals. The system-agent owner publishes the outcome of a decision (applied, or denied) once; approval publication only adds expiry and cancellation, so a denial produces one chat update. The fallback answers only the live messaging chat that made the request: terminal and Webchat requests never fall back to the session's saved chat, and expiry is reported once, from the Gateway's recorded expiry rather than a local chat timer, so a change approved just before the deadline and applied after it reports its applied outcome instead of a false expiry. - **`/approve`.** The command probed only exec and plugin approvals. It now also resolves system-agent approvals through the canonical `approval.resolve`, after confirming the id is in `openclaw.approval.list`. Canonical resolution records a kind mismatch as a deny, so `/approve` confirms the owner first instead of probing. On channels with their own approver settings (Telegram, Discord, Slack, …), the Gateway checks the sender as the reviewer, the same check as native buttons. Everywhere else only a configured owner (`commands.ownerAllowFrom`) can approve an OpenClaw change: `/approve` sends the sender as the reviewer, and the Gateway checks owner custody against the current config inside the approval store's final decision guard. An ordinary command-authorized sender is refused, and an owner removed after sending `/approve` cannot complete the decision. Unchanged: approval authority stays bound to the requesting run; free-text "yes" never approves; Full Access still auto-applies; Control UI and the apps can still decide. Agent-facing text now says what happens: for runs from messaging channels, the `openclaw` tool description says the change waits for approval in this chat (buttons or `/approve`). Webchat and terminal runs, which the chat fallback cannot reach, are told to approve in the Control UI or OpenClaw apps. The gateway-only prompt line points to `openclaw` and `/restart` instead of "ask human". ## Evidence Real Telegram (Test Server userbot, Convex-leased credentials, fresh Gateway, mock provider), restricted `exec` mode, agent asks OpenClaw to `set logging.level "info"`: | Run | Setup | What the user saw | Tap | Result | |---|---|---|---|---| | A | tester is owner (native cards on) | 🔒 native approval card, no `/approve` text | **Allow Once** | `answerCallbackQuery` + 2× `editMessageText`: "approved. Applying" → "approved and applied"; final reply delivered | | C | tester is owner, `channels.telegram.execApprovals.enabled: false` | fallback message with change summary, `/approve <id> allow-once\|deny`, and **Allow Once** button | **Allow Once** | message edited to "approved. Applying…", then "approved and applied" posted; Gateway config on disk has `logging.level: "info"`; final reply delivered | Telegram Web screenshots from the same leased test account (cropped to the conversation): | | Pending | After **Allow Once** | |---|---|---| | Native card (A) |  |  | | Fallback message (C) |  |  | With no owner configured, the owner-only `openclaw` tool isn't exposed, so no change is proposed (config unchanged). That's the existing design; DM pairing sets the first owner. qa-channel (no native approval cards), new scenario `system-agent-chat-approval`: the agent's delegated change posts the approval in the requesting conversation. A command-authorized non-owner (`commands.allowFrom` includes them, `ownerAllowFrom` does not) sends `/approve <id> allow-once` and gets "❌ Only the owner can approve OpenClaw changes in this chat."; `logging.level` is unchanged and the approval stays pending. The owner's `/approve <id> allow-once` then resolves it; `logging.level` becomes `info`; exactly one final reply. On `origin/main` the same scenario times out waiting for the approval in the chat. Tests: `/approve` (resolves a pending OpenClaw change canonically; never submits a canonical decision for an id owned by another kind; on a channel without approver settings, a non-owner and a revoked owner never reach the canonical decision), channel custody (without approver settings only a configured owner holds custody, and only for OpenClaw changes), `approval.resolve` (custody revoked between the request and the final write leaves the approval pending), approval publication (allowed/denied changes leave the chat outcome to the system-agent owner; expired/cancelled are published once), forwarder (requesting chat gets the prompt and outcome without `approvals.*` config; a running native card suppresses it; terminal and Webchat requests never reach the saved session chat; a change applied after the deadline reports its outcome with no false expiry; the recorded expiry is reported once), plus existing gateway approval and system-agent suites. The new owner-custody and single-publisher tests fail with the fix reverted. Shared approval and forwarder fixtures moved to sibling `*.test-support.ts` modules so the test files stay under the line cap. Wall time for the touched suites: `commands-approve` + `approval-publication` + `exec-approval-forwarder` + `system-agent-approval` + `approval` ran in 59.5s across 3 Vitest shards. `pnpm tsgo:core` clean. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: when an agent asks OpenClaw to change config, restart, or manage plugins/channels/agents, the approval never reaches chats without a native approval card, and
/approve <id>rejects it. The agent's tool call then blocks until the 10-minute expiry, and users are sent to the Control UI or a terminal to approve a change they asked for in chat.User Impact
User impact: every approval an agent needs can be completed in the chat where it was requested.
/approve <id> allow-once|denyline./approvenow resolves OpenClaw change approvals, not only exec and plugin approvals.No config options, protocol, or schema changes.
Why This Change Was Made
Delegated OpenClaw changes ("system-agent" approvals) already had native cards (#134670). Two gaps remained outside those cards:
/approve. The command probed only exec and plugin approvals. It now also resolves system-agent approvals through the canonicalapproval.resolve, after confirming the id is inopenclaw.approval.list. Canonical resolution records a kind mismatch as a deny, so/approveconfirms the owner first instead of probing. On channels with their own approver settings (Telegram, Discord, Slack, …), the Gateway checks the sender as the reviewer, the same check as native buttons. Everywhere else only a configured owner (commands.ownerAllowFrom) can approve an OpenClaw change:/approvesends the sender as the reviewer, and the Gateway checks owner custody against the current config inside the approval store's final decision guard. An ordinary command-authorized sender is refused, and an owner removed after sending/approvecannot complete the decision.Unchanged: approval authority stays bound to the requesting run; free-text "yes" never approves; Full Access still auto-applies; Control UI and the apps can still decide.
Agent-facing text now says what happens: for runs from messaging channels, the
openclawtool description says the change waits for approval in this chat (buttons or/approve). Webchat and terminal runs, which the chat fallback cannot reach, are told to approve in the Control UI or OpenClaw apps. The gateway-only prompt line points toopenclawand/restartinstead of "ask human".Evidence
Real Telegram (Test Server userbot, Convex-leased credentials, fresh Gateway, mock provider), restricted
execmode, agent asks OpenClaw toset logging.level "info":/approvetextanswerCallbackQuery+ 2×editMessageText: "approved. Applying" → "approved and applied"; final reply deliveredchannels.telegram.execApprovals.enabled: false/approve <id> allow-once|deny, and Allow Once buttonlogging.level: "info"; final reply deliveredTelegram Web screenshots from the same leased test account (cropped to the conversation):
With no owner configured, the owner-only
openclawtool isn't exposed, so no change is proposed (config unchanged). That's the existing design; DM pairing sets the first owner.qa-channel (no native approval cards), new scenario
system-agent-chat-approval: the agent's delegated change posts the approval in the requesting conversation. A command-authorized non-owner (commands.allowFromincludes them,ownerAllowFromdoes not) sends/approve <id> allow-onceand gets "❌ Only the owner can approve OpenClaw changes in this chat.";logging.levelis unchanged and the approval stays pending. The owner's/approve <id> allow-oncethen resolves it;logging.levelbecomesinfo; exactly one final reply. Onorigin/mainthe same scenario times out waiting for the approval in the chat.Tests:
/approve(resolves a pending OpenClaw change canonically; never submits a canonical decision for an id owned by another kind; on a channel without approver settings, a non-owner and a revoked owner never reach the canonical decision), channel custody (without approver settings only a configured owner holds custody, and only for OpenClaw changes),approval.resolve(custody revoked between the request and the final write leaves the approval pending), approval publication (allowed/denied changes leave the chat outcome to the system-agent owner; expired/cancelled are published once), forwarder (requesting chat gets the prompt and outcome withoutapprovals.*config; a running native card suppresses it; terminal and Webchat requests never reach the saved session chat; a change applied after the deadline reports its outcome with no false expiry; the recorded expiry is reported once), plus existing gateway approval and system-agent suites. The new owner-custody and single-publisher tests fail with the fix reverted. Shared approval and forwarder fixtures moved to sibling*.test-support.tsmodules so the test files stay under the line cap. Wall time for the touched suites:commands-approve+approval-publication+exec-approval-forwarder+system-agent-approval+approvalran in 59.5s across 3 Vitest shards.pnpm tsgo:coreclean.