Skip to content

fix: treat screenshot failure as non-critical in browser tool#157

Closed
atian8179 wants to merge 1 commit intovxcontrol:masterfrom
atian8179:fix/browser-screenshot-non-blocking
Closed

fix: treat screenshot failure as non-critical in browser tool#157
atian8179 wants to merge 1 commit intovxcontrol:masterfrom
atian8179:fix/browser-screenshot-non-blocking

Conversation

@atian8179
Copy link

Problem

In backend/pkg/tools/browser.go, the ContentMD, ContentHTML, and Links methods run two concurrent operations: fetching page content and capturing a screenshot. If the screenshot fails (scraper unavailable, timeout, image too small), the function returns an error discarding successfully-fetched page content.

The AI agent receives an error instead of the content it needs. Screenshot is a non-critical side-effect — PutScreenshot already ignores errors at the call-site.

Reported in #149.

Solution

Log a warning on screenshot failure instead of returning an error. Content is preserved.

if errScreenshot != nil {
    log.Printf("Warning: screenshot failed for %s (content still available): %v", url, errScreenshot)
    screenshotName = ""
}

Changes

  • backend/pkg/tools/browser.go: 3 methods changed — ContentMD(), ContentHTML(), Links() (+6/-3)

Testing

  • Content succeeds + screenshot fails → content returned ✅
  • Both succeed → unchanged ✅
  • Content fails → error returned ✅

Closes #149

Screenshot capture is a non-critical side-effect — its only purpose
is to write a PNG to disk for logging. When it fails (scraper down,
timeout, small image), the successfully-fetched page content was being
discarded and an error returned to the AI agent.

Change all three browser methods (ContentMD, ContentHTML, Links) to
log a warning on screenshot failure instead of returning an error,
preserving the successfully-fetched content for the agent.

Closes vxcontrol#149
@asdek
Copy link
Contributor

asdek commented Mar 2, 2026

thank you for the PR, but these changes were included by #150

@asdek asdek closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Browser tool discards successfully-fetched page content when screenshot fails

2 participants