Optimize Agent Prompt
BrowserbaseOfficialPublished by Browserbase
- Skill
- Workflow
- Agent tooling
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured methodology for refining the system prompts of Browserbase Agents. By establishing a fixed task, result schema, and evaluation oracle, it enables developers to treat the agent as an inner-loop rollout. The process involves running baseline tests, inspecting message trajectories and session logs to identify failures, and applying targeted heuristic improvements to the system prompt. The workflow emphasizes empirical validation, requiring consistent performance across multiple runs before confirming a prompt as optimal for a specific task distribution.
What it does
- Initializes an isolated workspace for prompt optimization experiments.
- Executes Browserbase Agent runs while capturing messages, session logs, and performance metrics.
- Provides tools to inspect agent trajectories and diagnose the root cause of failures.
- Facilitates the systematic application of counterfactual prompt improvements.
- Generates comparison reports to track progress across iterations.
- Enforces convergence rules to ensure prompt stability and reliability.
When to use it
- When developing or refining a Browserbase Agent demo or proof-of-concept.
- When you need to improve the accuracy or reliability of an agent's system prompt.
- When diagnosing flaky agent behavior or unproductive message spirals.
- When applying automated research patterns to the Browserbase Agents API.
Advantages
- Reduces guesswork by using observable evidence from agent messages and session logs.
- Prevents regression by enforcing strict evaluation criteria and comparison reporting.
- Optimizes for both performance and cost by identifying and stopping unproductive agent spirals.
- Ensures prompt changes are attributable to specific failures.
- Provides a clear path to graduating optimized prompts into production.
Usage examples
- “Initialize a new optimization experiment for my web scraping agent.”
- Creates a new workspace directory with the necessary task.json and prompt templates to begin the experiment.
- “Run the current iteration of the agent prompt and generate a report.”
- Executes the agent, logs the results, and produces a comparison table showing performance metrics against previous runs.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/browserbase/optimize-agent-prompt/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip optimize-agent-prompt.zip -d .agents/skills
Documentation by Browserbase
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:
node <skill-dir>/scripts/optimize_agent_prompt.mjs init \
--workspace ./agent-prompt-optimization/<experiment-name> \
--name <experiment-name>Edit the generated files:
task.json: keeptask,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 when designing the task or score.
Run the baseline
node <skill-dir>/scripts/optimize_agent_prompt.mjs run \
--workspace ./agent-prompt-optimization/<experiment-name> \
--prompt prompts/iteration-001.md \
--label iteration-001The harness creates one reusable Browserbase Agent, updates its systemPrompt on later iterations, starts the run, polls messages and status, and writes:
runs/<label>/
├── system-prompt.md
├── created-run.json
├── run.json
├── messages.json
├── session-logs.json
└── summary.jsonIt 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:
node <skill-dir>/scripts/optimize_agent_prompt.mjs inspect \
--workspace ./agent-prompt-optimization/<experiment-name> \
--label iteration-001Then 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 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
nullinstead 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:
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
- ATTRIBUTION.mdAdded by AutoGineer906 B
- LICENSE.txt1.0 KiB
- SKILL.md5.5 KiB
- agents/openai.yaml232 B
- evals/evals.json2.2 KiB
- references/api.md3.0 KiB
- references/evaluation.md2.3 KiB
- scripts/optimize_agent_prompt.mjsScript11.8 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs an API key, Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Browserbase
- Publisher
- Browserbase (Official)
- Source
- browserbase/skills · skills/optimize-agent-prompt · commit 6811ca3
- Licence
- MIT License (redistribution allowed)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Browserbase or Browserbase.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download optimize-agent-prompt.zip