Skip to content

fix(web-fetch): balanced link URLs leak into extracted text - #180605

Merged
steipete merged 9 commits into
openclaw:mainfrom
AmelioMansour:fix/web-fetch-balanced-links
Oct 25, 2026
Merged

steipete merged 9 commits into
openclaw:mainfrom
AmelioMansour:fix/web-fetch-balanced-links

Conversation

@AmelioMansour

@AmelioMansour AmelioMansour commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: text-mode web_fetch results leak URL suffixes when Markdown link destinations contain nested parentheses.

User Impact

[Cassini](https://example.com/a_(b(c))) becomes Cassini, without stray closing parentheses. Images stay omitted from web text, while one-line previews keep their existing image labels. HTML anchor labels remain readable even with spaces or unmatched parentheses in the destination. No configuration or migration changes are required.

Why This Change Was Made

Replace the two first-closing-parenthesis regexes with the existing balanced-link parser. The shared parser retains its preview default and supports omitting images for web extraction. Basic HTML text extraction keeps anchor labels directly instead of serializing arbitrary HTML URLs as Markdown and parsing them again. Thanks @AmelioMansour for the fix and its regression cases.

Evidence

  • The owner regression fails on current main with Read Cassini)) and .png)., then passes with this repair. The full extraction, normalizer, and Readability suites pass: 46 + 23 + 7 tests. Vitest durations were 4.04s, 7.70s, and 11.16s; combined wrapper wall time was 34.96s on a busy host.
  • Real HTTP through createWebFetchTool().execute in isolated process state reproduced leaked Markdown/HTML suffixes and malformed-Markdown rewriting on base. All seven head fixtures pass: balanced links, unmatched HTML parentheses, a space-bearing HTML URL, a trailing label backslash, unchanged HTML Markdown output, and malformed Markdown preservation. The synthetic server was stopped. A full Gateway/model session was not run; the HTTP tool invocation exercises the changed extraction boundary.
  • Targeted package typecheck, type-aware oxlint, oxfmt, and git diff --check pass. Broad proof is provided by exact-head PR CI.
  • Simplification removes the two inadequate link regexes and reuses one maintained parser. Production delta is +14 lines, tests +22: the remaining growth preserves the distinct image policies and avoids lossy HTML-to-Markdown round-tripping.
  • Independent diff review through P2, with full parser and extractor source, found no actionable findings.

Current CI limitation

Exact-head run 40140057766 finished red in two Gateway recovery cases: gateway-widget-restart.e2e.test.ts (widget revision stayed at 1) and gateway-restored-requester-settle.e2e.test.ts (three restored wakes instead of two). Their classification is unknown because the scheduled-main run uses different shard coverage; no matching main failure has been established. The extraction regressions and targeted checks above pass. These failures have not been rerun merely to obtain green CI.

A bounded local baseline attempt on main 085076cc8f76c05b58166f85d792d851ac6c6d68 used TMPDIR=/private/tmp/oc-ct-webfetch OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs test/gateway-widget-restart.e2e.test.ts test/gateway-restored-requester-settle.e2e.test.ts --maxWorkers=1. Runtime preparation took 23m19s and worker preparation another 213.5s; the attempt was stopped after 30 minutes without a test verdict. The completed build was not interrupted. This establishes an environment/proof limitation, not an inherited-failure classification. No CI rerun was requested.

@clawsweeper

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

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR reuses the balanced Markdown link parser and preserves HTML anchor labels directly during text extraction.

