Skip to content
Skills Library
AI & agents · Testing

optimize-agent-prompt

/optimize-agent-prompt

Builds and improves Browserbase Agent API demos through an Autobrowse-style outer loop: run a fixed task, collect Agent messages and session logs, score the result, revise one system-prompt heuristic, and confirm convergence. Use when creating a Browserbase Agents demo or POC, optimizing an Agent system prompt, diagnosing flaky Agent runs, or applying auto-research/autobrowse to the Browserbase Agents API.

Repository
skills ↗
Licence
MIT
Last repository change
01.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
7
Scripts
1
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 01.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 1 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/optimize_agent_prompt.mjs

What it does and when to use it

Builds and improves Browserbase Agent API demos through an Autobrowse-style outer loop: run a fixed task, collect Agent messages and session logs, score the result, revise one system-prompt heuristic, and confirm convergence. Use when creating a Browserbase Agents demo or POC, optimizing an Agent system prompt, diagnosing flaky Agent runs, or applying auto-research/autobrowse to the Browserbase Agents API.

Original author description

Builds and improves Browserbase Agent API demos through an Autobrowse-style outer loop: run a fixed task, collect Agent messages and session logs, score the result, revise one system-prompt heuristic, and confirm convergence. Use when creating a Browserbase Agents demo or POC, optimizing an Agent system prompt, diagnosing flaky Agent runs, or applying auto-research/autobrowse to the Browserbase Agents API.

How it works

  1. Set up the experiment
  2. Run the baseline
  3. Diagnose from observable evidence
  4. Improve one heuristic
  5. Judge and converge
  6. Graduate into the demo
Original SKILL.md headings · 114 lines, 671 words
SKILL.md preview
---
name: optimize-agent-prompt
description: "Builds and improves Browserbase Agent API demos through an Autobrowse-style outer loop: run a fixed task, collect Agent messages and session logs, score the result, revise one system-prompt heuristic, and confirm convergence. Use when creating a Browserbase Agents demo or POC, optimizing an Agent system prompt, diagnosing flaky Agent runs, or applying auto-research/autobrowse to the Browserbase Agents API."
license: MIT
allowed-tools: Bash Read Write Edit Grep Glob
---

# Optimize Agent Prompt

Optimize a Browserbase Agent's `systemPrompt` while holding its task, result schema, variables, and evaluation criteria fixed. Treat the outer agent as the teacher and each Browserbase Agent run as an inner-agent rollout.

Use Node.js 18 or later and set `BROWSERBASE_API_KEY`. The harness uses only Node.js built-in modules.

## Set up the experiment

Choose a short experiment name and create an isolated workspace inside the demo or POC repository:

```bash
node <skill-dir>/scripts/optimize_agent_prompt.mjs init \
  --workspace ./agent-prompt-optimization/<experiment-name> \
  --name <experiment-name>
```

Edit the generated files:

- `task.json`: keep `task`, `resultSchema`, variables, browser settings, and evaluation oracle stable across iterations.
- `prompts/iteration-001.md`: write the minimal baseline system prompt. Include irreversible-action guardrails when applicable.

Use concrete success criteria. Prefer a strict JSON Schema with required fields and `null` for unavailable facts. Add known-field regexes and factuality-warning regexes under `evaluation` when a truth oracle exists. Read [references/evaluation.md](references/evaluation.md) when designing the task or score.

## Run the baseline

```bash
node <skill-dir>/scripts/optimize_agent_prompt.mjs run \
  --workspace ./agent-prompt-optimization/<experiment-name> \
  --prompt prompts/iteration-001.md \
  --label iteration-001
```

The harness creates one reusable Browserbase Agent, updates its `systemPrompt` on later iterations, starts the run, polls messages and status, and writes:

```text
runs/<label>/
├── system-prompt.md
├── created-run.json
├── run.json
├── messages.json
├── session-logs.json
└── summary.json
```

It stops a run after the configured message budget instead of paying for an unproductive spiral. Use `--max-messages`, `--timeout-ms`, `--proxies`, or `--verified` only when the task needs different values from `task.json`.

## Diagnose from observable evidence

Start with the compact trajectory:

```bash
node <skill-dir>/scripts/optimize_agent_prompt.mjs inspect \
  --workspace ./agent-prompt-optimization/<experiment-name> \
  --label iteration-001
```

Then read `summary.json` and drill into `messages.json` at the first wrong or wasted turn. Agent messages expose ordered tool calls, tool results, errors, and final output. A `reasoning` part may contain no readable text; never require hidden chain-of-thought for the teacher loop.

Read `session-logs.json` only when browser-level evidence can distinguish the cause—for example, a redirect, 403, failed request, console error, or hidden endpoint. Empty session logs can mean the Agent completed with search/fetch tools and never drove its browser.

See [references/api.md](references/api.md) for endpoint shapes, pagination, result normalization, and trace caveats.

## Improve one heuristic

Find the earliest consequential failure and state one counterfactual:

> If the system prompt had instructed X, the Agent would have avoided Y, as shown by tool result Z.

Copy the current prompt to `prompts/iteration-NNN.md` and make one attributable change. Typical improvements are:

- cap retries after a repeated block or identical error;
- distinguish public identifiers from private/internal IDs;
- prefer search/fetch before launching a browser when interaction is unnecessary;
- separate current snapshots from dated historical events;
- define when a qualified fallback counts as completed;
- require `null` instead of guessed values;
- add a tool-call or evidence budget.

Keep wins. If the new run regresses, restore the previous prompt and test a different hypothesis rather than stacking more rules.

## Judge and converge

Generate the comparison table after each run:

```bash
node <skill-dir>/scripts/optimize_agent_prompt.mjs report \
  --workspace ./agent-prompt-optimization/<experiment-name>
```

Judge more than field completeness. Require:

- terminal status `COMPLETED`;
- required fields populated or explicitly nullable;
- known-fact checks passing when available;
- no factuality-warning match;
- provenance and safety constraints preserved;
- fewer messages or lower duration without quality loss.

Once a prompt wins, run it again unchanged with a new label. Converge only after it passes at least two of the last three runs and one pass is an unchanged confirmation. Do not call a prompt globally optimal from one task; describe it as the best prompt for the tested task distribution.

## Graduate into the demo

Use the confirmed prompt as the Agent's production `systemPrompt`. Keep the strict result schema and per-run variables. Preserve the experiment workspace or its report so reviewers can audit why each instruction exists.

In the final handoff, report:

- baseline versus winning score, duration, and message count;
- the first wrong turn each prompt change fixed;
- whether session logs added evidence;
- the winning prompt path;
- confirmation-run results;
- limitations and the next holdout matrix.
Files in this package (7)
  • LICENSE.txt 1 KB
  • SKILL.md 5 KB
  • agents/openai.yaml 1 KB
  • evals/evals.json 2 KB
  • references/api.md 3 KB
  • references/evaluation.md 2 KB
  • scripts/optimize_agent_prompt.mjs 12 KB

Versions

The database has no other skills named optimize-agent-prompt.

Database snapshot: 13.11.2026 · package version 73b68390c4e5 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100autobrowse
    Self-improving browser automation via the auto-research loop. Iteratively runs a browsing task, reads the trace, and improves the navigation skill (strategy.md) until it reliably passes. Supports parallel runs across multiple tasks using sub-agents. Use when you want to build or…
  • 90build-browser-agent
    Build or adapt a consumer browser agent with Stagehand v4 and Browserbase using the Browsie pattern. Use for adding persistent browser tools, Browserbase Contexts, vaults, human handoff, CAPTCHA state, channels, or an inspection UI to an agent application. Do not use for a…
  • 90prompt-engineering
    Create, update, review, or discuss an LLM prompt — a system prompt, a skill, or an agent. Use when writing or improving a prompt, discussing a skill or agent, diagnosing prompt failures, or when the user says a prompt needs work.
  • 100cookie-sync
    Sync cookies from local Chrome to a Browserbase persistent context so the browse CLI can access authenticated sites. Use when the user wants to browse as themselves, sync cookies, or log into sites via Browserbase.
  • 95browserbase-cookbook
    Find and adapt Browserbase cookbook examples for browser automation, Stagehand, Playwright, authentication, extraction, agent frameworks, and business workflows. Use when selecting an example, implementing from a Browserbase recipe, or troubleshooting its setup.
  • 90vc:agent-browser
    AI-optimized browser automation CLI with context-efficient snapshots. Use for long autonomous sessions, self-verifying workflows, video recording, and cloud browser testing (Browserbase).

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.