AgentOpt Skill
End-to-end workflow: user files → ZIP → upload → optimize → poll → results.Trigger
Activate when user says things like:- “optimize my agent / prompt”
- “run agentopt on my files”
- “improve my system prompt using the optimizer”
/AgentOpt
Prerequisites
Ask for these if not already provided:Step 1 — Validate & convert files
agent.py requirements
Must have EDITABLE and FIXED boundary markers, and exportrun_batch:
- If user’s code has no
EDITABLE SECTION STARTmarker → wrap theirSYSTEM_PROMPT+run_batchin the EDITABLE section, append the FIXED boundary block verbatim. - If
run_batchdoesn’t exist → wrap their inference logic inside the template above. MODELmust be set to the target model string.- The FIXED boundary block must not be modified.
examples/gaia/agent.py, examples/finance_agent/agent.py
eval.py requirements
Must definescore(expected: str, predicted: str) -> float returning 0.0–1.0.
- If user has a different metric (e.g. F1, BLEU, exact_match) → wrap it in a
score(expected, predicted)function that returns float 0–1. - If user has no eval → use the exact/partial match template above, noting that they should customize it for their task.
examples/gaia/eval.py, examples/finance_agent/eval.py, examples/trail/eval.py
dataset.json requirements
JSON array of{"input": str, "answer": str} objects. Minimum 10 rows.
- CSV with
input/answercolumns →python3 -c "import csv,json,sys; rows=list(csv.DictReader(open('data.csv'))); json.dump([{'input':r['input'],'answer':r['answer']} for r in rows],sys.stdout,indent=2)" - Different column names → remap to
input/answer. - JSONL →
python3 -c "import json,sys; data=[json.loads(l) for l in open('data.jsonl')]; json.dump(data,sys.stdout,indent=2)" - Fewer than 10 rows → warn the user; optimizer requires minimum 10.
Step 2 — Build ZIP
Step 3 — Upload ZIP to Cloudflare R2
Requires R2 credentials in environment:Step 4 — Submit optimization job
Response:
Step 5 — Poll status until complete
Poll every 30 seconds. Show live progress each iteration.queued → running → completed | interrupted | failed
AgentOpt-specific status fields:
Step 6 — Fetch and display results
Complete end-to-end script
Save to/tmp/run_agentopt.sh and run:
Reference examples
Pre-built working examples inexamples/:
Quick test with a pre-built example: