Skip to content

webfetch returns page chrome verbatim and gives no guidance on API endpoints — strip boilerplate before markdown conversion, document 404 handling #190

Closed

Description

@mdev34-lab

Problem

Observed in the same session: a fetch of github.com/.../pull/182/checks returned ~10KB of GitHub navigation menus, marketing links, sign-in prompts, cookie text, and footer boilerplate — the actual CI-status content was a few lines. The fetch also failed to answer the question (pass/fail per check was ambiguous), forcing another round-trip. Additionally, the model then fetched api.github.com/repos/.../check-runs without auth, got a predictable 404, and burned another call.

Requested change

Code + prompt, one file.

  1. Code in packages/opencode/src/tool/webfetch.ts, in the HTML pipeline, before markdown conversion. Use the HTML parser the package already depends on — do NOT add a dependency, do NOT add per-domain rules:
const BOILERPLATE = [
  "nav", "header", "footer", "aside",
  "[role='navigation']", "[role='banner']", "[role='contentinfo']",
  "[class*='cookie']", "[class*='footer']",
]
for (const sel of BOILERPLATE) {
  for (const el of doc.querySelectorAll(sel)) el.remove()
}
  1. Prompt — add to the webfetch tool description:
HTML pages carry heavy navigation/footer chrome. For structured data, prefer
API endpoints or raw file URLs (raw.githubusercontent.com, api.github.com)
over rendered pages. A 404 from an API endpoint usually means authentication
is required — do not retry variants of the same unauthenticated request.

Acceptance criteria

  • Fetching a GitHub PR page no longer returns the nav menu / footer / "Skip to content" / marketing blocks.
  • No new package.json dependencies.

Activity

  1. agenteinstinct1-max commented on Oct 11, 2026

    @agenteinstinct1-max
    Collaborator

    Completed in PR #219 (#219) and the core-path port/fix in PR #234 (#234), both merged. Checked current dev-vibecoded at 2225f76: the core HTML pipeline removes navigation/header/footer/aside and chrome roles/classes before markdown/text conversion, uses the existing HTML parser, preserves legitimate cookie/footer content, and includes API/raw-URL and cautious 404 guidance. Regression fixtures cover chrome removal and retained content.

    Known limitation, outside this issue's acceptance criteria: GitHub's dynamically loaded CI content is not guaranteed to be fully visible through webfetch. The chrome removal and no-new-dependency scope is complete; this is not a remaining implementation item for #190.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions