[PR #158] [CLOSED] fix(browser): treat screenshot failure as non-critical warning #198

Closed
opened 2026-06-06 22:09:40 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/158
Author: @haosenwang1018
Created: 3/1/2026
Status: Closed

Base: masterHead: fix/browser-screenshot-non-critical


📄 Description

Summary

Treat screenshot capture failures as non-critical warnings instead of aborting the entire browser tool operation.

Problem

Fixes #149

In ContentMD, ContentHTML, and Links, page content fetching and screenshot capture run concurrently. If the screenshot fails (scraper unavailable, timeout, image too small, etc.), the function returns an error even though the page content was successfully fetched. This causes the AI agent to receive an error like:

browser tool 'markdown' handled with error: failed to fetch screenshot by url '...': ...

The agent then interprets the URL as unreachable and wastes tool calls retrying.

Root Cause

The screenshot is a non-critical side-effect — its only purpose is to write a PNG to disk and log it via PutScreenshot, whose return value is already ignored:

_, _ = b.scp.PutScreenshot(ctx, screen, url, b.taskID, b.subtaskID)

Yet screenshot errors abort the operation that produced the content.

Fix

In all three methods (ContentMD, ContentHTML, Links), when content fetch succeeds but screenshot fails:

  • Log the screenshot error as a warning via logrus.WithError(...).Warnf(...)
  • Clear screenshotName to empty string
  • Return the successfully-fetched content instead of an error

Before / After

Before: Screenshot failure → content discarded → agent receives error
After: Screenshot failure → warning logged → agent receives content normally


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/158 **Author:** [@haosenwang1018](https://github.com/haosenwang1018) **Created:** 3/1/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/browser-screenshot-non-critical` --- ### 📄 Description ## Summary Treat screenshot capture failures as non-critical warnings instead of aborting the entire browser tool operation. ## Problem Fixes #149 In `ContentMD`, `ContentHTML`, and `Links`, page content fetching and screenshot capture run concurrently. If the screenshot fails (scraper unavailable, timeout, image too small, etc.), the function returns an error **even though the page content was successfully fetched**. This causes the AI agent to receive an error like: ``` browser tool 'markdown' handled with error: failed to fetch screenshot by url '...': ... ``` The agent then interprets the URL as unreachable and wastes tool calls retrying. ## Root Cause The screenshot is a non-critical side-effect — its only purpose is to write a PNG to disk and log it via `PutScreenshot`, whose return value is already ignored: ```go _, _ = b.scp.PutScreenshot(ctx, screen, url, b.taskID, b.subtaskID) ``` Yet screenshot errors abort the operation that produced the content. ## Fix In all three methods (`ContentMD`, `ContentHTML`, `Links`), when content fetch succeeds but screenshot fails: - Log the screenshot error as a warning via `logrus.WithError(...).Warnf(...)` - Clear `screenshotName` to empty string - Return the successfully-fetched content instead of an error ## Before / After **Before:** Screenshot failure → content discarded → agent receives error **After:** Screenshot failure → warning logged → agent receives content normally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:40 -04:00
yindo closed this issue 2026-06-06 22:09:40 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#198