feat: web screenshot tool and file-download support#288
Open
philipph-askui wants to merge 2 commits into
Open
Conversation
Add a WebSaveScreenshotTool, importable from askui.tools.store.web, that saves a screenshot of the currently active browser page to disk as a PNG. It mirrors ComputerSaveScreenshotTool but extends PlaywrightBaseTool so the screenshot is captured from the Playwright page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a `download_dir` parameter to `WebAgent` and `PlaywrightAgentOs`. When set, every file downloaded by the browser is automatically copied into that directory once it finishes, saved under its browser-suggested filename and auto-renamed on collision (e.g. `report (1).pdf`) so nothing is overwritten. This is implemented via a persistent page `download` event listener rather than `expect_download`, because the click that triggers a download and the save are decoupled across the agent's tool calls. Files are copied while the browser context is still open, since Playwright deletes the temporary download files when the context closes. Save failures are reported but never propagated, so a failed download cannot break an automation run. A `downloaded_files` property exposes the saved paths for programmatic use. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
programminx-askui
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two web-automation capabilities to the SDK:
WebSaveScreenshotTool— importable fromaskui.tools.store.web. Saves a screenshot of the currently active browser page to disk as a PNG. Analogous toComputerSaveScreenshotTool, but extendsPlaywrightBaseToolso the capture comes from the Playwright page.Automatic downloads — a new
download_dirparameter onWebAgent/PlaywrightAgentOs. When set, every file the browser downloads is automatically copied into that directory once it finishes, under its browser-suggested filename, auto-renamed on collision (report (1).pdf, …) so nothing is overwritten. Adownloaded_filesproperty exposes the saved paths.Why this design for downloads
page.expect_download()(which wraps the click) doesn't fit. Instead a persistentdownloadevent listener registered inconnect()captures every download.save_as()works there and auto-creates parent dirs).When
download_dirisNone(default), behaviour is unchanged.Tests
tests/unit/tools/playwright/test_agent_os.py— unit tests for the collision-aware unique-path helper.tests/e2e/tools/playwright/test_download.py— real headless-Chromium tests: download copied intodownload_dir, collision auto-rename leaves the original intact, anddownload_dir=Noneleaves nothing behind.pdm run qa:fixis clean (typecheck, lint, format); unit + e2e download tests pass.Known limitation
The download listener is attached to the main page only; downloads triggered in a popup/new tab are not captured yet. Can extend to context-level page tracking if needed.
🤖 Generated with Claude Code