Browser4 AGENTS.md

Repository-specific instructions for Browser4, a browser automation project whose command-line client sends requests through a service to a browser driver. They describe the project structure, request flow, batch commands, and known Chrome DevTools Protocol issues.

In plain words
What is it for?
Use them when developing, debugging, or testing Browser4 code across its Rust command-line client, Kotlin service, browser driver, agent tools, and end-to-end test harness.
Why use it?
They help an agent change the correct layer and follow how a browser command travels through the system. This reduces mistakes caused by misunderstanding the repository's architecture or command names.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/platonai/browser4/agents-md
Clone the repo
git clone --depth 1 https://github.com/platonai/Browser4

Made for: Codex, OpenCode.

Per session 4,778 This file is loaded in full into every session.
When invoked 4,778 The same file — it is already loaded in full.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.04778 $0.04778
Opus 5 $0.02389 $0.02389
Sonnet 5 $0.00956 $0.00956
Haiku 4.5 $0.00478 $0.00478

Measured yesterday against content hash 9d2ad598b116, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

Browser4 AGENTS.md scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

| `.ps1` scripts don't run on Linux | `sudo apt-get install -y powershell`, then `pwsh script.ps1` |
AGENTS.md · 380 lines

How it starts

The opening of the file, as written. The whole thing — 380 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Repository Guidelines

Repo: https://github.com/platonai/Browser4

Architecture

browser4-cli (Rust)  ──MCP over HTTP──▶  browser4-rest (Kotlin/Spring)  ──▶  PulsarWebDriver (Kotlin/CDP)
     ▲                                           │
     │                                           ▼
     └──── e2e tests ────▶  Fixture HTTP server (Rust test harness)
  • CLI: cli/browser4-cli/ — Rust binary, MCP tool calls over HTTP
  • Backend: browser4-rest/ — Spring Boot, MCPToolController dispatches tools
  • Browser driver: browser4-core/browser4-browser/PulsarWebDriver wraps CDP
  • Agent tools: browser4-agentic/AgentToolManager maps MCP tool names → driver methods

Dispatch chain (CLI → browser)

  1. CLI builds MCP tool call: {tool: "browser_type", arguments: {ref: "#el", text: "hi"}}
  2. MCPToolController.callTool()dispatchToToolExecutor()
  3. normalizeFrontendToolCall() applies FRONTEND_TOOL_NAME_ALIASES (e.g., browser_typefill)
  4. DefaultArgumentNormalizer maps refselector, strips sessionId, converts snake_case
  5. resolveMcpToolCall()ToolCall("tab", "fill", args)
  6. AgentToolManager.execute()executor.callFunctionOn(toolCall, driver)PulsarWebDriver.fill()

Batch commands

handleCommandBatch()handleBatchTool() in MCPToolController. CLI's compile_batch_request() builds step arrays with op: "tool". preFocusSelector only added for keydown/keyup (not fill/type/press).

Known CDP pitfalls

  • crbug.com/444929150: Input.dispatchMouseEvent type mouseWheel race condition in headless Chrome. Fix: dispatch to {passive: false} wheel listener.
  • Cursor positioning: DOM.focus() + Input.dispatchMouseEvent (click) may leave cursor at 0. Fix: setSelectionRange(99999, 99999) after focus+click.
  • Input.insertText racing: 0ms delay between chars drops input events. Fix: use same inter-char delay as type() via randomDelayMillis("type") (90-240ms).

Read the full file on GitHub · 380 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 380 lines · 4,778 tokens per session scan B 9d2ad598b116

Subscribe to this mod's changes

Browser4 AGENTS.md is an instructions file published in the GitHub repository platonai/Browser4 (1,114 stars, last pushed 2d ago), licensed Apache-2.0. It adds 4,778 tokens to every session, about $0.0239 per session on Opus 5. A static security scan graded it B with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.