Skip to content

feat: add network request capture for browser agent#164

Merged
nwang783 merged 1 commit into
mainfrom
161-fix-the-browser-limitations
Jan 17, 2026
Merged

feat: add network request capture for browser agent#164
nwang783 merged 1 commit into
mainfrom
161-fix-the-browser-limitations

Conversation

@nwang783
Copy link
Copy Markdown
Owner

Summary

Adds network request capture capability to the browser agent, enabling visibility into XHR/fetch API calls made by web applications.

Changes

New Files

  • tempo/tools/network_capture.py - NetworkRequestCapture class that:

    • Captures XHR/fetch requests via CDP Network domain events
    • Fetches response bodies on-demand with size limits (1MB max)
    • Filters capturable content types (JSON, XML, HTML, JS, text)
    • Truncates output at 45k chars with auto-save to file
  • tests/tools/test_network_capture.py - 20 unit tests (all passing)

Modified Files

  • tempo/agents/browser.py - Added network_capture parameter to create_browser_use_agent()
  • tempo/tools/browser_task_tool.py - Integrates NetworkRequestCapture with background CDP attachment
  • tempo/tools/browser_use_adapter.py - Registers get_network_requests tool with async body fetching
  • tempo/prompts/templates/browser_base.txt - Documents the new tool for the agent

New Tool: get_network_requests

get_network_requests(
    filter_type: str = "",        # "xhr", "fetch", "all"
    include_bodies: bool = False, # Fetch response bodies via CDP
    max_requests: int = 30
)

Use cases for security testing:

  • Analyzing API endpoints and request/response patterns
  • Capturing authentication tokens (bearer tokens, API keys, session cookies)
  • Finding hidden API endpoints not visible in page source
  • Understanding client-side API interactions on modern SPAs

Testing

python -m pytest tests/tools/test_network_capture.py -v
# 20 passed

- Add NetworkRequestCapture class to capture XHR/fetch via CDP
- Add get_network_requests tool for browser agent to inspect API calls
- Implement on-demand response body capture with size limits (1MB)
- Filter capturable content types (JSON, XML, HTML, etc.)
- Truncate output at 45k chars with file save for full data
- Add 20 unit tests (all passing)

This gives the browser agent visibility into API calls for:
- Analyzing API endpoints and request/response patterns
- Capturing auth tokens (bearer tokens, API keys, cookies)
- Finding hidden API endpoints not visible in page source
- Understanding client-side API interactions on SPAs
@nwang783 nwang783 linked an issue Jan 17, 2026 that may be closed by this pull request
@nwang783 nwang783 merged commit 910f3d1 into main Jan 17, 2026
3 checks passed
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.

Fix the browser limitations

1 participant