Skip to content

fix: restore CLI message sends with agent tool policies - #188058

Merged
shakkernerd merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix/message-send-policy-cycle
Nov 2, 2026
Merged

shakkernerd merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix/message-send-policy-cycle

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #184964

What Problem This Solves

Fixes openclaw message send failing with Cannot verify the installed tool authority for Template-managed agent "main" when the selected agent has its own tool profile or allowlist. Even text-only sends and --dry-run fail for ordinary agents with no Template installation.

User Impact

CLI message sends work again without changing agent policies or repairing a healthy state database. Explicit attachment read restrictions and genuine Template-consent failures remain enforced.

Why This Change Was Made

The regression was introduced by 3c23d52c93b in #184964: the new resolveEffectiveToolPolicy() call in src/media/read-capability.ts reads Template consent during message preparation, including text-only sends.

The CLI config guard publishes its configuration synchronously, before that consent provenance has been initialized. Initialize the provenance and bind it to the effective command configuration before dispatch, using the same preparation owners as standalone agent commands. No media-policy checks are removed.

Evidence

  • Reproduced with the installed CLI: openclaw message send --channel discord --target channel:123456789012345678 --message regression-probe --dry-run --json exits 1 with the error above.
  • New command-boundary regressions: 2 fail / 1 pass before, 3 pass after. They exercise real config, policy, and dispatch with isolated consent-row I/O. Both an agent-owned profile and a restrictive allowlist can send text; unreadable consent remains rejected.
  • 35 focused tests passed across the command, media workspace-access, and consent-preparation suites. Existing attachment-denial tests remain green. Command-suite wall time was 5.14 seconds for 14 tests; the three sequential test shards completed in 23.93 seconds.
  • A separate Node process with no module mocks, isolated empty state, and a local channel adapter reproduced the same consent error before the fix. Afterward, dry-run succeeded without delivery, and a non-dry-run delivered the exact message to the local adapter once with deliveryStatus: "sent". No external channel API was called.
  • Changed-file lint, formatting, and git diff --check passed. The final isolated regression run also passed all 3 cases (33.16 seconds including cold worker compilation). The 76-line test allocation covers the missing CLI initialization boundary and fail-closed control.

Shipped-CLI proof pinned to a9bd00376c21

Source builds of the CLI (pnpm openclaw → scripts/run-node.mjs) at head a9bd00376c21 and PR parent 43af01b15c96. Each case uses a fresh OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, and HOME. Delivery cases use the bundled Mattermost channel pointed at a local 127.0.0.1 recording endpoint (network.dangerouslyAllowPrivateNetwork: true). The endpoint logs each request and whether the body contains the attachment bytes. The token is a placeholder; no external API was called.

Case Agent tools / consent state Parent 43af01b Head a9bd003 Channel requests (head)
Text dry-run (Discord) allow:[message] deny:[read] ❌ Cannot verify the installed tool authority… ✅ dry-run payload —
Text send allow:[message] deny:[read] ❌ same error, 0 requests ✅ deliveryStatus: sent 1 (POST /posts)
Attachment send, read denied allow:[message] deny:[read] — ❌ path-not-allowed, sentBeforeError: false 0
Attachment send, read allowed (control) profile:full allow:[read,message] — ✅ sent 2 (/files with bytes, /posts)
Template consent: current v2 row, matching digest profile:full allow:[read,message] — ✅ sent 2
Agent config edited after consent (allow += exec), attachment and text-only same row — ❌ Cannot verify the installed tool authority… 0
Row digest invalidated (config unchanged) v2 row, wrong digest — ❌ Cannot verify… 0
Unsupported provenance schema …templateInstallRecord.v999 — ❌ Cannot verify… 0
Legacy v1 provenance …templateInstallRecord.v1 — ❌ …uses a legacy dynamic tool policy… 0
State database unreadable (overwritten with random bytes) — — ❌ file is not a database 0

openclaw templates add in this build does not write template_installs rows (0 rows after a successful add). The consent rows were therefore inserted into the isolated state database in the shape an earlier install leaves (agent_id, schema_version, agent_config_digest, status=complete). The matching digest comes from collectTemplateToolPolicyCandidates.

Head transcript excerpt (Template consent cases)
owned-config digest: sha256:57b65b3c495c57930df557688a15487b6148c9573895acee1a9eb497fa5685b1
## P1 consented: current v2 provenance row matching the agent config
$ openclaw message send --channel mattermost --target channel:<id> --message p1-consented --media <state>/tpl-ws/report.txt --json
    "deliveryStatus": "sent",
exit=0
{"method": "POST", "path": "/api/v4/files", "bytes": 321, "hasAttachmentBytes": true}
{"method": "POST", "path": "/api/v4/posts", "bytes": 89, "hasAttachmentBytes": false}
## P2 mismatched: tools edited after consent (allow += exec); row unchanged
$ openclaw message send ... --message p2-mismatch --media <state>/tpl-ws/report.txt --json
    "message": "Cannot verify the installed tool authority for Template-managed agent \"tplagent\". Repair the OpenClaw state database before running it."
exit=1
local channel endpoint requests for this step: 0
$ openclaw message send ... --message p2-mismatch-text-only --json
    "message": "Cannot verify the installed tool authority for Template-managed agent \"tplagent\". ..."
exit=1
local channel endpoint requests for this step: 0
## P3 invalidated: matching config, row digest replaced
exit=1  (Cannot verify ...)  requests: 0
## P4 unsupported provenance schema (v999)
exit=1  (Cannot verify ...)  requests: 0
## P5 legacy v1 provenance
    "message": "Template-managed agent \"tplagent\" uses a legacy dynamic tool policy. Its tool consent cannot be refreshed in place. ..."
exit=1  requests: 0

@clawsweeper

clawsweeper Bot commented Oct 30, 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 commands Command implementations size: S labels Oct 30, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Initialize Template consent provenance before CLI message dispatch for agents with tool profiles or allowlists.

Example: Run openclaw message send --channel discord --target channel:123456789012345678 --message regression-probe --dry-run --json with agent tools allow:[message], deny:[read].

  • Before: The command rejects an ordinary agent with “Cannot verify the installed tool authority.”
  • After: The text dry-run succeeds while workspace attachments remain denied.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-reusing repair with shipped-CLI before/after evidence, forbidden-case final-effect controls, meaningful regressions, and passing exact-head gates.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): At the pinned head, the shipped CLI exercises ordinary-agent text sends and bundled Mattermost attachment delivery against a local recording endpoint; read-denied and stale or invalid consent cases produce zero channel requests, while authorized controls deliver.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ordinary agents with their own tool profile or allowlist cannot send CLI text messages, even in dry-run mode.
Reason: Restores an existing command contract without new settings, changed defaults, parallel policy ownership, or removed safeguards.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI regression with a focused change that preserves attachment restrictions and Template consent enforcement; no actionable defects remain.

Priority: P1
Reviewed head: a9bd00376c21fac562b2156d42666c09111c6481

Before merge

None.

Findings

None.

Agent review details

How this fits together

The message command resolves configuration and channel credentials, prepares agent consent facts, and passes the request to shared message dispatch and media-policy owners before channel delivery.

flowchart LR
  A[CLI message command] --> B[Effective configuration]
  B --> C[Existing consent preparation]
  C --> D[Shared message dispatch]
  D --> E[Media read policy]
  E --> F[Channel transport]
Loading

Technical review

Best possible solution:

Land the existing command-boundary initialization while retaining shared consent and attachment-policy enforcement.

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

The source exposes missing consent initialization before media-policy resolution, and the contributor supplies a pinned parent CLI failure; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: prepare provenance and bind it to the effective command configuration through existing owners before dispatch, without weakening read restrictions.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Unified CLI message dispatch keeps the original intent (3636a2b: Unify message tool and CLI dispatch under the shared message-action owner.)
  • Asynchronous consent preparation keeps the original intent (7e48efb: Prepare runtime facts asynchronously through existing owners while preserving effect-time authority checks.)
  • Explicit attachment read restrictions keeps the original intent (3c23d52: Apply explicit global and agent read restrictions before granting workspace attachment access.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7e48efb adds src/commands/message.ts:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7e48efba1047; files: src/commands/message.ts)

PR surface

Source +9, Tests +76, Other +2. Total +87 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 9 0 +9
Tests 1 76 0 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 3 87 0 +87

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +9 lines; tests +76 lines The production change reuses existing owners; the tests exercise cold ordinary-agent policies and unreadable-consent rejection through real command dispatch.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A current regression prevents CLI text sends and dry-runs for ordinary agents with explicit tool profiles or allowlists.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-30T03:18:23.069Z sha a9bd003 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-31T23:45:35.356Z sha a9bd003 :: needs maintainer review before merge. :: none

Reviewed October 31, 2026, 7:51 PM ET / 23:51 UTC (Revision 3).

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 30, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 31, 2026
@shakkernerd
shakkernerd merged commit 970fc4e into openclaw:main Nov 2, 2026
171 of 172 checks passed
@shakkernerd

Copy link
Copy Markdown
Contributor

Fixed: CLI message sends work with agent tool policies while preserving attachment read restrictions and Template consent checks.

With thanks to @Marvinthebored.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
)

Restore CLI message sends for agents with their own tool policies while preserving attachment read restrictions and Template consent validation.

Refs openclaw#184964.
Reviewed-by: @shakkernerd
tideclaw-bot added a commit that referenced this pull request Nov 5, 2026
Backport accepted fixes onto 2026.11.5-beta.2.

Base: bc061f9
Canonical source tree before commit: e6c0c39

These are adapted/squashed backports; do not claim each is an exact Git cherry-pick.
Source provenance (selected verified commits; other cohorts use their frozen patch/adoption manifests):

