Skip to content

fix(web-fetch): preserve table cells and preformatted code in Markdown output - #176263

Merged
obviyus merged 4 commits into
openclaw:mainfrom
sunlit-deng:sunlit/fix/issue-176244
Oct 20, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
sunlit-deng:sunlit/fix/issue-176244

Conversation

@sunlit-deng

@sunlit-deng sunlit-deng commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

Fixes #176244. Minified HTML tables currently return EMEA12015 for the separate cells EMEA, 120, and 15. HTML preformatted code loses indentation and runs into the following paragraph.

Changes

Separate table cells, protect preformatted text during prose normalization, and wrap it in a fence longer than its literal backticks. Treat markup inside a pre block as presentation, so anchors contribute literal text without Markdown link syntax. Escape input NULs before restoring internal markers in one forward pass.

Reuse the fenced-code whitespace preservation from #172389; the text extractor only gains matching-length fence recognition. Remove the extra literal-anchor state and custom marker-restoration scanner from the original proposal.

Evidence

Built isolated Gateways, invoked POST /tools/invoke with web_fetch against a local HTTP page containing adjacent numeric cells and an indented pre block, twice with independent URLs plus an ordinary-prose control. Configuration was created through the shipped CLI.

Baseline output:

EMEA12015
APAC987

def f(x):
 if x:
 return 1
 return 0Done with the example code above and more trailing words.

Candidate output:

EMEA | 120 | 15
APAC | 98 | 7

```
def f(x):
    if x:
        return 1
    return 0
```

Done with the example code above and more trailing words.

The ordinary-prose control passes on both artifacts. The focused suite has 44 passing tests on the candidate; six new regressions fail on the baseline. Coverage includes literal links, longer fences, decoded marker-like input, long NUL runs, and the existing adjacent-code-block boundary. Targeted formatting and lint pass.

Whole-change deltas against the merge base: production +121/-26 (net +95), tests +59/-0. This removes 77 net production lines from the original proposal. Remaining growth is needed to keep code out of prose normalization, separate cells, and recognize the longer safe fences without reimplementing whitespace extraction.

Thanks to @sunlit-deng for the report and original implementation; their commits are retained.

Merge danger: two-way door; reverting restores the old extraction without a state migration. Blast radius is HTML rendering in web_fetch's Markdown extraction, basic fallback, and HTML error summaries, plus matching-length fenced-code conversion in text extraction.

@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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 18, 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. P2 Normal backlog priority with limited blast radius. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR separates HTML table cells and preserves preformatted code, literal links, and backticks in web_fetch output.

Example: Fetch a minified HTML row containing EMEA, 120, and 15.

  • Before: EMEA12015
  • After: EMEA | 120 | 15

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused shared-owner repair with shipped-entry-point evidence, distinct regression coverage, and no actionable findings; enforced workflow checks still govern landing.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR supplies before/after output from isolated Gateways invoking web_fetch through POST /tools/invoke against real HTTP pages: table values remain separate, preformatted indentation survives, and the following paragraph starts separately.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agents receive merged table values and code examples whose indentation and following paragraph boundaries have been lost.
Reason: Preserving distinct values and literal code restores readable extraction within the existing tool contract.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a verified current-main extraction bug, and the reviewed head has no actionable code findings.

Priority: P2
Reviewed head: d86ee33f42942c33a0c2cd5b8427bb42a449aaae

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared HTML renderer receives sanitized HTML from Readability or basic extraction and produces Markdown; text extraction subsequently removes Markdown formatting while preserving code literals.

flowchart TD
  A[web_fetch request] --> B[Fetch HTML]
  B --> C[Sanitize and extract content]
  C --> D[Shared HTML renderer]
  D --> E[Markdown output]
  D --> F[Markdown to text]
  F --> G[Text output]
Loading

Technical review

Best possible solution:

Land the focused shared-renderer fix once the enforced checks permit merging.

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

Current-main source establishes the failure for adjacent td/th elements and indented pre content, and the supplied Gateway output demonstrates the same observable failure; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the existing shared owner, keeps code outside prose normalization, and extends the existing text converter for safe fences without introducing a competing extraction path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • HTML scanner and render contexts keeps the original intent (64015e7: Replace vulnerable broad replacements with bounded forward scanning while preserving ordinary rendering.)
  • Shared context rendering keeps the original intent (d73bc54: Consolidate repeated tool behavior while preserving result contracts.)
  • Fenced-code text extraction keeps the original intent (42ff52b: Keep code indentation and whitespace intact when converting Markdown to text, building on earlier code-literal protection.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Pavan Kumar Gondhi: Raw commit 64015e7 adds src/agents/tools/web-fetch-utils.ts:383 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 64015e71dd5a; files: src/agents/tools/web-fetch-utils.ts)

PR surface

Source +95, Tests +59. Total +154 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 121 26 +95
Tests 1 59 0 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 180 26 +154

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +121/-26; tests +59/-0 Growth stays within the existing renderer and covers cell boundaries, protected preformatted text, collision-safe placeholders, and longer-fence text conversion.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Merged numeric cells and damaged code examples reduce fetched-content accuracy without disabling the overall agent workflow.
  • 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 (4 earlier review cycles)
  • reviewed 2026-10-18T15:58:24.318Z sha a8aad1a6d3ab1d2429ec4ddfcde14b8702dcc6a1 :: needs real behavior proof before merge. :: [P2] Remove the unreachable pre case from the narrowed switch | [P2] Make longer fences round-trip through markdownToText
  • reviewed 2026-10-19T14:06:40.772Z sha 604ada9632aaebaf699bff0ff5cc4f8e54f1def4 :: blocked before merge. :: [P2] Escape decoded input before restoring preformatted placeholders | [P2] Choose preformatted markers without repeated whole-input searches
  • reviewed 2026-10-20T00:17:17.552Z sha 5331637 :: needs changes before merge. :: [P2] Preserve literal text for links inside preformatted blocks
  • reviewed 2026-10-20T00:37:13.065Z sha 30d11a7 :: needs maintainer review before merge. :: none

Reviewed October 20, 2026, 10:32 AM ET / 14:32 UTC (Revision 5).

@sunlit-deng
sunlit-deng force-pushed the sunlit/fix/issue-176244 branch from a8aad1a to 604ada9 Compare October 19, 2026 13:10
@sunlit-deng

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. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Oct 20, 2026
@sunlit-deng

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 20, 2026
@obviyus

obviyus commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 20, 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. 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 20, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 20, 2026
@obviyus
obviyus merged commit e6afd9d into openclaw:main Oct 20, 2026
137 of 139 checks passed
@obviyus

obviyus commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Landed in e6afd9d. Thanks @sunlit-deng. web_fetch no longer merges table cells or flattens preformatted text.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…n output (openclaw#176263)

fix(web-fetch): keep HTML table cells and preformatted text intact

web_fetch's HTML-to-Markdown rendering merged adjacent table cells, so separate values like "12" and "34" came out as a misleading "1234", and it flattened indentation in pre/code blocks. Cells now stay separated and preformatted blocks keep their indentation and the text that follows them.

Proof: built Gateway, /tools/invoke web_fetch on a local page. On main, numeric cells merged and code indentation was lost (twice, separate URLs); a plain-prose page was unchanged. With this change cells stay separate, indentation is kept, and the following paragraph is intact. Production +95 (cut from the original proposal by 77 lines; reuses the code-whitespace handling from openclaw#172389).

Fixes openclaw#176244. Thanks @sunlit-deng.

Co-authored-by: Ayaan Zaidi <[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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

web_fetch: markdown extraction merges table cells and flattens pre code indentation

2 participants