Skip to content

fix: restore message actions for CLI channel replies - #149131

Merged
shakkernerd merged 2 commits into
mainfrom
fix/cli-message-authority
Sep 16, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix/cli-message-authority

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139119.

What Problem This Solves

Channel replies using a CLI backend could send messages but could not perform otherwise permitted reads or reactions through OpenClaw's message tool. The Gateway MCP grant was missing the host's conversation authority.

User Impact

CLI-backed channel replies using the Gateway MCP bridge can perform permitted Discord reactions, pins, deletions and channel edits, and Discord/Slack reads. The tool retains the admitted sender, account, conversation and provider permissions.

Why This Change Was Made

The shared fallback-candidate owner supplies the existing message authority to CLI and embedded execution, with a separate token for each candidate and revocation before the next candidate starts. CLI grants carry the token privately to the message tool and preserve the durable reply session when policy uses a separate session key. Plugin delivery keeps its existing permissions.

Evidence

  • HTTP MCP/Gateway coverage includes 13 cases through the registered Discord/Slack adapters against synthetic provider HTTP: channel targets, three Discord DM target forms, implicit accounts, permitted channel management, forged/revoked authority, cancellation before a reaction write, and accepted-send completion. The accepted-send/MCP-drain case was rerun after integration; the other 12 cases retain qualified coverage from their unchanged affected behavior.
  • The original reaction denial reproduces on the unchanged baseline. Candidate and factory checks cover success/failure, token replacement and revocation, heartbeat and untrusted-ingress exclusions, policy-session binding, and CLI plugin-delivery exclusion. Both CLI preparer variants verify the private grant handoff and absence of the token from the CLI environment.
  • Focused remote validation passes 565 cases across 31 files, including all 77 isolated execution cases and all six real-minter authority cases. Matching baseline, pre-correction and corrected CI replays confirm the shared fixture regression and its repair without changing assertions or timeouts.
  • Changed-path formatting, targeted lint, ratchets and independent P0–P2 review pass. The messaging type check also passes; all five changed tests/helpers map to verified type projects. The exact public head has a Platinum ClawSweeper review with no findings.

@shakkernerd
shakkernerd requested a review from a team as a code owner September 15, 2026 13:35
@clawsweeper

clawsweeper Bot commented Sep 15, 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 agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 11:33 PM ET / September 16, 2026, 03:33 UTC (Revision 4).

ClawSweeper review

What this changes

Restores permitted message reads and actions for CLI-backed channel replies by carrying private, turn-bound conversation authority through the Gateway’s MCP bridge.

Merge readiness

✅ Ready for maintainer review

This remains a useful repair absent from current main. The earlier cancellation concern is addressed by the integrated caller-lifetime safeguards and recorded boundary proof; no actionable patch defect remains. The related scheduled-turn permission request is a separate concern.

Priority: P1
Reviewed head: 892dd5ebb78a525576d1d887b32d652e0623f6b2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused authority-handoff repair with meaningful production-boundary proof and no remaining actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Recorded remote MCP/Gateway runs exercise the changed grant and message-tool path through real Discord/Slack adapters against synthetic provider HTTP, covering permitted requests, forged and revoked authority, cancellation before a reaction write, and accepted-send settlement. Source inspection supports the retained coverage; this is production-boundary proof, not a live-channel demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded remote MCP/Gateway runs exercise the changed grant and message-tool path through real Discord/Slack adapters against synthetic provider HTTP, covering permitted requests, forged and revoked authority, cancellation before a reaction write, and accepted-send settlement. Source inspection supports the retained coverage; this is production-boundary proof, not a live-channel demonstration.
Evidence reviewed 10 items Pinned introduction and clean checkout: Reviewed the merge-base-to-head change at 892dd5e. The checkout is clean and diff whitespace checks pass. The supplied test merge is stale, so endpoint drift was not treated as PR-introduced removal.
Single candidate authority owner: The shared fallback owner mints authority for each candidate and revokes it in finally; CLI and embedded execution consume that same candidate token. The minter excludes heartbeat and untrusted ingress.
Private grant and replacement fencing: The capability stays in the host-owned grant row and is excluded from the child-visible grant context. Existing row identity, admission, abort, capture, transfer, and cache-invalidation checks fence retained callers.
Findings None None.
Security None None.