runtime-B:
b20a0cc fix(macos): connect with configured credentials despite stale app environment (#191468)
c4c0942 fix(update): failed updates from 10.7–10.9 crash in automatic migration recovery (#189713)
6aae408 fix(update): preserve recovery errors and async triage callbacks (#191495)
8910654 fix(macos): prevent first-launch Gateway failures after upgrades (#191436)
00b2ff4 fix: parent sessions miss child approvals with a custom session store (#189827)
c6142a8 fix: avoid copying managed plugin binaries during Gateway startup (#187865)
e72b356 fix(anthropic): avoid token profile collisions (#187875)
807075d fix(anthropic): set API workspace at login (#186976)
bafe92f fix(exec): preserve no-timeout results from macOS app nodes (#190729)
9b05a64 fix(imessage): use a PostgreSQL-safe recovery cursor key (#184919)
6ba197f fix: session search on PostgreSQL scans every transcript row instead of using the text index (#187909)
4f49aa5 fix(sessions): PostgreSQL session search scans every transcript row again after the 5th search on a connection (#188979)
de3936c fix(macos): Mac tab shows a blank or stale page when a load fails (#185432)
e977080 fix(macos): prevent duplicate voice sends and false sent feedback (#186271)

provider-compaction:
1b43c2e fix(compaction): preserve active request provenance (#180214)
7b0cfe3 fix(google): restore tool calls with Python keyword parameters (#191561)
9039ceb fix(ci): keep compaction attribution helpers internal
d6a1327 feat(google): use the Interactions API for Gemini Flash models (#189395)
fe0f8d1 fix(google): Gemini models ignore configured topP (#190695)

history:
c51d733 fix(sessions): stop expanding archive reads from exhausting memory (#190690)
3c8bd4d fix(sessions): page oversized earlier history instead of failing at 8 MiB (#188450)
b195f61 fix(sessions): page oversized transcript history in both directions (#188483)
b65482e fix(gateway): preserve older history across hidden message gaps (#188557)
3d4fc94 fix(sessions): avoid oversized listing and imported-history reads (#189284)
33e7baf fix(sessions): bound active accounting without blocking writers (#190182)
682ade7 fix: preserve chat history continuation metadata (#188612)

runtime-C:
7e005b0 fix(macos): keep secrets when a Gateway config save fails (#187734)
15cf738 fix(macos): keep Gateway auth when Tailscale exposure is turned off (#187664)
b53a06b perf(update): read candidate state inventory without copying the shared database (#187921)
970fc4e fix: restore CLI message sends with agent tool policies (#188058)
73ad731 fix: stop model fallback when session capability metadata changes (#179312)
32305db fix: subagent turns fail after session metadata changes (#183501)
d13bd0f fix(codex): include relay conversation instructions in trajectory (#189005)
e375530 fix: replies after a plugin reload from Control UI go to the session's last external chat (#190982)
9346376 fix: reasoning-only retry is refused by Anthropic as reasoning_extraction (#184434)

direct-auth-state:
1b15408 fix(models): keep the model list when one plugin-owned provider lacks a credential (#189014)
7d8dc60 fix: recover startup migration with retained worker index (#189023)

capacity:
41772e3 fix(worktrees): settle completed disk debt on refused postchecks (#188727)

command-once-189369:
8269137 fix(plugins): plugin commands that continue the agent run three times on native command turns (#189369)

pg-board-189564:
7232a8d fix(boards): publish widgets with PostgreSQL storage (#189564)

queued-edit-189869:
92b32ca fix: hold queued messages through inline edits (#189869)

Preserve source attribution from original commits. For a genuinely exact individual pick only, use the conventional (cherry picked from commit <sha>) line.
Full file-level provenance: coverage-manifest.json; reviewed patch hashes: artifact-registry.json.
No held136/native82 content adopted by this work. No release or full-candidate qualification claim.

Additional original-source identities (exact adapted hunk scope is in frozen artifacts):
release-guides-185258: 39c37e6 docs(release): define ledger-first hotfix routing (#185258)
UI-history: 10a6e4f fix(ui): scope provider-add discovery warning to its own provider (#188541), 3d7b4c4 fix(ui): never fail loading earlier chat history without a boundary (#188372)
obsolete-cache-188203: 90d82c2 fix: preserve completed reasoning and refill chat snapshots (#188203)
webhook-169778: b1f643f fix(startup): keep webhook decisions startup recorded for channels Doctor left pending (#169778)
schema-lease-188391: ba6cfcd fix(state): keep lease renewal independent of parent admission (#188391)
backfill-188976: c75a8a8 fix(gateway): stop session row backfill once the Gateway is closing (#188976)
canonical-disable-188846: 88b56ee fix(config): auto-enable reads and writes mixed-case plugin policy under the canonical id (#188846)
matrix-177272: 5a6d22c fix(matrix): stop seeding new thread sessions from the room transcript (#177272)
provider-hook-189059: 0588f51 fix(models): isolate every per-provider catalog failure (#189059)
unicode-189868: 87396e7 fix(oc-path): avoid reading and editing a different Unicode key (#189868)
replay-cohort: 2031044 fix(sessions): acknowledge committed input retries without duplicate turns (#188527), 9114431 fix: resume configured fallback after interrupted attempts (#188672)

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

clawtributors PR from a clawtributor commands Command implementations P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

4 participants