Skip to content

docs: clarify MEDIA directive formatting - #78534

Closed
Jefsky wants to merge 3 commits into
openclaw:mainfrom
Jefsky:docs-media-directive-formatting
Closed

Jefsky wants to merge 3 commits into
openclaw:mainfrom
Jefsky:docs-media-directive-formatting

Conversation

@Jefsky

@Jefsky Jefsky commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Clarify that MEDIA:<path-or-url> must be an unformatted line-start directive outside code fences.
  • Add invalid Markdown-wrapped examples to the OpenClaw start docs.
  • Update assistant output guidance so agents avoid bold, inline-code, and inline-prose MEDIA directives.

Fixes #78495.

Real behavior proof

  • Behavior or issue addressed: After this patch, the OpenClaw start docs and assistant system prompt explicitly tell users/agents that MEDIA: must be a plain line-start directive outside code fences and without Markdown wrappers.
  • Real environment tested: Local OpenClaw checkout at /Users/jefskywong/openclaw-work on macOS, branch docs-media-directive-formatting, with repository dependencies installed via pnpm install --frozen-lockfile.
  • Exact steps or command run after this patch: Ran this Node command against the real changed files in the local checkout:
node - <<'NODE'
const fs = require('node:fs');
const docs = fs.readFileSync('docs/start/openclaw.md', 'utf8');
const prompt = fs.readFileSync('src/agents/system-prompt.ts', 'utf8');
const snippets = [
  docs.match(/The directive must start the line as plain text[^\n]+/)?.[0],
  docs.match(/These forms are not attachment directives[^\n]+/)?.[0],
  prompt.match(/The MEDIA directive must start the line as plain text[^\n]+/)?.[0],
].filter(Boolean);
console.log('OpenClaw local checkout:', process.cwd());
console.log('Docs MEDIA formatting guidance present:', docs.includes('without Markdown wrappers such as bold or inline code'));
console.log('Invalid MEDIA examples present:', docs.includes('**MEDIA:https://example.com/screenshot.png**') && docs.includes('Here is the screenshot: MEDIA:https://example.com/screenshot.png'));
console.log('System prompt MEDIA guidance present:', prompt.includes('Do not write `**MEDIA:...**`'));
console.log('After-fix snippets:');
for (const line of snippets) console.log('- ' + line);
NODE
  • Evidence after fix: Terminal output from the local OpenClaw checkout:
OpenClaw local checkout: /Users/jefskywong/openclaw-work
Docs MEDIA formatting guidance present: true
Invalid MEDIA examples present: true
System prompt MEDIA guidance present: true
After-fix snippets:
- The directive must start the line as plain text, outside code fences and without Markdown wrappers such as bold or inline code. Example:
- These forms are not attachment directives and will be sent as normal text:
- The MEDIA directive must start the line as plain text, outside code fences and without Markdown wrappers. Do not write `**MEDIA:...**`, `` `MEDIA:...` ``, or inline prose like `Here is the file: MEDIA:...`.",
  • Observed result after fix: The real changed documentation and prompt source now both contain the after-fix MEDIA formatting guidance and invalid examples, so the shipped docs/prompt copy no longer only states the positive MEDIA: form.
  • What was not tested: I did not change or test runtime parser behavior; this PR intentionally keeps parser behavior unchanged and only updates docs/prompt copy.

Test plan

  • git diff --check
  • pnpm docs:list
  • pnpm exec oxfmt --check --threads=1 src/agents/system-prompt.ts

Document the plain line-start MEDIA contract so agents avoid markdown-wrapped attachment directives that channels ignore.

Co-authored-by: Cursor <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. docs Improvements or additions to documentation agents Agent runtime and tooling size: XS labels May 6, 2026
@clawsweeper

clawsweeper Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds start-doc and assistant prompt guidance that MEDIA directives must be plain line-start text outside Markdown wrappers or code fences.

Reproducibility: yes. Source inspection on current main shows splitMediaFromOutput skips fenced blocks and only parses lines whose trimmed start is MEDIA:, while the docs and prompt still only show the positive standalone form.

Real behavior proof
Sufficient (terminal): The PR body includes copied terminal output from a real local checkout showing the changed docs and prompt source contain the after-fix MEDIA guidance.

Next step before merge
The PR is useful and proof-sufficient, but the remaining action is maintainer review plus conflict resolution or replacement, not a safe automated repair from this read-only cleanup pass.

