Overview
Agent Contracts provides powerful verification capabilities to evaluate if your agentβs behavior matches the defined contracts.Verify a run
Prerequisites:- Installed and set up agent contracts for offline verification installation.
- Created an offline specification for your agent contract specifications.
1
Run your application through all predefined scenarios
app.py
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 β
ββββββββ΄ββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββ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
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
verify_RUN_ID.json in the specified output directory.
TODO: add example results
Next Steps
- Explore runtime certification capabilities
- View example contracts for common use cases