Skip to content

fix(channels): make system-agent approval cards actionable - #147152

Merged
obviyus merged 9 commits into
mainfrom
bugloop/system-agent-approval-actions
Sep 13, 2026
Merged

obviyus merged 9 commits into
mainfrom
bugloop/system-agent-approval-actions

Conversation

@obviyus

@obviyus obviyus commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

The OpenClaw Change approval card appears, but its buttons cannot approve. A late callback can overwrite the application result, and a Slack card can stay pending after its delivery receipt is lost.

Fix and Impact

Accept the existing three approval kinds in Discord, Slack, and shared presentation validation. Native updates and callbacks share a per-message queue in each channel. Callbacks read current controls before editing, so old pending cards finish and final Applied, Not applied, or Denied cards survive.

Native delivery keeps its existing frozen runtime selection from #121673. Restart/list replay does not send a second card; an authorized operator can still resolve the original card. No schema, migration, config-key, protocol, dependency, or delivery-policy change.

Supersedes #137169 by @LiuwqGit. Contributor authorship is preserved. Reported by @anyech in #137142. Refs #134670.

Consumers

The shared presentation normalizer also feeds Telegram and the fallback renderers for other channels. Telegram already accepts the system-agent callback kind. Its existing typed-action tests remain intact. Other renderers retain their existing unsupported-control and text-fallback behavior; this change does not claim native approval support for them.

Documentation

No product documentation change is required. docs/plugins/sdk-channel-plugins/approvals.md:104 already requires all three kinds and the final application result. The Slack codec unit test covers a direct encoder/decoder round trip; the registered-handler and real Gateway evidence below establish the complete approval flow.

Evidence

  • Main 37130969fa54: both emitted Discord buttons returned “This approval is no longer valid”; SQLite stayed pending and the resolver was not reached.
  • Slack baseline fc188ff0b943: after native delivery and runtime stop, Allow Once and Deny persisted their decisions but left the original card pending with buttons.
  • Narrowed candidate b5e76a8386f03380a369dd5150f57b5e488cd64b: three fresh real Slack handler → Gateway → application/SQLite → card cases passed. Actual stop/start/list replay selects no replacement and sends no second card. Original Allow Once and Deny clear the controls; the threaded case reads and finishes the exact original reply. Full captures: runtime-narrowed-3.json.
  • Retained evidence: 21 non-replay Slack cases at 73fba5283a4b cover both native/callback orders, Applied/Not applied/Denied, generic controls, stale winners, authority checks, and exec/plugin siblings. Source-aware review confirmed unchanged inputs. These are reused records, not new executions. Earlier replacement-delivery records are historical only. The retained 21 Discord Gateway scenarios cover the real dispatcher, approval resolver, application executor, SQLite results, and final cards against local HTTP responses.

The boundary uses a real bundled Gateway and native HTTP clients with isolated local HTTP and deterministic inference fixtures. Recorded harness commands (SLACK_PROOF is the retained evidence directory; start runs in a separate terminal):

node "$SLACK_PROOF/start.mjs" narrowed
node "$SLACK_PROOF/call.mjs" narrowed
node "$SLACK_PROOF/verify.mjs"

Fresh merge f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e has direct parents candidate b5e76a8386f03380a369dd5150f57b5e488cd64b and main adb6e518a44218650883f3daec4bd319165e0017. The affected approval lifecycle group passed 836 tests (2 skipped), full Slack passed 3,017, and the Discord native/registered-callback sibling passed 44. All three commands exited 0.

pnpm changed:lanes --json --base 37130969fa54c64d1f62d91d0b2bbf8861c168b8 --head f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e
node --import tsx scripts/ci-run-node-test-shard.mts

The retained plan and command/result receipts specify each CI config, include list, and environment. Local pnpm exec oxlint --config .oxlintrc.json passed for all 15 retained PR files plus both reverted files; oxlint-final.json records the exact command and exit. Unchanged suite evidence remains tied to its earlier merge 68930a5e67a2, rather than being counted as a new run. CI run 34773959228 completed successfully at landing head f08ae38f5237e35276bdf9bb2f50c68cbe4af31b, including the previously failing type-aware jobs. The last commit changes only two Discord test fixtures; production and the accepted Gateway evidence are unchanged. Both affected test files also passed all 44 local tests.

Limit: no human click.

LiuwqGit and others added 5 commits September 13, 2026 20:38
… and Slack codecs

System-agent approval cards rendered by the Discord or Slack native adapters can now be resolved through their transport-private callback codecs. Both kind allowlists stay closed to the three canonical kinds; malformed ids, unknown kinds, and unknown decisions still fail closed.

Fixes #137142

(cherry picked from commit 94e963a)
@clawsweeper

clawsweeper Bot commented Sep 13, 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 channel: discord Channel integration: discord channel: slack Channel integration: slack size: L maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 2:49 PM ET / 18:49 UTC (Revision 6).

ClawSweeper review

What this changes

Makes Discord and Slack approval buttons for proposed OpenClaw changes actionable and prevents delayed callbacks from overwriting completed approval cards.

Merge readiness

✅ Ready for maintainer review

This remains a useful repair: current main and the latest release still reject the emitted Discord approval kind. No blocking correctness finding was identified, and the narrowed patch preserves the established account-custody and delivery-selection contracts.

Priority: P1
Reviewed head: f08ae38f5237e35276bdf9bb2f50c68cbe4af31b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful production-boundary evidence and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The captured evidence records real channel handlers, Gateway resolution, application/SQLite state and native HTTP clients preserving final cards across callback ordering and Slack restart/list replay. Production code is unchanged by the final fixture-only commit; live platform clicks and Telegram generic rendering are not claimed by these records.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The captured evidence records real channel handlers, Gateway resolution, application/SQLite state and native HTTP clients preserving final cards across callback ordering and Slack restart/list replay. Production code is unchanged by the final fixture-only commit; live platform clicks and Telegram generic rendering are not claimed by these records.
Evidence reviewed 10 items Current main still needs the codec repair: Pinned main retains the two-kind Slack decoder. Inspection of the Discord codec on both pinned main and v2026.9.4 likewise found the system-agent rejection.
Introduced changes restore an existing contract: The merge-base-to-head delta accepts system-agent in both transport codecs and shared presentation validation. The existing approval-kind type already includes it; no new SDK signature, configuration option, or persistent format is introduced.
Documented approval lifecycle: The channel approval contract already requires three approval kinds and distinguishes approval from the final application outcome.
Findings None None.
Security None None.

How this fits together

Channel approval adapters turn Gateway-owned requests into chat cards and send operator decisions back to the Gateway. The Gateway controls authorization and application; channel adapters keep the displayed outcome consistent with that result.

flowchart TD
  A[Proposed OpenClaw change] --> B[Gateway approval record]
  B --> C[Discord or Slack card]
  C --> D[Operator button click]
  D --> E[Approver and Gateway custody checks]
  E --> F[Canonical decision and application]
  F --> G[Serialized card updates]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +125, Tests +585. Total +710 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 172 47 +125
Tests 6 609 24 +585
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 781 71 +710

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +125 lines; tests net +585 lines Production growth supplies shared message ordering and current-control checks; most growth protects callback, stale-card and authorization behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137142
Summary: This PR is a candidate repair for the canonical codec report and adds presentation-race handling beyond the earlier proposal.

Members:

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

Technical review

Best possible solution:

Keep Gateway-owned authorization and application intact while both channel adapters serialize presentation updates and preserve final application outcomes.

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

Yes: current main emits system-agent approval controls while its Discord and Slack decoders reject that kind before resolution. This review verified the source path and recorded baseline evidence without executing target code.

Is this the best way to solve the issue?

Yes: repairing the existing codecs and coordinating channel-owned message updates addresses the failure without creating another authorization owner or changing delivery policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Existing Discord and Slack approval cards can block operators from completing an already-supported change-approval workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The captured evidence records real channel handlers, Gateway resolution, application/SQLite state and native HTTP clients preserving final cards across callback ordering and Slack restart/list replay. Production code is unchanged by the final fixture-only commit; live platform clicks and Telegram generic rendering are not claimed by these records.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence records real channel handlers, Gateway resolution, application/SQLite state and native HTTP clients preserving final cards across callback ordering and Slack restart/list replay. Production code is unchanged by the final fixture-only commit; live platform clicks and Telegram generic rendering are not claimed by these records.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The shared normalizer also makes generic system-agent approval buttons render on Telegram; that visible path is distinct from the unchanged native Telegram approval card.

Evidence

