Skip to content

Agent interaction patterns

NeedUse
Operate the browser the user already authenticatedunsurf-local-mcp
Record a browser run for reviewrecord / recordAttachedLocal
Retry until visual success is provenloop
Ask what happened in a runobserveVideo
Reuse a stable hidden HTTP seamscout → worker → heal

Use local MCP when another nearby agent should act inside the user’s real session:

{
"mcpServers": {
"unsurf-local": { "command": "unsurf-local-mcp" }
}
}

Typical flow:

  1. call unsurf_local_sessions
  2. inspect the attachable tabs
  3. call unsurf_local_execute
  4. optionally record the action plan

This is the right path for authenticated dashboards, enterprise apps, and any work where the browser identity matters.

If the task matters enough to review later, record it:

Terminal window
unsurf record ./run.ts --task "dashboard proof" --cdp-port 9222

A proof bundle gives the agent and the human a shared artifact: the browser video, trace, status, and viewer link.

Pattern 3 — Loop until the North Star is met

Section titled “Pattern 3 — Loop until the North Star is met”

Use loop() when the success condition is visual or interaction-heavy:

Terminal window
unsurf loop "fill the three visible form fields" \
--north-star "Did all three fields contain non-empty values?" \
--max-iter 3 \
--cdp-port 9222

Good North Stars are yes/no and observable from the recording.

If an operation repeats often and the browser exposes a stable HTTP endpoint, use:

scout once → worker many times → heal on drift

That path is still excellent for search APIs, data loaders, and repeatable CRUD-like flows. It is simply not the only Unsurf workflow.

Use Unsurf like this:
1. If the task depends on the user's existing login, use the local browser MCP.
2. If the task should be reviewable, record it.
3. If success is visual, prefer loop with a yes/no North Star.
4. If the site exposes a stable API seam worth reusing, scout it and replay it with worker.
5. Heal a broken seam instead of repeatedly retrying the same dead path.
FailureAgent response
No local browser sessionsAsk the user to open/authenticate the browser runtime
Browser action failsStop the plan, return the failing action, do not blindly continue
Loop misses North StarRefine or stop at budget
worker path driftsCall heal