How this fits together

CLI-backed agents call OpenClaw tools through the Gateway’s MCP bridge. The bridge binds those calls to the admitted channel conversation before the message tool applies account, sender, and provider permissions.

flowchart TD
  A[Incoming channel message] --> B[Admitted reply turn]
  B --> C[Candidate-scoped authority]
  C --> D[Private Gateway grant]
  E[CLI tool request] --> D
  D --> F[Message permission and liveness checks]
  F --> G[Provider read or action]
  B --> H[Completion or cancellation revokes access]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +52, Tests +992, Docs +6. Total +1050 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 13 174 122 +52
Tests 5 1009 17 +992
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 1189 139 +1050

Review metrics

Metric Value Why it matters
Production versus test growth production +52 net lines; tests and test support +992 Production growth connects existing authority owners; most added code exercises the permission and lifecycle boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139119
Summary: This PR addresses the canonical CLI authority-handoff defect; scheduled access and provider caller lifetime have distinct scopes.

Members:

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

Technical review

Best possible solution:

Use the existing host-owned turn authority for both execution backends while preserving provider permissions, candidate revocation, and accepted-send settlement.

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

Yes, by source inspection: current main’s CLI grant omits the authority required by the message tool, matching the reporter’s Discord reaction trace. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. The patch repairs the existing authority handoff without trusting child-supplied routing fields, widening plugin delivery permissions, or adding a competing authorization mechanism.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Source and production reports establish broken permitted reactions and reads in CLI-backed channel replies.
  • 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 (terminal): Recorded remote MCP/Gateway runs exercise the changed grant and message-tool path through real Discord/Slack adapters against synthetic provider HTTP, covering permitted requests, forged and revoked authority, cancellation before a reaction write, and accepted-send settlement. Source inspection supports the retained coverage; this is production-boundary proof, not a live-channel demonstration.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded remote MCP/Gateway runs exercise the changed grant and message-tool path through real Discord/Slack adapters against synthetic provider HTTP, covering permitted requests, forged and revoked authority, cancellation before a reaction write, and accepted-send settlement. Source inspection supports the retained coverage; this is production-boundary proof, not a live-channel demonstration.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the merge-base-to-head change at 892dd5e. The checkout is clean and diff whitespace checks pass. The supplied test merge is stale, so endpoint drift was not treated as PR-introduced removal. (892dd5ebb78a)
  • Single candidate authority owner: The shared fallback owner mints authority for each candidate and revokes it in finally; CLI and embedded execution consume that same candidate token. The minter excludes heartbeat and untrusted ingress. (src/auto-reply/reply/agent-runner-fallback-candidate.ts:267, 892dd5ebb78a)
  • Private grant and replacement fencing: The capability stays in the host-owned grant row and is excluded from the child-visible grant context. Existing row identity, admission, abort, capture, transfer, and cache-invalidation checks fence retained callers. (src/gateway/mcp-grant-store.ts:126, 892dd5ebb78a)
  • Message-only scope: Tool construction supplies the token only to the message tool, preserving the separate durable reply session. Plugin delivery still requires its existing messageActionTurnCapability option; the new message-only option does not satisfy that contract. (src/agents/openclaw-tools.ts:243, 892dd5ebb78a)
  • Authority boundary proof: The captured PR body reports 13 HTTP MCP/Gateway cases through registered Discord/Slack adapters and synthetic provider HTTP. The inspected harness records permitted provider requests, rejects forged and revoked authority with zero provider requests, cancels a held lookup before a reaction write, and preserves an accepted send through CLI completion and MCP drain. The body distinguishes the freshly rerun drain case from retained coverage; no tests were executed during this review. (test/cli-message-authority.integration.test.ts:1, 892dd5ebb78a)
  • Earlier cancellation concern resolved: fix: stop message sends and actions after caller retirement #149277 is verified merged. The message tool captures caller and capability assertions, and Discord carries them through its request scheduler to the final fetch. Those three production files have identical blobs in the reviewed head and fetched main. (extensions/discord/src/internal/rest.ts:239, 2426d0a06f0b)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (3 earlier review cycles)
  • reviewed 2026-09-15T13:43:48.893Z sha 19677bc :: needs real behavior proof before merge. :: [P1] Carry turn liveness through reaction provider I/O
  • reviewed 2026-09-16T02:48:37.935Z sha 3251399 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T03:26:13.189Z sha 892dd5e :: needs maintainer review before merge. :: none

@shakkernerd
shakkernerd force-pushed the fix/cli-message-authority branch from 19677bc to 3251399 Compare September 16, 2026 02:41
@shakkernerd shakkernerd self-assigned this Sep 16, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Sep 16, 2026
@shakkernerd
shakkernerd merged commit 277c54b into main Sep 16, 2026
205 of 206 checks passed
@shakkernerd
shakkernerd deleted the fix/cli-message-authority branch September 16, 2026 03:51
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: CLI-backed channel replies can use permitted message reads and actions through the Gateway MCP bridge.

obviyus added a commit to masatohoshino/openclaw that referenced this pull request Nov 12, 2026
…lity

The scheduled grant is redeemed under the turn's runtime policy key; personal-tool authority checks the run's own registration through sourceReplySessionKey, as ordinary replies already set it (openclaw#149131).
obviyus added a commit that referenced this pull request Nov 12, 2026
…n session is used from a DM (#180603)

fix(cron): bind scheduled message capabilities under the keys the run's tools use

Since scheduled conversation work moved through session admission (#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes.

Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: #180603 (comment).

Closes #180602. Closes #197181. Thanks @masatohoshino for the fix and @Suiah98 for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…n session is used from a DM (openclaw#180603)

fix(cron): bind scheduled message capabilities under the keys the run's tools use

Since scheduled conversation work moved through session admission (openclaw#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (openclaw#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes.

Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: openclaw#180603 (comment).

Closes openclaw#180602. Closes openclaw#197181. Thanks @masatohoshino for the fix and @Suiah98 for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 16, 2026
…n session is used from a DM (#180603)

fix(cron): bind scheduled message capabilities under the keys the run's tools use

Since scheduled conversation work moved through session admission (#178764), a cron or heartbeat run on the main session minted its message-action capability under the plain session key, while the run's own tools looked it up under the peer-scoped runtime policy key when the main session was used from a DM. The lookup missed, so every message send failed with "message action turn capability is no longer active", or the run failed earlier with "plugin delivery capability is no longer active". The scheduled grant is now redeemable under the turn's runtime policy key and records the execution session key as sourceReplySessionKey, as ordinary replies already do (#149131). It is still one capability for the same run with the same lifetime and revocation; nothing is granted, widened or skipped. No text changes.

Evidence: a built Gateway with the real bundled Codex app-server against a local model endpoint that calls message, the real WhatsApp channel with only the Baileys socket stood in, and a Telegram stand-in, two runs each. With the main session used from a WhatsApp DM, a heartbeat on agent:main:main failed the send on main and delivers with this change; from a Telegram DM it failed before the model call on main and delivers with this change. Ordinary DM turns, an isolated job and an announce job with --to deliver on both, a heartbeat whose job is removed mid-decision sends nothing, and a grant minted for one peer is refused for another peer on both. Net 0 test lines; the structured-result test fails on main. Details: #180603 (comment).

Closes #180602. Closes #197181. Thanks @masatohoshino for the fix and @Suiah98 for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 4f96534)

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. size: XL 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.

1 participant