What I checked:

  • Current main still needs the codec repair: Pinned main retains the two-kind Slack decoder. Inspection of the Discord codec on both pinned main and v2026.9.4 likewise found the system-agent rejection. (extensions/slack/src/approval-actions.ts:49, 144ebea0cb62)
  • Introduced changes restore an existing contract: The merge-base-to-head delta accepts system-agent in both transport codecs and shared presentation validation. The existing approval-kind type already includes it; no new SDK signature, configuration option, or persistent format is introduced. (src/interactive/payload.ts:545, f08ae38f5237)
  • Documented approval lifecycle: The channel approval contract already requires three approval kinds and distinguishes approval from the final application outcome. Public docs: docs/plugins/sdk-channel-plugins/approvals.md. (docs/plugins/sdk-channel-plugins/approvals.md:104, f08ae38f5237)
  • Presentation ordering stays channel-owned: Discord native edits/deletes and clicked-card edits share one message queue. Slack native and callback updates share an account/channel/message queue; the callback reads the exact current message and edits only matching controls. Failed reads preserve the card and return ephemeral decision feedback. (extensions/slack/src/monitor/events/interactions.block-actions.ts:682, f08ae38f5237)
  • Authority remains with the Gateway: Channel callbacks retain actor/account/kind facts. The canonical resolver checks live custody, stored kind and allowed decisions before resolution; the existing system-agent owner retains run-authority and proposal-identity checks. The final diff makes no change to frozen native-delivery selection. (src/gateway/server-methods/approval.ts:409, f08ae38f5237)
  • Captured production-boundary proof and continuity: The supplied body snapshot, sourceRevision 3c771f770508f8a8de554b0d0589eff355539b0109181f855e4e9319eed81c59, records three fresh Slack restart/list-replay cases at b5e76a8 plus retained Slack and Discord Gateway cases covering update ordering, application outcomes, authority checks and siblings. These use the real Gateway, native HTTP clients and SQLite with local HTTP/inference fixtures. The final commit changes only Discord test fixtures. Raw runtime-narrowed-3.json captures were not present in the supplied scratch directory; this review inspected the recorded account and source continuity, without rerunning it. (b5e76a8386f0)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-13T15:46:42.286Z sha fc188ff :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T15:55:24.382Z sha fc188ff :: needs changes before merge. :: none
  • reviewed 2026-09-13T17:31:11.429Z sha 73fba52 :: needs changes before merge. :: none
  • reviewed 2026-09-13T18:00:37.184Z sha b5e76a8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T18:23:49.615Z sha f08ae38 :: needs maintainer review before merge. :: none

@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 147152
head: b5e76a8
scope: owner-review

@obviyus
obviyus marked this pull request as ready for review September 13, 2026 17:52
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-admin-merge
pr: 147152
head: f08ae38
scope: owner-review

@clawsweeper clawsweeper Bot added the proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. label Sep 13, 2026
@obviyus
obviyus merged commit efd65c9 into main Sep 13, 2026
188 checks passed
@obviyus
obviyus deleted the bugloop/system-agent-approval-actions branch September 13, 2026 19:01
@obviyus

obviyus commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @LiuwqGit!

Proof: Allow Once and Deny callbacks resolved real pending approvals through the Gateway, with final cards preserved in both update orders. Local transport fixtures were used; no human click.

  • Bug: Change approval buttons rejected valid requests, left old cards pending, or overwrote the application result.
  • Fix: Channel callbacks accept the existing approval kinds and coordinate updates using the current card state.
Before After
Invalid approval, pending buttons, or a lost application result Canonical decisions are shown and final Applied, Not applied, or Denied cards are preserved

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit 'cf45ff4d6a9c13164463db860285a02c1c4f2e8c':
  test(macos): observe readiness cancellation and deadline ownership (#145056)
  fix(ci): route QA Profile Evidence to its run-status owner test (#147293)
  fix(install): preserve runtime links when Node validation fails (#147221)
  test(auto-reply): reuse memory session fixtures (#147262)
  fix: hide subagent sessions from Activity (#147253)
  ci: record resources for slow runtime test commands (#147254)
  fix(update): recognize FreeBSD boot identities in triage leases (#147243)
  refactor(active-memory): share closing tag line scan (#147031)
  fix: resume Settings autosave after Reload Config (#147136)
  fix(cli): keep conversation context after cancellation (#147139)
  fix(channels): make system-agent approval cards actionable (#147152)
  refactor: retain shared database handles until their last worker closes (#147246)
  refactor(slack): share workspace-qualified target resolution (#147024)
  refactor(msteams): remove duplicate quoted-table test (#147270)
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit 'ac59d5e09eb468dc23cf95e447608b57e71b52af': (176 commits)
  improve(gateway): avoid redundant startup preflight work (#147285)
  test(macos): observe readiness cancellation and deadline ownership (#145056)
  fix(ci): route QA Profile Evidence to its run-status owner test (#147293)
  fix(install): preserve runtime links when Node validation fails (#147221)
  test(auto-reply): reuse memory session fixtures (#147262)
  fix: hide subagent sessions from Activity (#147253)
  ci: record resources for slow runtime test commands (#147254)
  fix(update): recognize FreeBSD boot identities in triage leases (#147243)
  refactor(active-memory): share closing tag line scan (#147031)
  fix: resume Settings autosave after Reload Config (#147136)
  fix(cli): keep conversation context after cancellation (#147139)
  fix(channels): make system-agent approval cards actionable (#147152)
  refactor: retain shared database handles until their last worker closes (#147246)
  refactor(slack): share workspace-qualified target resolution (#147024)
  refactor(msteams): remove duplicate quoted-table test (#147270)
  fix(qa): bind coverage IDs to producer assertions (#144000)
  fix(linux): explain FreeBSD desktop setup prerequisites (#147211)
  fix(memory): split embedding batches rejected for an input array item cap (#139541)
  test: isolate timing metadata persistence from inherited settings (#147112)
  refactor(status): retire test-only helper publication (#147071)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…147152)

## What Problem This Solves

The OpenClaw Change approval card appears, but its buttons cannot approve. A late callback can overwrite the application result, and a Slack card can stay pending after its delivery receipt is lost.

## Fix and Impact

Accept the existing three approval kinds in Discord, Slack, and shared presentation validation. Native updates and callbacks share a per-message queue in each channel. Callbacks read current controls before editing, so old pending cards finish and final Applied, Not applied, or Denied cards survive.

Native delivery keeps its existing frozen runtime selection from openclaw#121673. Restart/list replay does not send a second card; an authorized operator can still resolve the original card. No schema, migration, config-key, protocol, dependency, or delivery-policy change.

Supersedes openclaw#137169 by @LiuwqGit. Contributor authorship is preserved. Reported by @anyech in openclaw#137142. Refs openclaw#134670.

## Consumers

The shared presentation normalizer also feeds Telegram and the fallback renderers for other channels. Telegram already accepts the system-agent callback kind. Its existing typed-action tests remain intact. Other renderers retain their existing unsupported-control and text-fallback behavior; this change does not claim native approval support for them.

## Documentation

No product documentation change is required. `docs/plugins/sdk-channel-plugins/approvals.md:104` already requires all three kinds and the final application result. The Slack codec unit test covers a direct encoder/decoder round trip; the registered-handler and real Gateway evidence below establish the complete approval flow.

## Evidence

- Main `f700a855a470`: both emitted Discord buttons returned “This approval is no longer valid”; SQLite stayed pending and the resolver was not reached.
- Slack baseline `fc188ff0b943`: after native delivery and runtime stop, Allow Once and Deny persisted their decisions but left the original card pending with buttons.
- Narrowed candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b`: three fresh real Slack handler → Gateway → application/SQLite → card cases passed. Actual stop/start/list replay selects no replacement and sends no second card. Original Allow Once and Deny clear the controls; the threaded case reads and finishes the exact original reply. Full captures: `runtime-narrowed-3.json`.
- Retained evidence: 21 non-replay Slack cases at `73fba5283a4b` cover both native/callback orders, Applied/Not applied/Denied, generic controls, stale winners, authority checks, and exec/plugin siblings. Source-aware review confirmed unchanged inputs. These are reused records, not new executions. Earlier replacement-delivery records are historical only. The retained 21 Discord Gateway scenarios cover the real dispatcher, approval resolver, application executor, SQLite results, and final cards against local HTTP responses.

The boundary uses a real bundled Gateway and native HTTP clients with isolated local HTTP and deterministic inference fixtures. Recorded harness commands (`SLACK_PROOF` is the retained evidence directory; start runs in a separate terminal):

```sh
node "$SLACK_PROOF/start.mjs" narrowed
node "$SLACK_PROOF/call.mjs" narrowed
node "$SLACK_PROOF/verify.mjs"
```

Fresh merge `f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e` has direct parents candidate `b5e76a8386f03380a369dd5150f57b5e488cd64b` and main `e08263bdd3341031c219bb147638f23a1f4c3c03`. The affected approval lifecycle group passed 836 tests (2 skipped), full Slack passed 3,017, and the Discord native/registered-callback sibling passed 44. All three commands exited 0.

```sh
pnpm changed:lanes --json --base f700a85 --head f9ccdd51aa0d590adb72d35c83eb937bbe9fa13e
node --import tsx scripts/ci-run-node-test-shard.mts
```

The retained plan and command/result receipts specify each CI config, include list, and environment. Local `pnpm exec oxlint --config .oxlintrc.json` passed for all 15 retained PR files plus both reverted files; `oxlint-final.json` records the exact command and exit. Unchanged suite evidence remains tied to its earlier merge `68930a5e67a2`, rather than being counted as a new run. CI run `34773959228` completed successfully at landing head `f08ae38f5237e35276bdf9bb2f50c68cbe4af31b`, including the previously failing type-aware jobs. The last commit changes only two Discord test fixtures; production and the accepted Gateway evidence are unchanged. Both affected test files also passed all 44 local tests.

Limit: no human click.

Co-authored-by: LiuwqGit <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants