Skip to content

web_fetch reports multibyte pages as truncated when nothing was cut #709

Open

Description

@RaphaelFakhri

web_fetch caps extracted content at 100,000 characters (fetchExtractedCapChars), but Fetcher.Fetch in internal/webaccess/fetch.go decides whether to truncate by comparing the content's byte length with that character cap:

if len(content) > fetchExtractedCapChars {
	content = textutil.TruncateRunes(content, fetchExtractedCapChars)
	truncated = true
}

For non-ASCII pages (for example Cyrillic, Greek, CJK, or accented Latin text) whose extracted content is longer than 100,000 bytes but shorter than 100,000 characters, TruncateRunes returns the content unchanged, yet truncated is still set to true. The tool result then carries "truncated": true and appends "[the upstream extractor truncated this response; all extracted content is shown]", so the agent is told it received partial content when it received the whole page.

Steps to reproduce

  1. Serve a text/plain; charset=utf-8 response containing 99,995 é characters (199,990 bytes).
  2. Fetch it with web_fetch.

Expected: truncated is false and the full content is returned.

Actual: the full content is returned, but truncated is true and the truncation note is appended.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions