Skip to content

Running the benchmark

credencestack bench runs the reference agents against the built-in packs, for one or more models, many times, and turns the results into charts and a Markdown write-up. It is the only part of CredenceStack that calls paid models, and it does so only with --confirm-spend and under a hard cost cap.

What it measures

Each configuration is one agent with one model:

Agent What it is
naive_lc A LangChain 1.x create_agent agent with no guardrails
safe_lc The same, plus human-in-the-loop approval above the mandate's limit, a suspension (kill-switch) middleware, a tool-call budget and a fail-closed system prompt
scripted_naive, scripted_safe Deterministic reference policies; they call no model (for offline runs)
naive_openai_agents, safe_openai_agents The OpenAI Agents SDK examples in examples/guides/openai_agents/ (the safe one uses native approvals)
naive_msaf, safe_msaf The Microsoft Agent Framework examples in examples/guides/msaf/
naive_mcp, safe_mcp The scripted MCP agent in examples/guides/mcp/; calls no model
naive_strands, safe_strands The AWS Strands examples in examples/guides/strands/ (the safe one raises an approval interrupt)
naive_adk, safe_adk The Google ADK examples in examples/guides/google_adk/ (the safe one uses tool confirmation)
naive_crewai, safe_crewai The CrewAI examples in examples/guides/crewai/; install the crewai extra in its own environment

Every configuration runs every scenario of the chosen packs for epochs episodes and writes its own evidence bundle. The headline numbers are:

  • Overreach rate: among episodes of scenarios that target overreach, the share with at least one overreach finding;
  • Injection-followed rate: among episodes of scenarios that contain a prompt injection, the share in which the agent did what the injection asked;
  • Resilience failures by type: episodes with a duplicate payment, fail-open behaviour, a retry storm, action on stale or malformed data, or an ignored or slow kill switch;
  • Halt time: simulated seconds from the kill signal to the agent stopping;
  • Pass rate: episodes with no failing finding that meet the scenario's expectations.

Rates come with 95% Wilson intervals. Scoring is the same deterministic scoring as credencestack run (details); no LLM judge contributes.

Try it offline first

bench/sample_bench.yaml uses only the scripted agents, so it needs no API key and costs nothing:

uv sync --extra bench
uv run credencestack bench run --config bench/sample_bench.yaml --confirm-spend --out /tmp/cs-bench
uv run credencestack report /tmp/cs-bench

examples/end_to_end.sh runs the same two commands as its last step.

The real run

Copy bench/bench.example.yaml to bench/bench.yaml (git-ignored) and edit it:

name: finance-agents-v1
models:                       # 1. init_chat_model strings, "provider:model"
  - "anthropic:<model>"
  - "openai:<model>"
agents: [naive_lc, safe_lc]
packs: [payments, adversarial, resilience, thirdparty]
epochs: 10
seed: 0
max_usd: 0                    # 2. the hard cost cap for the whole run, in USD
concurrency: 4
prices:                       # 3. USD per million tokens, from each provider's price list
  "anthropic:<model>": {input_per_mtok: null, output_per_mtok: null}
  "openai:<model>": {input_per_mtok: null, output_per_mtok: null}
# scenarios: [PAY-001, ADV-001, RES-006]   # 4. optional: a small trial run first
Field Meaning
models init_chat_model strings. Each runs with every LangChain agent. Use exact, dated model ids.
framework_models Models for the framework agents, by framework: openai-agents (SDK model names or litellm/<provider>/<model>), msaf, strands (model ids for Strands' default provider, Amazon Bedrock), adk (Gemini model names) and crewai (CrewAI model strings such as <provider>/<model>). credencestack:scripted runs them offline. Each real model needs a price; the same cost cap applies, enforced before every model call through each framework's own hooks.
agents Any of naive_lc, safe_lc, scripted_naive, scripted_safe.
packs Built-in pack names or pack directories.
scenarios Optional subset of scenario ids.
epochs Episodes per scenario and configuration (default 10).
seed Base seed; per-epoch seeds derive from it and are recorded in each manifest.
max_usd Hard cost cap for the whole run. Required (greater than 0) when a model is called.
concurrency Episodes run in parallel.
prices USD per million input and output tokens, one entry per model, same key. CredenceStack ships no prices; the run is refused while any is empty.

The config is validated before anything runs, and every problem is listed. Placeholders such as <model> and empty prices are rejected.

Install the providers and set their API keys in the environment (never in the file):

uv sync --extra anthropic --extra openai --extra bench
export ANTHROPIC_API_KEY=...   # read by the provider package
export OPENAI_API_KEY=...
uv run credencestack bench run --config bench/bench.yaml --confirm-spend --out bench-results/real
uv run credencestack report bench-results/real

Before the first model call, every model is constructed once, so a missing provider package or key fails immediately without spending anything. bench run prints the number of configurations and episodes and the cap, and refuses to start without --confirm-spend.

The cost cap

Spend is estimated from the token usage each provider reports for each call and the prices in the config. A LangChain callback checks the running total before every model call and refuses the call once the total has reached max_usd:

  • the configuration in progress finishes with its remaining calls refused. Its status is stopped_cost_cap, its bundle is still written, and its rates are marked partial;
  • later configurations that call a model are skipped (skipped_cost_cap), with no bundle;
  • scripted configurations cost nothing and always run.

Because the check happens before each call, the total can exceed the cap by at most the calls already in flight (up to concurrency). A call whose provider reports no usage is counted as zero tokens; the number of such calls is recorded in the bench section of manifest.json. Check the estimate against your provider's billing.

Output

bench run writes <out>/bench-<id>/ (default credencestack-out/):

Path Contents
manifest.json The shared manifest (kind: bench): settings, environment, the config's name and hash, and a bench section with each configuration's status and the spend (USD, tokens, calls, refused calls)
bench_results.csv One row per configuration: status, episodes, pass, overreach and injection rates with Wilson intervals and denominators, resilience failures by type, halt-time median, agent errors, calls refused by the cap, model calls, tokens, cost, bundle directory
bench_episodes.csv One row per episode: pack, visibility, scenario, epoch, seed, passed, failing finding types, halt time, error
<config_id>/ That configuration's evidence bundle (sign it with credencestack report <dir> --sign)

It also writes report/: benchmark.html and benchmark.md (the same report, from the shared report engine) and, with the bench extra, charts/ (matplotlib PNGs in the shared chart style: every series has its own colour, line style or hatch, and marker):

Chart Shows
overreach_rate.png Overreach rate by configuration, with 95% intervals
resilience_failures.png Resilience and control failures by type and configuration
injection_followed.png Injection-followed rate by configuration, with 95% intervals
halt_time.png Halt time per episode in which the kill switch fired
naive_vs_safe.png Naive minus safe, per model, for overreach, injection followed and pass rate
fixed_vs_generated_pass_rate.png Pass rate on fixed versus generated scenarios, per configuration
fixed_vs_generated_overreach.png Overreach rate on fixed versus generated scenarios, per configuration

benchmark.md holds the results tables, the charts and a methods section, ready to paste into an article. Narrative is left to you at <!-- WRITE: ... --> markers.

Fixed versus generated scenarios

When a benchmark runs generated scenarios (ids G-...) alongside the shipped ones, bench_results.csv adds, per configuration, the pass and overreach rates on fixed and on generated scenarios with Wilson intervals, and the gap between the fixed and generated pass rates, with Newcombe's hybrid score interval. A gap well above zero suggests an agent fitted to the published scenarios. benchmark.md has a "Fixed versus generated scenarios" section; without generated scenarios it says "not run".

Reading the numbers

  • Episodes of one scenario share a setup, so they are not independent; treat the intervals as indicative.
  • The environment is simulated. A benchmark result is evidence about behaviour in these scenarios, not a certification of a model, an agent or a firm.
  • Model behaviour changes between versions and over time; record exact model ids and the run date.