Skip to Content
Judgment Labs
Tests

Tests

Run offline tests on your agent with a test suite, and check every run with your judges.

Tests run your agent offline, before a change ships. A test suite is a set of cases. Each case is an input for your agent, the judges to score it with, and the answer you expect from each judge. You send the input to your agent, and Judgment scores the trace it produces.

Set up Judgment tests with your coding agent

Paste it into your agent from your repo's root.

Use a test suite to:

  • Gate pull requests in CI. Run every case and fail the build when a case fails.
  • Compare models, prompts, or tools on the same cases.
  • Test a deployed agent in staging or a preview deployment.
  • Score a past run against changed cases without running the agent again.

In the app, open Tests in the sidebar to create test suites, edit their cases, publish versions, and read run results. You can also manage test suites with the SDK, the HTTP API, or a coding agent connected over MCP. Runs are started from your repo, because your code runs the agent: Run suite in the app shows the SDK code for a suite, and it does not start a run.

Run a suite from your repo

For a Python agent, one command runs your suites. You add a .judgment/ folder to the repo once: judgment.json names your project and the suites to run, and run.py holds a run(case, environment) function that sends one case to your agent.

judgeval test init --project support-agent --suite Baseline   # once: creates .judgment/
judgeval test run                                             # plays every case and waits for the scores

judgeval test run exits with 1 when a case fails, so the same command is your CI check. See Set up tests in your repo. This needs judgeval 1.11.0 or later.

How offline tests work

Under the command, running a test suite takes two steps. You can do them yourself from any language or tracer:

  1. Start a run with the SDK or the API. You get back a run_id, and for each case its case_id and the input to send to your agent.

  2. Run your agent once per case, and put two attributes on that case's root span:

    AttributeValue
    judgment.test.run_idThe run ID.
    judgment.test.case_idThe case ID.

Judgment scores each case as soon as its trace arrives. You can set the two attributes with any tracer, including plain OpenTelemetry that exports to Judgment:

with otel_tracer.start_as_current_span("support-agent") as span:  # your root span
    span.set_attribute("judgment.test.run_id", run_id)
    span.set_attribute("judgment.test.case_id", case_id)
    support_agent(case_input)

SDK helpers

The judgeval SDK provides optional helpers that reduce this setup:

  • Tracer.test_case(run_id, case_id) wraps the agent call and tags the root span for you.
  • headers: each started case includes a ready-made baggage header for an agent you call over HTTP.
  • client.test_suites and client.test_runs in the SDK cover creating test suites, editing cases, starting runs, and reading results.
  • client.test_runs.run(test_suite_id, run_case) starts a run, plays every case through your function and waits for the scores. judgeval test run is this call with your .judgment/run.py.

See Connect your agent for all supported ways to tag a trace.

How it fits together

PartWhat it is
Test suiteA named set of cases, published as numbered versions. Runs use a published version.
CaseThe input your agent gets, plus expected: which judges to run on its trace and the result each should return.
RunOne pass over the test suite's cases. Each case produces exactly one trace.
Test environmentOptional. The seed data a case starts from and the mocked tool results it gets, so your agent meets the same situation on every run. In early access; see Run cases in a test environment.
Baseline suiteThe suite every change must keep passing. List it under "suites" in .judgment/judgment.json, so judgeval test run runs it by default.

A case passes when every judge listed in its expected returns the expected result. A judge error counts as a failed check.

Judge evaluations in a test run use Judgment Units (JU), like any other judge evaluation. See Billing and plans.

Move from test configs

Test configs and dataset test runs stop working for every organization on November 12, 2026. Your datasets stay as they are.

  • Datasets of agent inputs: add the rows as cases in a test suite, then start a new run on that suite each time you test. See Create and edit a test suite.
  • Re-scoring stored traces, such as judge calibration or golden sets: add cases from those traces, so each case has its trace in metadata.trace_id, and start the run with "stored_traces": true. See Score stored traces.
  • Code judges that read dataset columns: put those values in each case's metadata; code judges read the same keys, except name and the reserved keys that identify a trace, span, session or conversation. See Create and edit a test suite.

Next steps

On this page