The agentunit command executes one or more evaluation scenarios and exports summaries. Review the Quickstart first for installation and template usage, then use this document as a detailed flag reference.
agentunit <suite> [options]<suite>– a Python module path (package.module) or a filesystem path to a.pyfile. The module must expose eithersuite(an iterable ofScenario) or a callablecreate_suite()that returns one.
| Flag | Description |
|---|---|
--metrics METRIC [METRIC ...] |
Optional subset of registered metrics. Default runs everything registered in agentunit.metrics. |
--otel-exporter {console,otlp} |
Choose the telemetry exporter. console (default) pretty prints spans; otlp streams to the active OTLP endpoint. |
--seed INT |
Seed used to initialize any random generators before iterating dataset cases. |
--json PATH |
Write evaluation output as structured JSON. |
--markdown PATH |
Write a human-readable Markdown summary. |
--junit PATH |
Write JUnit XML compatible with most CI dashboards. |
AgentUnit looks for suites in two ways:
- Python module import – run
agentunit my_project.evals.product_suite. Python must be able to import the module (package installed or available onPYTHONPATH). - Direct file execution – run
agentunit evals/product_suite.py. The file must have a.pyextension and exportsuiteorcreate_suite.
If both suite and create_suite exist, the CLI prefers suite. Use create_suite() to keep initialization logic fresh on every CLI invocation.
- JSON: includes aggregate metrics, per-scenario records, and per-case diagnostics. Ideal for dashboards or custom scripts.
- Markdown: readable summary for pull requests and changelogs.
- JUnit: standard CI integration. Failed cases surface as failed tests.
You can supply any combination of export flags during a single run. See Performance testing for strategies that pair exports with load analysis.
Metrics are discovered from the plugin registry (agentunit.metrics.registry). To list available metrics:
from agentunit.metrics.registry import list_metric_names
print(list_metric_names())Specify the subset you care about via --metrics faithfulness tool_success.
Set --otel-exporter otlp to forward spans to your collector. Configure the destination via the following environment variables before launching the CLI:
OTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_HEADERSOTEL_RESOURCE_ATTRIBUTES
If omitted, the SDK default (localhost gRPC) is used. Use console exporter when you want to debug spans locally.
--seed 42– seeds Python'srandommodule before iterating cases.- Use deterministic datasets where possible (sorting inputs, removing randomness from retrieval).
- Pair seeds with pinned model versions to reduce nondeterministic responses.
Run a suite with all metrics and a Markdown export:
agentunit my_project.evals.qa_suite --markdown reports/qa-suite.mdLimit metrics to correctness and hallucination:
agentunit my_project.evals.qa_suite --metrics answer_correctness hallucination_rateSend telemetry to OTLP collector and emit all export formats:
agentunit my_project.evals.qa_suite \
--otel-exporter otlp \
--json reports/qa.json \
--markdown reports/qa.md \
--junit reports/qa.xml0– CLI executed successfully (individual scenario failures still produce exit code 0; inspect reports for results).- Non-zero – CLI encountered a configuration or runtime error (invalid suite, import failure, unhandled adapter exception).
Use JUnit exports or JSON parsing to fail CI when cases regress.