# google-gemini/computer-use-preview architecture

> Architecture diagram of the GitHub repository google-gemini/computer-use-preview, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google-gemini/computer-use-preview
- Repository: https://github.com/google-gemini/computer-use-preview
- Video tour (about a minute): https://gitdiagram.com/google-gemini/computer-use-preview/video

## Overview

Computer Use Preview is a CLI-driven browser agent: a user supplies a task, the agent asks Gemini for computer-use actions, dispatches those actions to a selected browser backend, and sends the resulting page state back into the interaction. Playwright provides local browser control; Browserbase reuses its computer behavior over a remotely hosted browser session. The excerpts show the CLI wiring, agent/model interaction, and backend calls; finer-grained behavior inside the unsampled agent loop is not expanded here.

Main entry points: [`main.py`](https://github.com/google-gemini/computer-use-preview/blob/main/main.py) (Agent CLI), [`computers/playwright/playwright.py`](https://github.com/google-gemini/computer-use-preview/blob/main/computers/playwright/playwright.py) (Playwright browser), [`agent.py`](https://github.com/google-gemini/computer-use-preview/blob/main/agent.py) (Agent loop), [`computers/browserbase/browserbase.py`](https://github.com/google-gemini/computer-use-preview/blob/main/computers/browserbase/browserbase.py) (Browserbase backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Task entry"]
  node_cli["Agent CLI<br/>[main.py]"]
end

subgraph group_agent["Agent runtime"]
  node_agent_loop["Agent loop<br/>[agent.py]"]
end

subgraph group_browsers["Browser environments"]
  node_computer_api["Computer interface<br/>[computer.py]"]
  node_playwright["Playwright browser<br/>[playwright.py]"]
  node_browserbase["Browserbase backend<br/>[browserbase.py]"]
end

node_user(("Task user"))
node_gemini{{"Gemini API"}}
node_browserbase_service{{"Browserbase service"}}
node_web_page(("Web page"))

node_user -->|"submits task"| node_cli
node_cli -->|"starts agent"| node_agent_loop
node_cli -->|"selects backend"| node_playwright
node_cli -->|"selects backend"| node_browserbase
node_agent_loop -->|"requests actions"| node_gemini
node_agent_loop -->|"dispatches actions"| node_computer_api
node_playwright -.->|"implements controls"| node_computer_api
node_browserbase -->|"inherits controls"| node_playwright
node_playwright -->|"controls browser"| node_web_page
node_browserbase -->|"creates session"| node_browserbase_service

click node_cli "https://github.com/google-gemini/computer-use-preview/blob/main/main.py"
click node_agent_loop "https://github.com/google-gemini/computer-use-preview/blob/main/agent.py"
click node_computer_api "https://github.com/google-gemini/computer-use-preview/blob/main/computers/computer.py"
click node_playwright "https://github.com/google-gemini/computer-use-preview/blob/main/computers/playwright/playwright.py"
click node_browserbase "https://github.com/google-gemini/computer-use-preview/blob/main/computers/browserbase/browserbase.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_browserbase_service toneBlue
class node_agent_loop toneAmber
class node_computer_api,node_playwright,node_browserbase,node_gemini toneMint
class node_user toneRose
class node_web_page toneIndigo
```

## Components

### Task entry

- [Agent CLI](https://github.com/google-gemini/computer-use-preview/blob/main/main.py): `main.py`

### Agent runtime

- [Agent loop](https://github.com/google-gemini/computer-use-preview/blob/main/agent.py): `agent.py`

### Browser environments

- [Computer interface](https://github.com/google-gemini/computer-use-preview/blob/main/computers/computer.py): `computers/computer.py`
- [Playwright browser](https://github.com/google-gemini/computer-use-preview/blob/main/computers/playwright/playwright.py): `computers/playwright/playwright.py`
- [Browserbase backend](https://github.com/google-gemini/computer-use-preview/blob/main/computers/browserbase/browserbase.py): `computers/browserbase/browserbase.py`

### Other components

- **Task user**
- **Gemini API**
- **Browserbase service**
- **Web page**

## Connections

- Task user → Agent CLI: submits task (evidence: `README.md`)
- Agent CLI → Agent loop: starts agent (evidence: `main.py`)
- Agent CLI → Playwright browser: selects backend (evidence: `main.py`)
- Agent CLI → Browserbase backend: selects backend (evidence: `main.py`)
- Agent loop → Gemini API: requests actions (evidence: `agent.py`)
- Agent loop → Computer interface: dispatches actions (evidence: `agent.py`)
- Playwright browser → Computer interface: implements controls (evidence: `computers/playwright/playwright.py`)
- Browserbase backend → Playwright browser: inherits controls (evidence: `computers/browserbase/browserbase.py`)
- Playwright browser → Web page: controls browser (evidence: `computers/playwright/playwright.py`)
- Browserbase backend → Browserbase service: creates session (evidence: `computers/browserbase/browserbase.py`)
