# Agent mode > Looking for a step-by-step walkthrough instead of a reference? > See [agent-tutorial.md](agent-tutorial.md) — it builds one end-to-end > Hacker News scenario covering the REPL, recording, replay, > `--self-heal`, and the MCP roundtrip. `lightpanda agent` runs a browsing agent backed by Lightpanda's headless engine. It can act as: - an **LLM agent** that drives the browser with tool calls (`--provider`), - a **scripted runner** that replays a `.lp` script deterministically, - a **basic REPL** for hand-driven PandaScript with no LLM at all, - a **one-shot task runner** that prints a single answer to stdout (`--task`). All four modes share the same browser tools (`goto`, `click`, `fill`, `tree`, `markdown`, `search`, ...). The same set is exposed over MCP via `lightpanda mcp`, so an agent script and an MCP client see the same surface — that is also the way to drive Lightpanda from an external LLM agent (Claude Code, etc.) without giving Lightpanda its own API key. ## Quick start ```console # Interactive REPL — auto-detects an API key from your environment ./lightpanda agent # Force a specific provider ./lightpanda agent --provider anthropic # Basic REPL (no LLM, PandaScript only) ./lightpanda agent --no-llm # Replay a recorded script ./lightpanda agent session.lp # Replay then continue interactively, appending new commands to the file ./lightpanda agent -i session.lp # One-shot: ask a question, capture the answer on stdout ./lightpanda agent --task "what is on the front page of hn?" ``` ## Providers and API keys | Provider | Flag | API key env | |-------------|------------------------|--------------------------------------| | Anthropic | `--provider anthropic` | `ANTHROPIC_API_KEY` | | OpenAI | `--provider openai` | `OPENAI_API_KEY` | | Gemini | `--provider gemini` | `GOOGLE_API_KEY` or `GEMINI_API_KEY` | | Ollama | `--provider ollama` | none (local) | Defaults: `--model` falls back to a sensible per-provider default; `--base-url` overrides the API endpoint (Ollama defaults to `http://localhost:11434/v1`). ### Provider auto-detection When `--provider` is omitted, lightpanda inspects the environment and picks one: - **No keys set** → falls back to the basic REPL (PandaScript only). Natural language, `LOGIN`, `ACCEPT_COOKIES`, and `--self-heal` will reject. A one-line notice is printed so you know which mode you landed in. - **Exactly one key set** → that provider is used. A one-line notice identifies the env var that won. - **Multiple keys set, on a TTY** → a numbered prompt asks which to use. - **Multiple keys set, non-interactive** → the agent fails fast and tells you to pass `--provider` explicitly. Ollama is never auto-detected (no env var to look at) — pass `--provider ollama` if you want it. `--no-llm` is the explicit bypass: it forces the basic REPL even when an API key is present or `--provider` is set. Use it to test PandaScript without burning tokens, or to disable the LLM in a saved command without editing the existing flags. `--no-llm` wins over `--provider`. ## PandaScript PandaScript is a tiny, line-oriented DSL for browser actions. Each line is one command. Comments start with `#`. Strings are quoted with `'`, `"`, or `'''…'''` for values that mix both quote styles. Quoting rules are content-aware so that recorded scripts round-trip through the parser. Commands are matched **ALL CAPS only** (`CLICK`, `GOTO`, `TYPE`, …). Lowercase or mixed-case input is forwarded to the LLM as natural language, so prompts like `click the login button` flow through without being misread as a `CLICK` command. In the REPL, TAB completion fills in the canonical caps form for you. | Command | Form | Notes | |------------------|---------------------------------------|------------------------------------------------------| | `GOTO` | `GOTO ` | Navigate. URL is unquoted. | | `CLICK` | `CLICK ''` | CSS selector. | | `TYPE` | `TYPE '' ''` | Fills an input. `$LP_*` env refs auto-resolve. | | `WAIT` | `WAIT ''` | Wait for selector to be present in the DOM. | | `SCROLL` | `SCROLL [x] [y]` | Default `(0, 0)`. | | `HOVER` | `HOVER ''` | | | `SELECT` | `SELECT '' ''` | `