Skip to content

fix(web-fetch): preserve inline code examples in text output - #184423

Closed
ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/web-fetch-inline-code-184362
Closed

ZengWen-DT wants to merge 1 commit into
openclaw:mainfrom
ZengWen-DT:fix/web-fetch-inline-code-184362

Conversation

@ZengWen-DT

@ZengWen-DT ZengWen-DT commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #184362.
Related: #184411.

What Problem This Solves

Fixes: web_fetch text extraction deletes or rewrites literal Markdown link and image examples inside inline code.

Why This Change Was Made

Use the existing Markdown code-region parser to protect inline spans in the original source before fence scanning and prose formatting, sharing the existing literal restoration pass. The main regression risk is changing ownership around image alt text or embedded fences; the HTTP controls and focused regressions cover those boundaries.

User Impact

User impact: fetched code examples retain their literal contents, including embedded backticks and repeated spaces; ordinary links keep their labels and ordinary images remain omitted.

Evidence

  • Before: real HTTP baseline, main 7aee7016f08cfc43ffe5f69a70d02f5a4d84a99b: 12 real loopback HTTP requests through production createWebFetchTool.execute, with five expected failing assertions. The reported example returned Use ` and label`; read guide.; ordinary link/image, image-alt, fenced-code, and all Markdown-mode controls passed. The artifact contains the actual tool envelopes.
  • After: exact-head verification, 8c43abe85efc7df67a58b76338d3635f248575e0: all 18 real HTTP requests and the exact utility NUL-collision control passed. Both focused suites and changed-file formatting passed. The eight new utility cases also ran against unchanged baseline production code and produced behavioral assertion failures, confirming the regressions detect the defect. pnpm build, pnpm check, and pnpm test remain in progress; this PR remains a draft.
  • Contract: the existing canonical parser determines code ownership, including image-alt exclusions. Code-span delimiter and whitespace handling follows CommonMark code spans.
  • Independent review: structured autoreview completed with no actionable P0–P2 findings. A separate source review caught nested-placeholder and repeated-suffix-scan risks; the final candidate protects original ranges and retains the next fence match while consuming inline spans.

The related candidate appeared while this repair was being validated. The same HTTP probe against its exact head, 5874523645e0a848f9d6db4e4cb20e2a629965ba, reproduced an additional failure: a valid inline span containing literal triple backticks returned Before literal \u00000\u0000 tail after. instead of preserving the embedded code. This submission covers that case at both the utility and HTTP tool boundary.

Production +34/-7 (net +27); tests +29/-0; docs +3/-1. The added production logic uses the existing parser and literal store to handle inline ownership while retaining the documented fenced-code extraction behavior; it replaces the single-backtick regex rather than adding a second restoration path.

Proof scope: real loopback HTTP, production tool execution, and actual returned results; no mocked transport or extraction. No external site, model, live Gateway, or browser UI was exercised.

AI-assisted implementation and review.

@clawsweeper

clawsweeper Bot commented Oct 26, 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 agents Agent runtime and tooling size: S labels Oct 26, 2026
@ZengWen-DT
ZengWen-DT force-pushed the fix/web-fetch-inline-code-184362 branch from 5a9d13f to 8c43abe Compare October 26, 2026 08:58
@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. P2 Normal backlog priority with limited blast radius. 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. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Protect inline code during web_fetch text conversion so literal Markdown examples survive prose formatting.

Example: Fetch a Markdown page containing Use ![alt](image.png) in text mode.

  • Before: The literal image example disappears.
  • After: The result retains Use alt.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with no discrete correctness finding; production-owner HTTP evidence supports it, while the required shipped-entry-point proof remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agents receive documentation with literal inline link and image examples deleted or rewritten.
Reason: Restoring literal code content is consistent with the existing extraction contract and requires no new capability, setting, or product direction.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR provides a focused repair for current-main inline-code corruption, and the related candidate is not an established landable replacement.

Priority: P2
Reviewed head: 8c43abe85efc7df67a58b76338d3635f248575e0

Before merge

  • Add real behavior proof - The inspected harness and successful workflow steps support real loopback HTTP through createWebFetchTool.execute, including inline examples, image-alt controls, embedded fences, and Markdown mode, but explicitly omit a shipped Gateway or agent invocation. The contributor should provide redacted terminal output or logs showing an isolated Gateway agent fetching these examples after the fix, with IPs, API keys, phone numbers, and non-public endpoints removed. 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.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied proof invokes the changed extraction through a shipped Gateway and agent entry point.
Agent review details

How this fits together

The web_fetch extraction layer converts fetched Markdown responses into agent-visible text, preserving code literals while flattening ordinary prose links and omitting images.

flowchart LR
 A[HTTP Markdown response] --> B[web_fetch tool]
 B --> C[Markdown to text converter]
 C --> D[Canonical code region parser]
 D --> E[Protect literals and format prose]
 E --> F[Restore literals]
 F --> G[Agent visible result]
Loading

Technical review

Best possible solution:

Preserve inline literals in the existing converter using canonical original-source ranges and the shared restoration pass.

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

Current-main source deterministically sends the reported inline literals through link/image stripping; supplied HTTP verification supports that mechanism, but this read-only review executed no reproduction.

Is this the best way to solve the issue?

The patch addresses the formatting order at its existing owner, reuses canonical parsing and literal restoration, and retains established fence behavior without adding another converter.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Fenced-literal storage and restoration keeps the original intent (4a90ec6: Preserve fenced code syntax while formatting surrounding prose, with escaped input NULs kept distinct from internal markers.)
  • Code whitespace keeps the original intent (42ff52b: Normalize prose before restoring protected code so indentation and repeated spaces remain intact.)
  • Tilde-fence handling keeps the original intent (ad2172d: Support closed and unfinished tilde fences through the existing sequential converter while retaining backtick extraction behavior.)
  • Ordinary link and image conversion keeps the original intent (9c39447: Remove balanced destinations completely, retain link labels, and continue omitting ordinary images from extracted text.)
  • Single-backtick replacement changes intended behavior with a stated reason (unknown: The expression was carried through the web-tools file split; deeper git log -S and --follow searches encountered unavailable promisor objects, so its original introduction remains unknown. The PR explains replacing it to preserve literal inline content.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +27, Tests +29, Docs +2. Total +58 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 34 7 +27
Tests 2 29 0 +29
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 66 8 +58

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #184362
Summary: Both open candidates address the canonical inline-code corruption report; neither currently establishes grounds to close this PR.

Members:

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

Labels

Label changes:

  • add P2: Text extraction silently corrupts fetched documentation examples, with a narrow trigger and a focused repair.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Text extraction silently corrupts fetched documentation examples, with a narrow trigger and a focused repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed October 26, 2026, 5:28 AM ET / 09:28 UTC.

@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this. The same web_fetch inline-code fix landed in #184411 (7639f53), which was opened earlier. If your branch covers a case that one doesn't, please say which and we'll take a look.

@ZengWen-DT ZengWen-DT closed this Oct 27, 2026
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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]: web_fetch text mode strips Markdown-looking inline code

2 participants