Skip to content

fix(web-fetch): keep blank lines before lists in text extraction - #164692

Merged
obviyus merged 2 commits into
openclaw:mainfrom
yetval:fix/web-fetch-text-list-blank-line
Oct 4, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
yetval:fix/web-fetch-text-list-blank-line

Conversation

@yetval

@yetval yetval commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fix web_fetch text extraction losing the separation between a paragraph or heading and a following list. The list-marker regexes in markdownToText allowed their leading whitespace match to consume preceding line breaks.

User Impact

Agents receive readable paragraph, heading, and list boundaries in web_fetch text results. No configuration or migration is required.

Why This Change Was Made

Keep yetval's original fix and regression, with a small follow-up that limits the behavior change to list separation: exclude LF from leading list whitespace, but preserve the existing heading regex, trailing marker whitespace, and Unicode indentation semantics. Extend the HTML regression to a heading followed by an ordered list and add a CRLF regression.

No overlap with Pash/Sarah changes.

Output compatibility

Compared the actual base and candidate markdownToText functions in an isolated Node 24 container across 12 fixtures: paragraphs, headings, nested lists, fenced code, a table, standalone markers, Unicode indentation, CRLF, and tab-indented lists.

The only observed changes in that corpus are:

  • LF input: restore blank lines before lists following a paragraph or heading, including tab-indented lists.
  • CRLF input: restore the paragraph/list boundary and list-item newlines. The base collapses Install steps:, Download, and Run into Install steps:DownloadRun; the candidate keeps the paragraph separation and separate item lines. This is the same list-separation defect with CRLF input.

Paragraphs, nested lists without a preceding blank line, tables, Unicode indentation, standalone markers, and fenced code otherwise match the base byte-for-byte. Markdown mode is untouched.

A separate existing defect found while checking scope: main strips a standalone # inside a fenced code block after removing the fence. The original proposal also changed that output. This PR deliberately leaves that behavior unchanged; code-block marker preservation deserves its own fix.

Evidence

pnpm test src/agents/tools/web-fetch-utils.test.ts --maxWorkers=1, Linux arm64, Node 24.21.0, isolated Docker:

  • Base: the LF regression fails with the two blank lines missing; 77 existing cases pass.
  • The additional CRLF negative control fails with Install steps:DownloadRun.
  • Candidate: all 79 tests pass. Vitest duration 1.78 seconds; wrapper 3.25 seconds; command wall time 4.59 seconds. Both new regression cases take approximately 1 ms each locally; no claim of separately measured hosted per-case CI time.

No paid Firecrawl requests were made. Firecrawl text mode and HTML error details use the same converter but were not exercised through their external entry points.

Real Gateway behavior proof

Built the base and candidate with pnpm build:docker in a secretless Node 24 container. Base production source is commit 91e9b93bcebd821474415d3daa8e9de4a566e1c3; candidate is de9bbef1e89da8e86b6ddda032f76560e71c490b. The touched files have no intervening main changes through 920820b202b.

Ran a real isolated Gateway agent turn using a scripted streaming model. It calls the real web_fetch tool twice with extractMode: "text" against a local HTTP server: once for text/markdown, once for equivalent HTML. The fixture explicitly allows only the local hostname, disables Tool Search to expose web_fetch directly, and disables extractor plugins while keeping the readability fallback route enabled. The returned extractors are cf-markdown and raw-html; both tools succeed.

For both content types, the base tool result contains:

Install steps:
Download the archive
Run the installer

Configure
Open settings
Save

For both content types, the candidate tool result contains:

Install steps:

Download the archive
Run the installer

Configure

Open settings
Save

The extracted content diff is exactly those two added blank lines. The real tool's untrusted-content wrapping remains in place; timestamps, timing, wrapper IDs, and lengths are normal per-call metadata, not content comparisons.

A separate exact-head live Gateway turn made one real gpt-5-mini request through a passive proxy: HTTP 200, reasoning effort low, maximum output budget 4096, and the expected final reply. That live smoke did not fetch a page; the deterministic Gateway turns above prove the changed fetch behavior.

markdownToText stripped list and heading markers with multiline regexes whose
leading and trailing \s also matched newlines, so the blank line between a
paragraph or heading and the following list was consumed. Restrict those
regexes to horizontal whitespace.
@clawsweeper

clawsweeper Bot commented Oct 4, 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: XS labels Oct 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 3:40 AM ET / 07:40 UTC (Revision 3).

ClawSweeper review

What this changes

Preserves blank lines before lists in web-fetch plain-text results and adds regressions for Markdown, fallback HTML, and Windows line endings.

Merge readiness

✅ Ready for maintainer review

Keep open: current main and v2026.9.8 retain the defect. The focused repair has sufficient Gateway behavior proof and no blocking findings.

Priority: P2
Reviewed head: de9bbef1e89da8e86b6ddda032f76560e71c490b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused shared-owner repair with relevant before/after Gateway output and meaningful regression coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured exact-head Gateway before/after output exercises the shared converter through real HTTP Markdown and fallback HTML fetches and shows the restored paragraph/list boundaries. Supplemental CRLF regressions cover Windows line endings; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured exact-head Gateway before/after output exercises the shared converter through real HTTP Markdown and fallback HTML fetches and shows the restored paragraph/list boundaries. Supplemental CRLF regressions cover Windows line endings; no stored-data contract changes.
Evidence reviewed 8 items Verified introduced patch: The pinned merge-base-to-head delta narrows leading whitespace in the two list-marker expressions and adds two regression cases. Heading handling, trailing marker whitespace, public signatures, and Markdown mode remain unchanged.
Current-main necessity: Fetched main still uses leading \s* in both multiline list-marker expressions, which can consume preceding line breaks. The touched files have no changes between the pinned merge base and fetched main.
Latest-release comparison: GitHub's contents API confirmed that v2026.9.8 retains both original list expressions. The requested repair is not already present in the supplied latest release.
Findings None None.
Security None None.

