Skip to main content

Overview

Agent Contracts provides powerful verification capabilities to evaluate if your agent’s behavior matches the defined contracts. Verification Workflow

Verify a run

Prerequisites:
  1. Installed and set up agent contracts for offline verification installation.
  2. Created an offline specification for your agent contract specifications.
1

Run your application through all predefined scenarios

app.py
Your traces will be available in the Jaeger UI (http://localhost:16686).
2

Retrieve the run

A run is a collection of traces. You can retrieve a run using the CLI. In the agent contract environment you can use the cli command to list the traces or runs.
$poetry run cli ls run β€”timespan 1d
Listing runs from 2025-03-05 21:54:40 to 2025-03-07 21:54:40…
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Run ID   ┃ Project Name        ┃ Specifications ID ┃ Start Time          ┃ End Time            ┃
┑━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
β”‚ cd26ad7e β”‚ langgraph-fin-agent β”‚ u8spz6vw          β”‚ 2025-03-06 12:45:32 β”‚ 2025-03-06 12:45:32 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
3

Verify the run against the specification

$poetry run cli verify run cd26ad7e fin-agent-022225.json β€”timespan 1d
Verifying run cd26ad7e with specifications from .local/fin-agent-022225.json…
Output will be saved to output/verify_cd26ad7e.json
Contract Right Tickers: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:05 < 00:00,  1.93s/it]
Contract Right Tickers: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:07 < 00:00,  1.91s/it]
Contract Right Tickers: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:08 < 00:00,  2.06s/it]
───────────────────────────────────────── Trace 150a4110d9de4134e577f7f4c0c56bd4 ──────────────────────────────────────────
Right Tickers (UNSATISFIED)
┏━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Type ┃ Qualifier ┃ Requirement                                             ┃ Satisfied ┃
┑━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
β”‚ PRE  β”‚ MUST      β”‚ Question about the debt-to-equity ratio                 β”‚ Yes       β”‚
β”‚ PATH β”‚ MUST      β”‚ Retrieve the financials of at least 3 car manufacturers β”‚ No        β”‚
β”‚ POST β”‚ MUST      β”‚ Output a table                                          β”‚ No        β”‚
β”‚ POST β”‚ SHOULD    β”‚ Include at least Tesla, Ford, and General Motors        β”‚ No        β”‚
β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
───────────────────────────────────────── Trace a8ac6ae61209833f7abd723bdd175770 ──────────────────────────────────────────
Right Tickers (SATISFIED)
┏━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓ ┃ Type ┃ Qualifier ┃ Requirement ┃ Satisfied ┃ ┑━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩ β”‚ PRE β”‚ MUST β”‚ Comparison between Nike and Adidas β”‚ Yes β”‚ β”‚ PATH β”‚ MUST β”‚ Retrieve Nike financials with the ticker NKE β”‚ Yes β”‚ β”‚ PATH β”‚ MUST β”‚ Retrieve Adidas financials with the ticker ADDYY β”‚ Yes β”‚ β”‚ POST β”‚ SHOULD β”‚ A numeric value for operating margins expressed in percentage β”‚ Yes β”‚ β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ───────────────────────────────────────── Trace a7bb5cfe26811835333c087e151f5eda ────────────────────────────────────────── Right Tickers (SATISFIED)
┏━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓ ┃ Type ┃ Qualifier ┃ Requirement ┃ Satisfied ┃ ┑━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩ β”‚ PRE β”‚ MUST β”‚ Question about Tesla’s net income β”‚ Yes β”‚ β”‚ PATH β”‚ MUST β”‚ Retrieve Tesla’s net income with the ticker TSLA β”‚ Yes β”‚ β”‚ POST β”‚ SHOULD β”‚ A numeric value for net income expressed in dollars β”‚ Yes β”‚ β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
You can get runs and traces by specifying either the date range or the timespan.
  • Explicit date range: --start YYYY-MM-DD --end YYYY-MM-DD
  • Relative timespan: --timespan 24h or --timespan 7d
Date range or timespan is necessary for ls and verify commands to query the jaeger database for the traces and runs.

Verify a single trace

1

Run your application on a single scenario

2

List available traces

$poetry run cli ls trace β€”timespan 1d
Listing traces from 2025-03-06 01:55:50 to 2025-03-07 01:55:50…
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Trace ID                         ┃ Project Name        ┃ Run ID   ┃ Specifications ID ┃ Scenario ID      ┃ Start Time          ┃ End Time            ┃
┑━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
β”‚ 150a4110d9de4134e577f7f4c0c56bd4 β”‚ langgraph-fin-agent β”‚ cd26ad7e β”‚ u8spz6vw          β”‚ de_ratio         β”‚ 2025-03-06 12:45:32 β”‚ 2025-03-06 12:45:32 β”‚
β”‚ a8ac6ae61209833f7abd723bdd175770 β”‚ langgraph-fin-agent β”‚ cd26ad7e β”‚ u8spz6vw          β”‚ nike_vs_adidas   β”‚ 2025-03-06 12:45:32 β”‚ 2025-03-06 12:45:32 β”‚
β”‚ a7bb5cfe26811835333c087e151f5eda β”‚ langgraph-fin-agent β”‚ cd26ad7e β”‚ u8spz6vw          β”‚ tesla_income     β”‚ 2025-03-06 12:45:32 β”‚ 2025-03-06 12:45:32 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
3

Verify the trace

If you’d like to download an individual trace, you can use the get command:

Interpret the results

In addition to the verification result summary, the verification results are saved in the .output directory as verify_RUN_ID.json or verify_TRACE_ID.json. You can specify a different output directory using the --output-dir flag. Here’s an example of the verification results. You can explore the detailed explanation for the requirement checking results.
.output/verify_150a4110d9de4134e577f7f4c0c56bd4.json
The results are saved as verify_RUN_ID.json in the specified output directory. TODO: add example results

Next Steps