Skip to main content

The Observe-Decide-Act Loop

AI agents interact with browsers through a repeating cycle:
1

Observe

Call agent/observe to get a structured snapshot of the page: interactive elements with stable refs, accessibility tree, optional annotated screenshot.
2

Decide

The LLM processes the observation and decides which action to take next. Element refs and action hints from observe make this decision straightforward.
3

Act

Call agent/act with a sequence of steps built from the LLM’s decision. Each step uses refs or semantic selectors from the observation.
4

Repeat

After acting, observe again to see the result. The incremental observation mode shows only what changed.

Fusion for Fewer Roundtrips

Fusion operations combine multiple BAP calls into single requests. For agents, this means fewer tool calls, less token overhead, and faster execution. Instead of two calls (navigate then observe), fuse them:

Act + Post-Observe

Get the page state after an action sequence without a separate observe call:

Pre + Act + Post (Full Kernel)

Capture state before and after in a single call:

Response Tiers

Control how much data comes back in observations to minimize token usage:

Incremental Observation

After the first observation, use incremental mode to get only what changed:

Session Persistence

Agent sessions survive disconnections. Include a sessionId when connecting:
The CLI auto-generates session IDs as cli-<port> (e.g., cli-9222). Override with the -s flag:
Dormant sessions expire after 300 seconds by default (configurable via dormantSessionTtl). After expiry, the browser state is destroyed.

Annotated Screenshots (Set-of-Marks)

For vision-capable LLMs, request annotated screenshots with element badges:

Platform Installation

BAP CLI supports 13 AI agent platforms via bap install-skill:
This copies the appropriate SKILL.md file to the detected platform’s skill directory, giving the agent structured documentation about BAP’s capabilities.