How this fits together

The web-fetch tool retrieves page content and returns readable content to agents. Its shared plain-text converter handles Markdown responses, fallback HTML extraction, and Firecrawl output.

flowchart TD
  A[Fetched page] --> B{Content format}
  B --> C[Markdown response]
  B --> D[Fallback HTML extraction]
  C --> E[Shared plain-text converter]
  D --> E
  E --> F[Content wrapping and limits]
  F --> G[Agent tool result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +16. Total +16 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 16 0 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 18 2 +16

Review metrics

None.

Technical review

Best possible solution:

Keep list separation in the existing shared converter while preserving public signatures, heading behavior, and Markdown-mode output.

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

Yes: current-main list expressions consume preceding line breaks, and the supplied base/candidate Gateway output demonstrates the exact failure through real HTTP extraction. This reviewer did not execute target code.

Is this the best way to solve the issue?

Yes: narrowing the leading list-marker match repairs the shared producer without adding a competing converter or changing public APIs.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded extraction defect that obscures paragraph and list structure in agent input.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured exact-head Gateway before/after output exercises the shared converter through real HTTP Markdown and fallback HTML fetches and shows the restored paragraph/list boundaries. Supplemental CRLF regressions cover Windows line endings; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head Gateway before/after output exercises the shared converter through real HTTP Markdown and fallback HTML fetches and shows the restored paragraph/list boundaries. Supplemental CRLF regressions cover Windows line endings; no stored-data contract changes.

Evidence

What I checked:

  • Verified introduced patch: The pinned merge-base-to-head delta narrows leading whitespace in the two list-marker expressions and adds two regression cases. Heading handling, trailing marker whitespace, public signatures, and Markdown mode remain unchanged. (src/agents/tools/web-fetch-utils.ts:363, de9bbef1e89d)
  • Current-main necessity: Fetched main still uses leading \s* in both multiline list-marker expressions, which can consume preceding line breaks. The touched files have no changes between the pinned merge base and fetched main. (src/agents/tools/web-fetch-utils.ts:363, 3e8edffc4313)
  • Latest-release comparison: GitHub's contents API confirmed that v2026.9.8 retains both original list expressions. The requested repair is not already present in the supplied latest release. (src/agents/tools/web-fetch-utils.ts, fc23bc864e45)
  • Production boundary: Markdown responses call the shared converter in text mode; fallback HTML calls basic extraction, which uses the same converter. Existing SDK re-exports also supply Firecrawl. This is an OpenClaw extraction repair with no affirmative dependency on the Codex harness. (src/agents/tools/web-fetch.ts:712, de9bbef1e89d)
  • Captured real Gateway proof: The complete supplied body, captured under sourceRevision 1dcb4dda9d414428add8a87e836cf5d65b6df25afba7fa8f9c40e92bb649fc7f, records secretless Node 24 Gateway turns against a real local HTTP server for base 91e9b93 and exact candidate de9bbef. Both text/markdown and fallback HTML produce the expected two restored blank lines through the real web_fetch tool. The scripted model drives tool selection; the HTTP transport and extraction owners are real. The unrelated live-model smoke is not used as extraction proof. Firecrawl and HTML error entrypoints were expressly unexercised. (de9bbef1e89d)
  • Regression value and review continuity: The complete production and test modules were read. New cases assert observable paragraph/list boundaries, nested lists, fallback HTML, and CRLF separation without adding production seams or process fixtures. The body reports failing base controls and 79 passing candidate cases, with 4.59 seconds command wall time. The preceding exact-head review contains no findings or published rank-up moves. No target code or tests were executed during this review; the introduced diff passes whitespace checking. (src/agents/tools/web-fetch-utils.test.ts:453, de9bbef1e89d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • ruel225: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-04T01:54:09.085Z sha 8c97520 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-04T07:26:04.408Z sha de9bbef :: needs maintainer review before merge. :: none

@obviyus

obviyus commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 4, 2026
@obviyus
obviyus merged commit f0a6317 into openclaw:main Oct 4, 2026
133 of 135 checks passed
@obviyus

obviyus commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Landed as f0a6317. Thanks @yetval! We narrowed it to the paragraph/list boundary, LF and CRLF. The fenced-code # stripping we noticed is a separate issue.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…nclaw#164692)

`web_fetch` with `extractMode: "text"` dropped the blank line between a paragraph or heading and the list after it, so the intro line read as the first list item. With CRLF input, list items also ran together (`Install steps:DownloadRun`). This affected text/markdown responses, the raw-HTML fallback, Firecrawl text mode and HTML error details, which all go through `markdownToText`. The converter now keeps that boundary for LF and CRLF input. The heading and marker-stripping behavior is otherwise unchanged, and a corpus diff confirms the only output change is the restored list separation.

Proof: in a real Gateway `web_fetch` against local Markdown and HTML pages, the blank line was missing on base and present with this change. The regression tests fail on base and pass here. A live gpt-5-mini call passed.

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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants