Skip to content

Conversation

@3clyp50
Copy link

@3clyp50 3clyp50 commented Feb 5, 2026

Add Timeout Parameter to Click Action

Summary

Adds timeout parameter to the click command, exposing Playwright's built-in timeout option to prevent indefinite hangs on problematic pages.

Why this is Critical for AI Agents

AI agents using agent-browser get stuck indefinitely when clicking elements on:

  • Pages with slow/broken JavaScript that never completes event handlers
  • Elements with async handlers that don't resolve
  • SPAs with navigation logic that hangs
  • Pages with infinite loading states

Blockers:

  • Production agents cannot afford indefinite hangs - they need fail-fast behavior
  • Current workaround (external timeouts) doesn't cleanly abort Playwright operations
  • Other automation frameworks (Selenium, Puppeteer) all expose timeout controls

Changes

CLI (cli/src/commands.rs):

agent-browser click @e1 --timeout 500  # Fail after milliseconds instead of hanging

JSON Protocol (src/protocol.ts, src/types.ts):

{"action": "click", "selector": "@e1", "timeout": 500}
  • Added extract_timeout() helper that properly parses and filters --timeout flag
  • Prevents flag leakage into text content for other commands
  • Timeout validation via Zod (positive numbers only)
  • Pass-through to Playwright's native click({ timeout }) option
  • Updated skills/agent-browser/SKILL.md with example

Tests Added:

  • Protocol validation: accept valid timeout, reject negative values
  • All existing tests pass: 213 passed, 9 skipped

Testing

# Test timeout behavior
agent-browser open https://slow-site.example.com
agent-browser click "#broken-button" --timeout 1000  # Fails fast instead of hanging

# Without timeout (default Playwright behavior)
agent-browser click "#normal-button"  # Works as before

Breaking Changes

None. Timeout is optional and backward compatible with existing usage.

Exposes Playwright's timeout option in CLI and JSON protocol to prevent indefinite hangs when clicking elements on script-heavy or slow-loading pages.

Changes:
- CLI: Added --timeout flag to click command with proper arg filtering
- Protocol: Added timeout validation (positive number, optional)
- Types: Extended ClickCommand interface with timeout field
- Actions: Pass timeout to Playwright's click() method
- Tests: Added validation tests for timeout parameter
- Docs: Updated SKILL.md with timeout usage example

Implementation uses helper function extract_timeout() that properly parses and filters --timeout flag from CLI arguments, preventing flag leakage into text content for other commands.

All tests pass (213 passed, 9 skipped).
@vercel
Copy link
Contributor

vercel bot commented Feb 5, 2026

@3clyp50 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant