Skip to content

fix: let completion replies send photos and attachments - #176594

Merged
steipete merged 21 commits into
mainfrom
fix/completion-source-reply-media
Oct 19, 2026
Merged

steipete merged 21 commits into
mainfrom
fix/completion-source-reply-media

Conversation

@steipete

@steipete steipete commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #176144

What Problem This Solves

Fixes: completion and settle replies reject requested photos and files, leaving the agent to send plain text or raw image markup instead.

User Impact

Completion replies can send media and attachments, with or without text or a caption, plus normal filename/MIME metadata, to the current conversation. MEDIA: directives and remote Markdown images follow normal outbound delivery. Local files still require the normal allowed media roots; local Markdown paths remain literal text. Channel, account, destination, thread, and the send action remain locked. Explicit replyTo stays limited to the current message or thread; inline reply and audio directives remain restricted. No new config, SDK, or schema changes.

Why This Change Was Made

The execution allowlist continued to reject media after #175309 exposed the full stable message schema to completion turns. Permit media content and remove duplicate completion-only text validation. The existing outbound sender remains the sole owner of text-or-media validation and media access, without a new resolver or broader roots. Caption fallback validation preserves Markdown indentation so existing reply/audio restrictions still apply. Source policy checks reply/audio tags with the sender’s inline parser before media extraction, so media URLs cannot hide a directive that would later change the reply target.

The normal outbound preparation owner also canonicalizes the advertised mimeType alias to contentType before its explicit-media early return. This preserves MIME metadata for both ordinary and completion sends, using the existing contentType-first reader and preserving buffer validation behavior.

Product decision from Peter: “Allow media, keep target lock (Recommended)”. The completion-source tests move into a focused sibling suite because the existing test file cannot grow under the line-cap ratchet.

Fact/lifetime audit: this change captures no new state or deferred effects. Existing turn/session authority and binding checks remain at awaited preparation and the outbound handoff. Channel/account/target/thread identity and config remain the admitted send’s existing inputs; media paths, roots, and limits are resolved and enforced by normal outbound owners.

Evidence

  • delivers completion media and attachments to the current source through normal sends exercises the real message tool/action runner through a synthetic transport: remote media, media-only attachments, captions, filename/MIME metadata, MEDIA:, remote Markdown images, same-thread replies, and successful source completion.
  • applies normal local media roots and empty-send validation to completion replies uses the shared media loader and requires the allowed-directory error, failed delivery, no source completion, and no platform send. Existing retargeting, non-send, and reply/audio refusal cases also carry media and metadata. The denial table additionally covers reply directive inside a media-only URL, reply directive inside a media caption, and audio directive inside a media URL, requiring rejection before secrets or dispatch.
  • The existing outbound dedupes resolved media while retaining first-entry metadata (%j) regression covers MIME-alias preservation and contentType precedence, asserting both canonical send metadata and attachment payload metadata.
  • PR CI is the test gate and covers the regressions, existing consumers, prompt-prefix stability, types, and broader checks selected by CI. Local tests, negative controls, typechecks, and live Gateway/Crabbox/Testbox proof were intentionally skipped per maintainer policy. No leases were created; local test wall time is not applicable.
  • Changed-file oxlint, oxfmt, and git diff --check pass. Independent Codex autoreview in branch mode through P2 is scoped-clean, including the shared MIME-normalization correction and the inline-directive routing repair.
  • Simplification removes duplicate completion-only content validation. Exact numstat totals: production +20/−11 (net +9), tests +333/−132 (net +201), docs +19/−0. Necessary growth covers three metadata allowlist entries, caption fallback validation, and four lines reusing the normal MIME reader. No parallel parser, resolver, or sender was added.

Current main at b791dd0664e58c5f0c3776ee333b7be4bf8b524f was fetched successfully and merged without conflicts. It includes the earlier UI and Codex test-type fixes and repairs the mock-export ratchet by preserving the real ci-test-timings module exports. The PR patch is unchanged by this merge; the only overlap is main’s independent requester documentation update. Changed-file oxlint/oxfmt and whitespace checks pass; the existing full-branch P2 autoreview covers the unchanged patch.

The completion fixture uses module spies after main retired private injection hooks, retaining the real outbound runner for media delivery/access-policy cases and restoring spies after every test.

CI run 39196007075 passed for 618d52d5bdbd23acad113bc4aa3ac35a5a05e9a1: 40 jobs passed, 27 skipped, no failures. The mock-export ratchet, selected Node/Bun tests, both UI E2E shards, production/test typechecks, and lint all passed. No inherited failure exception is needed; the UI bundle-performance job was skipped for this PR’s scope.

ClawSweeper’s completed exact-head review states verbatim: “Codex review: needs real behavior proof before merge.” It reports Findings: None, confirms the earlier directive finding is repaired, and marks the fix scope complete. The remaining proof/security holds ask for additional production-owner authority evidence (requester-denied workspace access and revocation during media preparation); the review identifies no concrete remaining bypass. These are proof-only requests: PR CI is the proof per maintainer policy, so no additional local/live proof was run. Exactly one re-review request was posted for this head; no second request was posted. The PR remains open and unmerged.

Allow source-bound completion sends to carry media and attachments through the normal outbound media policy, including media-only replies. Preserve channel, account, destination, thread, reply target and send-action restrictions. Fixes #176144.
@clawsweeper

clawsweeper Bot commented Oct 18, 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.

@steipete
steipete marked this pull request as ready for review October 18, 2026 22:59
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Oct 18, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T03:46:52.415995Z 618d52d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 23c8c1f451

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Accept media captions under the same directive restrictions as message text. Preserve Markdown indentation and exercise the normal media loader with source session context in the regression fixture.
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR permits source-bound completion replies to send media, attachments, captions, and file metadata through existing outbound delivery.

Example: A completion sends media=https://example.com/photo.png with caption=Replacement photo to its source conversation.

  • Before: The completion argument allowlist rejects the photo.
  • After: The photo enters normal outbound delivery while destination and thread restrictions remain enforced.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation and reviewed-head CI are sound signals, but the required authority scenarios remain unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Requested photos and files are rejected when completed work is delivered through a source-bound completion turn.
Reason: The maintainer-authored direction explicitly permits media while preserving the source target lock, addressing the reported failure without a new option or delivery subsystem.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: it addresses a confirmed completion-delivery failure with approved direction, and the earlier code findings are fixed; no new concrete defect was found.

Priority: P2
Reviewed head: 618d52d5bdbd23acad113bc4aa3ac35a5a05e9a1

Before merge

  • Add real behavior proof - Authority-chain proof required: the real message tool and action runner are exercised through a synthetic transport, but the supplied evidence does not cover an admitted requester denied workspace-file access or source authority revoked during awaited media preparation. Demonstrate allowed delivery and rejection before unauthorized file/network I/O and transport handoff through the real owners; an authorized production-path authority harness can cover these cases without a full live-channel campaign. Redact credentials and private endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass remains identified, but the newly enabled media effects require final-effect authority evidence.
  • Resolve merge risk - The expanded completion grant enables file and network effects whose preservation of requester permissions and live source authority remains unverified at the final effect.

Findings

None.

Tests

  • Missing end-to-end proof: Supply production-owner final-effect authority evidence for allowed delivery, denied requester workspace access, and revocation during media preparation; red-on-base regression execution is not shown.
Agent review details

How this fits together

The message tool validates completion authority and arguments, then passes permitted content to shared outbound preparation, media-access policy, and channel delivery.

flowchart LR
A[Completion turn] --> B[Message tool authority]
B --> C[Source routing policy]
C --> D[Outbound preparation]
D --> E[Media access policy]
E --> F[Channel transport]
F --> G[Delivery completion]
Loading

Technical review

Best possible solution:

Keep the narrow content allowlist and shared outbound owners, with requester and source authority demonstrated at media I/O and transport handoff.

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

Current main deterministically rejects completion media through its argument allowlist and directive checks, corroborating the linked report; no target code was executed during this review.

Is this the best way to solve the issue?

The patch uses the smallest existing-owner repair: admit content fields, retain routing restrictions, delegate content validation to outbound delivery, and normalize MIME metadata at its current owner.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify media authority through the production owners (recommended)
    Supply allowed delivery, requester-denied workspace access, and revocation during awaited preparation, recording rejection before unauthorized media I/O or transport handoff.

Provenance checked

  • Completion content restrictions changes intended behavior with a stated reason (cb16d73: Completion-authority hardening restricted sends to visible text and the admitted source; the later module split preserved that boundary.)
  • Execution-time completion allowlist changes intended behavior with a stated reason (b326dc0: fix: prompt cache misses on completion, heartbeat and non-owner turns #175309 stabilized tool definitions while retaining execution-time authority checks; this PR changes permitted content without changing the schema.)
  • Explicit-media attachment preparation keeps the original intent (60c24e3: The existing explicit-media early return preserves normal attachment preparation and buffer handling; canonicalizing MIME metadata before it repairs the advertised alias without replacing that owner.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete bypass remains identified, but the newly enabled media effects require final-effect authority evidence.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit b326dc0 adds src/agents/tools/message-tool-source-policy.ts:38 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b326dc020122; files: src/agents/tools/message-tool-source-policy.ts)
  • Josh Avant: Raw commit f7a8638 adds src/agents/tools/message-tool-source-policy.ts:24 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f7a86382823d; files: src/agents/tools/message-tool-source-policy.ts)

PR surface

Source +9, Tests +201, Docs +19. Total +229 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 20 11 +9
Tests 3 333 132 +201
Docs 2 19 0 +19
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 372 143 +229

Review metrics

Metric Value Why it matters
Production versus test growth Production +20/−11; tests +333/−132 Production growth extends the existing policy and MIME normalization; test growth preserves moved routing coverage and adds distinct media-input and access-denial cases.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change restores requested media delivery in completion turns with a limited workflow blast radius.
  • merge-risk: 🚨 security-boundary: Previously text-only completion authority now permits media reads and delivery, requiring final-effect requester and source-authority validation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for a requester denied workspace-file access and prove revocation during media preparation prevents unauthorized I/O and transport handoff.

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 (3 earlier review cycles)
  • reviewed 2026-10-18T23:38:41.376Z sha c92f4c0 :: needs real behavior proof before merge. :: [P2] Return the complete secret-resolution result from the typed mock | [P2] Assert the structured failed-delivery result for denied media
  • reviewed 2026-10-19T00:51:23.902Z sha 1d4c087 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T01:48:30.901Z sha bea4f85 :: needs real behavior proof before merge. :: [P1] [P1] Validate inline reply tags before extracting media

Reviewed October 19, 2026, 12:10 AM ET / 04:10 UTC (Revision 4).

@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: ad950472a6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@steipete
steipete merged commit 7f73804 into main Oct 19, 2026
154 checks passed
@steipete
steipete deleted the fix/completion-source-reply-media branch October 19, 2026 04:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

* fix: allow completion replies to send media

Allow source-bound completion sends to carry media and attachments through the normal outbound media policy, including media-only replies. Preserve channel, account, destination, thread, reply target and send-action restrictions. Fixes openclaw#176144.

* test: prepare runtime config for completion media replies

* fix: preserve completion media content and routing checks

Accept media captions under the same directive restrictions as message text. Preserve Markdown indentation and exercise the normal media loader with source session context in the regression fixture.

* test: align completion media fixtures with delivery contracts

* test: preserve literal local Markdown image behavior

* fix: allow completion media filename and MIME metadata

* fix: preserve MIME aliases for outbound media

* fix(agents): reject directives hidden in completion media

* test(agents): adapt completion reply fixture to current owners
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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Completion source replies reject media, attachments and replyTo, so requested photos are never sent

1 participant