Security
Cleared: The diff is documentation and prompt copy only, with no dependency, CI, permission, secret-handling, install, release, or code-execution changes.

Review details

Best possible solution:

Land or replace the docs/prompt clarification after resolving conflicts, and keep parser tolerance, warning logs, or sharp troubleshooting as separate scoped runtime follow-ups.

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

Yes. Source inspection on current main shows splitMediaFromOutput skips fenced blocks and only parses lines whose trimmed start is MEDIA:, while the docs and prompt still only show the positive standalone form.

Is this the best way to solve the issue?

Yes. For the immediate docs/prompt gap, documenting the existing parser contract in docs/start/openclaw.md and src/agents/system-prompt.ts is the narrowest maintainable solution; parser widening or diagnostics should be separate behavior work.

Acceptance criteria:

  • git diff --check
  • pnpm docs:list
  • pnpm exec oxfmt --check --threads=1 src/agents/system-prompt.ts

What I checked:

  • Live PR state: Live GitHub data shows this PR is open, not merged, references docs: MEDIA: directive silently ignored when wrapped in markdown formatting #78495 with closing syntax, changes docs/start/openclaw.md and src/agents/system-prompt.ts, has proof labels, and is currently CONFLICTING/DIRTY. (b8b933ca2eab)
  • Current docs gap: Current main documents the positive standalone MEDIA: form but does not warn that Markdown-wrapped, fenced, or inline-prose MEDIA text is not an attachment directive. Public docs: docs/start/openclaw.md. (docs/start/openclaw.md:199, 64b94daf92c4)
  • Current prompt gap: Current main's assistant output directives only say to attach media with MEDIA: on its own line and do not include the PR's negative Markdown-wrapper guidance. (src/agents/system-prompt.ts:411, 64b94daf92c4)
  • Parser contract: splitMediaFromOutput skips fenced code blocks and only enters MEDIA parsing when the trimmed line starts with MEDIA:, so inline-prose and Markdown-wrapped forms remain text under current behavior. (src/media/parse.ts:529, 64b94daf92c4)
  • Existing parser coverage: Current tests cover prose MEDIA mentions staying as text and fenced MEDIA lines being preserved as text, matching the behavior this PR documents. (src/media/parse.test.ts:107, 64b94daf92c4)
  • Related issue context: The linked issue asks for documentation updates with valid and invalid MEDIA examples, while parser tolerance and warning logs are described as optional or broader follow-ups.

Likely related people:

  • steipete: Recent merged work touched MEDIA path parsing, media docs, and related parser tests on the same attachment directive surface. (role: recent media/docs/prompt area contributor; confidence: high; commits: 3312ce5acba9, 25ca2fcda43c; files: src/media/parse.ts, src/media/parse.test.ts, docs/start/openclaw.md)
  • vincentkoc: Recent commits touched docs/start/openclaw.md and adjacent Markdown image parsing behavior relevant to documenting MEDIA directive boundaries. (role: recent docs and media parser contributor; confidence: medium; commits: 68a82cb2e282, 60d892d70044; files: docs/start/openclaw.md, src/media/parse.ts, src/media/parse.test.ts)
  • Bartok9: Recent merged work gated Markdown image extraction in the same parser and tests, adjacent to the fenced-block and line-start MEDIA contract reviewed here. (role: adjacent media parser contributor; confidence: medium; commits: f0b327cf686e; files: src/media/parse.ts, src/media/parse.test.ts)

Remaining risk / open question:

  • The PR head is currently merge-conflicting against current main, so the prompt/docs wording needs a rebase, conflict resolution, or maintainer replacement before it can land.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 64b94daf92c4.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 7, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 7, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 8, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 8, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks, this is useful. I absorbed the MEDIA directive clarification into main in commit e0fda55.

What landed: the docs and assistant output prompt now say MEDIA directives must start a line as plain text, outside code fences and without Markdown wrappers or inline prose.

Proof run before landing:

  • pnpm docs:list
  • pnpm docs:check-mdx
  • pnpm format:docs:check
  • node scripts/run-vitest.mjs src/media/parse.test.ts
  • node scripts/run-vitest.mjs src/agents/system-prompt.test.ts
  • git diff --check

Closing this PR because the change is now on main.

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 proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: MEDIA: directive silently ignored when wrapped in markdown formatting

2 participants