Example: Fetch Markdown containing Cassini with extractMode=text.

  • Before: Cassini))
  • After: Cassini

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source repair is focused and has meaningful regression coverage, but the required shipped-entry-point proof is absent and current-head CI has an unattributed failure.
Proof confidence 🧂 unranked krab (1/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: Text-mode web results contain stray URL suffixes after links with nested parentheses.
Reason: The focused repair restores readable output without changing configuration, persistence, or existing defaults.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it fixes a current extraction defect with a focused change, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: c2b1d3025338d9b76ef2741d45e0decfe6fc97ea

Before merge

  • Add real behavior proof - The supplied real-HTTP verification invokes createWebFetchTool().execute directly in isolated process state and covers the changed extraction boundaries, but explicitly omits the shipped Gateway/model path; the earlier sufficient assessment does not satisfy this review's shipped-entry-point gate. Provide terminal output or redacted logs for that path, removing IPs, API keys, phone numbers, and non-public 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.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted Gateway or CLI output exercising text-mode Markdown and basic HTML extraction, including balanced destinations, destination spaces, and trailing label backslashes.
Agent review details

How this fits together

The web_fetch extraction layer converts HTTP response bodies into model-facing Markdown or text, sharing link parsing with session previews.

flowchart TD
  A[HTTP response] --> B[Markdown extraction]
  A --> C[Basic HTML extraction]
  C --> D[Anchor labels]
  B --> E[Balanced link parser]
  D --> E
  E --> F[Text tool result]
Loading

Technical review

Best possible solution:

Keep the shared balanced parser and direct HTML label rendering while preserving preview defaults, image omission, and fenced-code literals.

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

Current-main regexes demonstrably stop at the first closing parenthesis; the supplied failing-base result matches that mechanism, but this read-only review executed no target code.

Is this the best way to solve the issue?

This is the smallest complete repair using existing owners: reuse the maintained parser and remove the lossy HTML destination round trip.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jay Zhou: Raw commit e73028f adds packages/normalization-core/src/markdown-plain-text.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e73028f81cda; files: packages/normalization-core/src/markdown-plain-text.ts)
  • Peter Steinberger: Raw commit 9a947e4 adds packages/normalization-core/src/markdown-plain-text.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9a947e4bb8d0; files: packages/normalization-core/src/markdown-plain-text.ts)
  • sunlit-deng: Raw commit e6afd9d adds src/agents/tools/web-fetch-utils.ts:335 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e6afd9d7b46d; files: src/agents/tools/web-fetch-utils.ts)
  • Ben.Li: Raw commit e9938e3 adds src/agents/tools/web-fetch-utils.ts:259 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e9938e38aa7f; files: src/agents/tools/web-fetch-utils.ts)

PR surface

Source +14, Tests +22, Docs +1. Total +37 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 22 8 +14
Tests 1 22 0 +22
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 45 8 +37

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The repaired converter is SDK-exported and htmlToMarkdown gains an optional argument; existing signatures and default rendering remain compatible.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: URL suffix leakage degrades extracted text for a bounded class of links without preventing fetching.
  • merge-risk: 🚨 compatibility: The repaired converter is SDK-exported and htmlToMarkdown gains an optional argument; existing signatures and default rendering remain compatible.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-22T13:04:11.221Z sha bf70142 :: needs real behavior proof before merge. :: [P2] Serialize HTML destinations before applying the Markdown parser
  • reviewed 2026-10-23T01:41:53.795Z sha aeb9491 :: needs changes before merge. :: [P2] Serialize spaces in HTML destinations before parsing them | [P2] Preserve HTML anchor labels that end in a backslash
  • reviewed 2026-10-23T02:04:06.313Z sha 1ffdab2 :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 6:54 PM ET / 22:54 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 22, 2026
@AmelioMansour

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 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. 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. labels Oct 23, 2026
@AmelioMansour

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 24, 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 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. 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 24, 2026
@steipete
steipete merged commit 9c39447 into openclaw:main Oct 25, 2026
187 of 191 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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

* fix(web-fetch): consume complete balanced link destinations

* fix(web-fetch): serialize HTML anchor parentheses for text parsing

* fix(web-fetch): retain literal HTML anchor text without a Markdown round trip

* docs: clarify web fetch link text extraction

---------

Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 28, 2026
* fix(web-fetch): consume complete balanced link destinations

* fix(web-fetch): serialize HTML anchor parentheses for text parsing

* fix(web-fetch): retain literal HTML anchor text without a Markdown round trip

* docs: clarify web fetch link text extraction

---------

Co-authored-by: Peter Steinberger <[email protected]>

(cherry picked from commit 9c39447)

Co-authored-by: RomneyDa <[email protected]>

Narrow companion adaptation; source author date: 2026-10-16T12:09:42+08:00
(cherry picked from commit 42ff52b)
Co-authored-by: Ben.Li <[email protected]>

Narrow companion adaptation; source author date: 2026-10-24T21:08:45-04:00
(cherry picked from commit ad2172d)
Co-authored-by: AmelioMansour <[email protected]>

Narrow companion adaptation; source author date: 2026-10-24T22:22:35-07:00
(cherry picked from commit a36d048)
Co-authored-by: Peter Steinberger <[email protected]>

Narrow companion adaptation; source author date: 2026-10-26T20:14:49+08:00
(cherry picked from commit 7639f53)
Co-authored-by: yy19971996 <[email protected]>
(cherry picked from commit e5fb9dfdf6e68f5a8209056f68352413f1a237c7)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
… [baseline validation follow-up]

* fix(web-fetch): consume complete balanced link destinations

* fix(web-fetch): serialize HTML anchor parentheses for text parsing

* fix(web-fetch): retain literal HTML anchor text without a Markdown round trip

* docs: clarify web fetch link text extraction

---------

Co-authored-by: Peter Steinberger <[email protected]>

Complete the source-equivalent baseline adaptation and checked-in regressions; normalize with the checkout formatter.

(cherry picked from commit 9c39447)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 81d1a6a44ab65b53de3bf348393b855a7d18d14c)
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants