How to Run Agent Evals on Your API, CLI or MCP Server
Direct answer
To run agent evals, pick five to ten real tasks your customers' developers do. Have Claude Code and Codex attempt each through your API, CLI or MCP server, unattended in a fresh sandbox with credentials in environment variables, five times per agent. Pass a run only when your API shows the result. Then fix what traces show and rerun.
An agent eval is a test in which a real coding agent attempts a task with your product, with no human help, and a check decides whether it worked. It measures agent usability, which is whether an agent can complete a real task with your product. What are agent evals? covers the idea, and this page is the procedure.
How do I benchmark my API with real coding agents?
You benchmark an API with real coding agents by giving each agent the same task in the same clean sandbox, then scoring every run on whether it worked and what it cost in time, money, tool calls and errors. Devtool Arena, Lightsage's public leaderboard of how well coding agents use 150+ developer tools, publishes runs like this for nine agents. Its eval score is a real integration task run end to end.
Test each interface you ship on its own. In one of our Claude Code runs in October 2026, a voice infrastructure company scored 87 through its CLI, 64 through its API and 51 through its MCP server. The same company can be easy for an agent to use from one interface and hard from another. MCP servers need extra checks, covered in how to test your MCP server with coding agents.
1. Pick real tasks your customers' developers do
Choose five to ten jobs a developer finishes in the first week with your product, and phrase each one the way that developer would type it. Support tickets and your quickstart are good sources. Anthropic's engineering team calls 20 to 50 simple tasks drawn from real failures "a great start" (Anthropic, January 9, 2026), so grow toward that.
Name your product in the prompt, because which tool the agent picks is a separate question. Leave out endpoint names and step-by-step hints, which hide exactly the doc gaps you want to find.
As an illustration, an email API like Resend could start with this task in a Next.js starter app: "Send a welcome email with Resend from the signup route in this app, then trigger it once for [email protected]." Resend's resend.dev test addresses simulate delivery without touching real inboxes (Resend docs).
The step is done when every task has a prompt, a starter project and a yes-or-no check you can run without reading the agent's output.
2. Give the agent only what a new developer has
Run every attempt in a fresh container with the starter project, a runtime, your public docs and a test key in an environment variable. Leave out everything a new developer wouldn't have: your ~/.claude or ~/.codex config, a CLAUDE.md or AGENTS.md you don't ship, and MCP servers you haven't published. Anthropic's guidance is to start each trial from a clean environment, because leftover files and cached data can cause correlated failures.
Getting that key is the first test. On Devtool Arena's Claude Code and Codex API boards (October 2026), dozens of tools are listed as skipped because the agent couldn't get past access: a key that required a paid plan, no key it could obtain, or company verification. When a key needs a paid plan or a manual review, an agent working alone stops before it reaches your code.
Remove the human too. Claude Code's -p flag and codex exec both run without prompts. Codex's default workspace-write sandbox keeps network access off (Codex docs), so turn it on, or every call to your API fails and you blame your API.
3. Run each task on several agents, several times
Run every task at least five times on each agent your customers use, starting with Claude Code and Codex. Agents disagree. Of the 121 tools scored above 30 on both the Claude Code and Codex API boards, 17 differ by 10 points or more (our analysis of the public boards, October 2026). In one of our payments runs, the same API scored 85 with Claude Code and 66 with Codex.
Repeat runs because outcomes vary. In Anthropic's example, an agent that succeeds 75% of the time passes three runs in a row about 42% of the time. We think five runs per agent per task is a sensible floor.
This loop is a manual baseline. Run it inside a throwaway container with git, Node, claude and codex installed:
export RESEND_API_KEY=re_xxxxxxxx # key on a dedicated test account
export ANTHROPIC_API_KEY=sk-ant-xxxxxxxx CODEX_API_KEY=sk-xxxxxxxx
for i in 1 2 3 4 5; do
for agent in claude codex; do
run="$agent-$i"; dir="runs/$run"
cp -r starter "$dir" && git -C "$dir" init -q
TASK="Send a welcome email with Resend from the signup route in this app, then trigger it once for delivered+$run@resend.dev. The API key is in RESEND_API_KEY."
if [ "$agent" = claude ]; then
(cd "$dir" && claude -p "$TASK" --allowedTools "Bash,Read,Edit,Write,WebFetch" \
--output-format stream-json --verbose > trace.jsonl)
else
(cd "$dir" && codex exec --json --sandbox workspace-write \
-c sandbox_workspace_write.network_access=true "$TASK" > trace.jsonl)
fi
./check.sh "$run" >> results.csv
done
done
The flags come from the Claude Code headless docs and the Codex non-interactive docs. For two agents and a handful of tasks, this is enough. If you'd rather use an eval framework, Promptfoo has providers for the Codex SDK, the Claude Agent SDK and the OpenCode SDK (checked October 24, 2026).
For more agents and tasks, Lightsage's Agent Usability is one option. It runs your task on real coding agents against your API, MCP server or CLI in sandboxes, and returns pass or fail, full traces, errors, and per-agent and per-endpoint scores. Startup ($100/month) includes Claude Code and Codex. Growth ($1,000/month) adds seven more agents, including Cursor and OpenCode, and the 7-day trial includes every agent with 1,000 credits and no card.
4. Pass a run only when your system shows the result
Decide pass or fail by querying your own system after the run. Anthropic's example is a flight-booking agent that says "Your flight has been booked", when the outcome is whether a reservation exists in the database.
Exit codes describe the run itself. Claude Code skips an MCP server whose config fails validation, carries on without it and exits cleanly. A failure inside a run, such as missing authentication, comes back as the result text (Claude Code docs). For Resend, the outcome is a delivered email to that run's address, which the List Emails endpoint shows:
#!/usr/bin/env bash
# check.sh RUN: pass only if Resend shows a delivered email to this run's address
sleep 15
curl -s "https://api.resend.com/emails?limit=100" \
-H "Authorization: Bearer $RESEND_API_KEY" |
jq -e --arg to "delivered+$1@resend.dev" \
'.data[] | select(.to[0] == $to and .last_event == "delivered")' > /dev/null \
&& echo "$1,pass" || echo "$1,fail"
Add checks for anything else you care about, such as grep -q '"resend"' package.json to confirm the agent used your SDK.
5. Read the trace to find where it stalled, then fix and rerun
Open each failing trace and find the first error, or the longest stretch of calls that made no progress. Claude Code's stream-json output and Codex's --json output record one event per line, covering commands, file edits, MCP tool calls and messages.
Counts point you to the right trace. In the payments run from step 3, Claude Code (Claude Sonnet 5) finished in 59 seconds with 7 tool calls, no errors and $0.15 of spend. Codex (GPT-6 Sol) took 3 minutes 34 seconds, 59 tool calls, 5 tool outputs with errors and $0.93, and its trace shows 39 of those calls touched the vendor's docs site. We think a trace like that means the agent searched the docs for something it couldn't find quickly.
Fix the product, never the task prompt. A missing docs page, an unclear error message or an SDK that won't install is the finding. Then rerun the same tasks on the same agents and model versions, so the change you see is yours. For common fixes, see the API agent-readiness playbook and how to make your API work better with Claude Code, Codex and Cursor.
6. Run it on a schedule or in CI
Rerun the evals weekly, and on every pull request that changes your docs, SDKs, OpenAPI spec, CLI or MCP tool descriptions. Results drift when agents and models update and when your product changes. Between the May and October 2026 batches on the Claude Code API board, three tools gained 34, 29 and 27 points. The agents' models changed between those batches too, so part of each jump may come from the agent rather than the product.
Both agents run in GitHub Actions. The Claude Code GitHub Action accepts a prompt and a schedule trigger, and openai/codex-action runs Codex with a prompt while keeping the API key behind a proxy. Store the agent version and model with every result, or a model update will look like your own regression. The step is done when you have a dated results table per agent that updates without anyone starting it.
Common mistakes
- Testing from your laptop. Local config and leftover files can inflate results, as Anthropic saw when Claude read git history left by earlier trials. Use a fresh container per run.
- Trusting exit code 0. It describes the run, and the task can still have failed. Check your system for the result.
- Rewording the task until it passes. That tunes the eval to the agent. Keep tasks fixed and change the product.
- Running once. One pass can be luck. Run five times per agent and report the pass rate.
How to measure progress
Measure the pass rate per agent on a fixed set of tasks, weekly, and count it as progress when it rises and holds for two consecutive runs on the same agent and model versions.
| Metric | How to compute it | Better means |
|---|---|---|
| Pass rate | Passing runs ÷ all runs, per agent and task | Higher |
| All-runs pass | Tasks where all five runs passed | Higher |
| Tool calls | Median per passing run | Fewer |
| Time and cost | Median per passing run | Lower |
| Errors | Error outputs per run in the trace | Fewer |
Frequently asked questions
How do I test whether Claude Code can use my SDK?
Give Claude Code a clean project in your customers' language, a key in an environment variable and a real task, then run it with claude -p five times. Pass a run only when your API shows the result and the code imports your SDK package, because an agent can pass the task with raw HTTP calls and never touch the SDK you want to test.
How do I test whether Codex can use my API?
Run codex exec with --sandbox workspace-write and network access turned on, because Codex's default sandbox blocks the network and every call to your API would fail. Then check each run through your own API. Test Codex separately from Claude Code: in one of our payments runs in October 2026, the same API scored 85 with Claude Code and 66 with Codex.
How do I run MCP evals?
Connect your published MCP server to each agent in a fresh sandbox, give it a task the server's tools can complete, and check the outcome through your API. First confirm the server loaded: Claude Code skips an MCP config entry that fails validation, exits cleanly, and in a scripted run reports the skip only in its startup event.
How can a sandbox company run CLI evals?
Install your CLI in the agent's container, put the token in an environment variable, and ask for jobs a developer would do with it, such as starting a sandbox and running a script inside it. Check the result through your API, since the CLI's own success message is a claim like any other.
How do I do coding agent testing for my agent skill?
Run the same tasks with and without the skill installed, in fresh sandboxes, and compare pass rate, tool calls and time on identical checks. If nothing moves, read the traces to see whether the agent ever opened the skill.
Next step
Write three tasks this week, run the step 3 loop on Claude Code and Codex, then compare platforms for running it at scale in best agent testing tools for developer tools.