Skip to content

feat(browser): add agent download actions#74411

Closed
GRD-Chang wants to merge 1 commit into
openclaw:mainfrom
GRD-Chang:fix/browser-agent-download-actions
Closed

feat(browser): add agent download actions#74411
GRD-Chang wants to merge 1 commit into
openclaw:mainfrom
GRD-Chang:fix/browser-agent-download-actions

Conversation

@GRD-Chang

Copy link
Copy Markdown
Contributor

Summary

  • Problem: the agent-facing browser tool did not expose the managed browser download helpers even though the CLI/control API already supported /download and /wait/download.
  • Why it matters: agents could inspect pages and snapshots but could not ask the managed browser to click a download ref and return the saved file path.
  • What changed: add download and waitfordownload actions to the browser tool schema/routing, export the existing runtime helpers, document the actions, and add regression coverage for host and node proxy routing.
  • What did NOT change (scope boundary): existing-session download interception remains managed-only; this does not bypass the browser server's existing 501/unsupported behavior for profiles that cannot intercept downloads.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: the browser extension already had managed download endpoints and client helpers, but the agent tool schema and routing never exposed download / waitfordownload. During implementation, the new action routing also needed to align outer transport timeouts with browser-side download waits instead of keeping the older fixed 20s HTTP/proxy timeout.
  • Missing detection / guardrail: there was no agent-tool regression test asserting download action routing or transport timeout propagation.
  • Contributing context (if known): prior PR feat: expose download and waitForDownload actions in browser agent tool #12378 attempted a similar action surface but did not land.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/browser/src/browser-tool.test.ts, extensions/browser/src/browser/client-actions-core.downloads.test.ts
  • Scenario the test should lock in: agent browser actions route download and waitfordownload through the host client or node proxy, preserve request bodies, require explicit ref/path where needed, and give long download waits enough outer transport timeout.
  • Why this is the smallest reliable guardrail: the browser-side download implementation already exists; the risk here is the agent tool contract and proxy/client timeout handoff.
  • Existing test that already covers this (if any): N/A
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

Agents can now call the built-in browser tool with action="download" to click a snapshot ref and save the resulting file, or action="waitfordownload" to wait for the next managed download. Results include the saved download path returned by the existing browser control API.

Diagram (if applicable)

Before:
[agent browser tool] -> [snapshot/action helpers only] -> [no download action]

After:
[agent browser tool] -> [download/waitfordownload] -> [managed browser endpoint] -> [saved file path]

Security Impact (required)

  • New permissions/capabilities? (Yes/No) Yes
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) Yes
  • Command/tool execution surface changed? (Yes/No) Yes
  • Data access scope changed? (Yes/No) Yes
  • If any Yes, explain risk + mitigation: this exposes existing managed browser download endpoints through the agent tool. It keeps the existing browser server/profile capability checks, keeps existing-session download interception managed-only, and constrains saved paths to the browser download path handling already used by the control API.

Repro + Verification

Environment

  • OS: Linux 6.8.0-55-generic x86_64
  • Runtime/container: Node v24.13.0, pnpm 10.33.0
  • Model/provider: N/A
  • Integration/channel (if any): Browser plugin / built-in browser tool
  • Relevant config (redacted): default managed browser action routing; node proxy tests use mocked browser-capable nodes

Steps

  1. Create the browser tool.
  2. Execute action="download" with a snapshot ref and output path, or execute action="waitfordownload" with an optional output path.
  3. For node targets, route the request through browser.proxy and preserve both body timeout and outer transport timeout.

Expected

  • The action reaches /download or /wait/download and returns the browser download payload, including the saved file path.
  • Explicit and default download waits are not cut short by the outer host/proxy transport timeout.

Actual

  • Implemented behavior matches expected in unit/seam tests.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Verification run locally:

pnpm test extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/client-actions-core.downloads.test.ts -- --reporter=verbose
# passed: 2 files, 56 tests

NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test:changed
# passed: 2 shards, 854 passed, 1 skipped

pnpm docs:check-mdx
# passed

pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/tools/browser-control.md extensions/browser/plugin-registration.ts extensions/browser/src/browser-runtime.ts extensions/browser/src/browser-tool.runtime.ts extensions/browser/src/browser-tool.schema.ts extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser-tool.ts extensions/browser/src/browser/constants.ts extensions/browser/src/browser/client-actions-core.ts extensions/browser/src/browser/client-actions-core.downloads.test.ts
# passed

git diff --check
# passed

NODE_OPTIONS=--max-old-space-size=2048 node scripts/run-oxlint.mjs --tsconfig tsconfig.oxlint.extensions.json extensions/browser/plugin-registration.ts extensions/browser/src/browser-runtime.ts extensions/browser/src/browser-tool.runtime.ts extensions/browser/src/browser-tool.schema.ts extensions/browser/src/browser-tool.ts extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/client-actions-core.ts extensions/browser/src/browser/client-actions-core.downloads.test.ts extensions/browser/src/browser/constants.ts
# passed: 0 warnings, 0 errors

Note: pnpm check:changed passed conflict-marker checks, changelog attribution checks, extension production typecheck, and extension test typecheck, then local broad lint:extensions was terminated by tsgolint with SIGTERM on an 8 GB host. I used the targeted repo lint wrapper above to avoid exceeding the host memory limit.

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: host-client download routing; host-client wait-for-download routing; node proxy download routing; node proxy wait-for-download routing; default 120s download wait transport timeout; explicit 30s download wait transport timeout; required ref/path validation; docs/format/lint/typecheck coverage listed above.
  • Edge cases checked: omitted timeoutMs uses the browser-side default download wait plus transport slack; explicit timeoutMs scales both proxy and gateway waits; existing-session managed-only scope is documented and unchanged.
  • What you did not verify: a live Chromium download in a real browser session; this PR relies on the existing browser-side download implementation and adds the missing agent tool contract/routing coverage.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: exposing downloads through the agent browser tool could let agents save files unexpectedly.
    • Mitigation: the action uses existing managed browser endpoints and their path/profile constraints; unsupported existing-session profiles remain blocked by the browser server.
  • Risk: long download waits could be cut short by outer transport timeouts.
    • Mitigation: host client and node proxy transport timeouts now scale from the effective download wait with slack, with tests for explicit and default waits.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Apr 29, 2026
@greptile-apps

greptile-apps Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds download and waitfordownload actions to the agent-facing browser tool, wiring them through to the existing managed browser /download and /wait/download control API endpoints. The main change beyond schema/routing is replacing the previously hardcoded 20 s HTTP timeout on download requests with a dynamic timeout that scales from the requested wait duration plus per-layer slack, correctly propagated through both the host client and node proxy paths.

Confidence Score: 5/5

This PR is safe to merge; it exposes existing server-side download endpoints with correct timeout layering and good test coverage.

No logic, correctness, or security issues found. The timeout chain (browser-wait → client-HTTP → proxy → gateway) is implemented consistently and verified by dedicated unit tests for both explicit and default waits. Required-param validation, both export paths, and the schema extension are all correct.

No files require special attention.

Reviews (1): Last reviewed commit: "feat(browser): add agent download action..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: current main and the latest release still lack the explicit agent-facing download and waitfordownload browser actions, and this branch contains meaningful implementation work. It is not merge-ready yet because GitHub reports the branch as conflicting, the external PR has only test/mock proof for a new agent download/file-write capability, and maintainers still need to choose this explicit-action API against the open /act metadata approach.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #93250
Summary: This PR is an explicit-action candidate for the canonical browser download feedback issue; another open PR fixes the same user problem through /act response metadata, while earlier explicit-action attempts are closed unmerged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level reproduction is high-confidence: current main and v2026.6.11 have managed /download routes but the agent tool schema and dispatcher do not expose download or waitfordownload. I did not run a live Chromium download in this read-only review.

Is this the best way to solve the issue?

Unclear. Explicit download actions are a plausible owner-boundary fix because the managed routes already exist, but maintainers still need to choose this API shape against the open /act metadata approach and require live proof.

Security review:

Security review cleared: No concrete supply-chain defect was found, but the diff is security-sensitive because it exposes managed browser download endpoints to agents and relies on existing path/profile checks.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-29T14:43:56Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: Peter Steinberger introduced the browser bundled-plugin ownership and current managed download route surface that this PR extends. (role: feature-history owner; confidence: high; commits: 8eeb7f082975, 197510f69302; files: extensions/browser/src/browser-tool.ts, extensions/browser/src/browser-tool.schema.ts, extensions/browser/src/browser/routes/agent.act.download.ts)
  • joshavant: Josh Avant authored the /act route action execution and contract consolidation adjacent to the browser action response path. (role: adjacent contract contributor; confidence: medium; commits: f096fc440686; files: extensions/browser/src/browser/routes/agent.act.ts, extensions/browser/src/browser/routes/agent.act.download.ts, extensions/browser/src/browser/pw-tools-core.interactions.ts)
  • vincentkoc: Vincent Koc appears in recent history touching the browser tool schema/action surface and release-side browser code snapshots, making him a useful routing candidate for current-main drift around this area. (role: recent area contributor; confidence: medium; commits: e085fa1a3ffd; files: extensions/browser/src/browser-tool.schema.ts, extensions/browser/src/browser-tool.ts, docs/tools/browser-control.md)

Codex review notes: model internal, reasoning high; reviewed against 5361e5a0b455.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes:

The PR adds download and waitfordownload browser tool actions, exports the existing download helpers, adjusts download request/proxy timeouts, documents the agent action surface, and adds browser-tool/client-helper regression tests.

Maintainer follow-up before merge:

This is an open implementation PR for a real current-main gap; the remaining action is maintainer review plus CI/security validation of the new agent capability, not an automated repair lane.

Review details

Best possible solution:

Land this PR, or a narrow replacement, after confirming the new agent actions route only through the existing managed download API, preserve download-path restrictions, keep existing-session profiles unsupported, and document the agent action surface alongside the CLI/control API.

Acceptance criteria:

  • pnpm test extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser/client-actions-core.downloads.test.ts -- --reporter=verbose
  • pnpm docs:check-mdx
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/tools/browser-control.md extensions/browser/plugin-registration.ts extensions/browser/src/browser-runtime.ts extensions/browser/src/browser-tool.runtime.ts extensions/browser/src/browser-tool.schema.ts extensions/browser/src/browser-tool.test.ts extensions/browser/src/browser-tool.ts extensions/browser/src/browser/constants.ts extensions/browser/src/browser/client-actions-core.ts extensions/browser/src/browser/client-actions-core.downloads.test.ts
  • pnpm check:changed in Testbox before merge

What I checked:

  • Current schema gap: Current main's BROWSER_TOOL_ACTIONS lists browser actions through pdf, upload, dialog, and act, with no download or waitfordownload action. (extensions/browser/src/browser-tool.schema.ts:19, 8cf724a381a3)
  • Current routing gap: Current main routes pdf directly into upload, dialog, and act; there are no agent-tool switch cases for download actions before the unknown-action fallback. (extensions/browser/src/browser-tool.ts:795, 8cf724a381a3)
  • Lower-level API exists: Current main already registers POST /wait/download and POST /download, rejects existing-session profiles with 501, and returns { ok, targetId, download } from the Playwright download helpers. (extensions/browser/src/browser/routes/agent.act.download.ts:27, 8cf724a381a3)
  • Path constraint evidence: The existing route resolves explicit download output paths under DEFAULT_DOWNLOAD_DIR, and resolveWritablePathWithinRoot rejects traversal, symlink, hardlink, and non-file escapes before the Playwright save path is used. (extensions/browser/src/browser/paths.ts:115, 8cf724a381a3)
  • Existing lower-level tests: Current main has route and Playwright tests for /download and /wait/download, including traversal/symlink rejection and explicit in-root output paths, which supports the PR's claim that the missing surface is the agent tool contract/routing rather than the core browser download implementation. (extensions/browser/src/browser/server.agent-contract-form-layout-act-commands.test.ts:344, 8cf724a381a3)
  • PR diff scope: The PR diff touches browser docs, browser plugin/tool description, runtime helper exports, browser tool schema/routing, browser download timeout handling, and browser-focused tests; it does not modify workflows, dependencies, lockfiles, package scripts, or release publishing surfaces. (ca534ee5d7e3)

Likely related people:

  • steipete: The available current-main blame and log history for the central browser tool schema, routing, download helper, route, and docs paths points to Peter Steinberger, and the related browser download helper/docs history is present in the latest release commit. (role: recent maintainer / likely follow-up owner; confidence: medium; commits: 8055e74485e2, be8c24633aaa; files: extensions/browser/src/browser-tool.ts, extensions/browser/src/browser-tool.schema.ts, extensions/browser/src/browser/client-actions-core.ts)

Remaining risk / open question:

  • The PR exposes an existing managed browser download/file-write capability to the agent-facing browser tool, so maintainers should explicitly confirm the permission boundary and path constraints before merge.
  • The PR body reports targeted tests and changed tests passing, but this read-only review did not execute the PR branch or Testbox changed-gate.
  • The PR body says a live Chromium download was not verified; a managed-browser smoke would reduce residual integration risk if maintainers want stronger proof.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8cf724a381a3.

@GRD-Chang
GRD-Chang force-pushed the fix/browser-agent-download-actions branch from ca534ee to 96c1f7e Compare May 1, 2026 01:57
@GRD-Chang
GRD-Chang force-pushed the fix/browser-agent-download-actions branch from 96c1f7e to f64bac3 Compare May 3, 2026 01:01
@GRD-Chang

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@barnacle-openclaw barnacle-openclaw Bot removed the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@scorpiord

scorpiord commented Jun 15, 2026

Copy link
Copy Markdown

@GRD-Chang Hello, I'm experiencing the same issue and noticed that your PR is addressing it. Could you please update and merge it? I hope to see this fix in a new release.

Thank you!

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 17, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 26, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 29, 2026
@steipete steipete self-assigned this Jul 6, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Landed the improved current-main version in #101369 as 01d6ea1f0e8760fb337169a78361523e331b745b.

Thank you @GRD-Chang for the original explicit download-action design. Your authorship is preserved in the landed commit with Co-authored-by: changcy <[email protected]> and in the release-note context.

I recreated the branch as a maintainer PR because the stale fork branch could not accept the current-main rewrite through the verified GitHub branch-update path without serializing the repository-wide base gap. The replacement keeps the useful functionality and adds typed host/node dispatch, bounded 120/125/130-second wait layers, current-tab navigation enforcement, guarded node path rewriting, docs, and regression coverage.

Verification on the landed patch:

Closing this superseded branch; future contributor PRs are easier to update when the fork stays close to current main and “Allow edits by maintainers” remains enabled.

@steipete steipete closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants