from agentx import AgentX
from agentx.tracing import CIRun, CIRunResult
client = AgentX.from_env()
tracer = client.tracer
# 1. Create the run, receive test cases
run: CIRun = tracer.create_ci_run(
dataset_id="6876ddd222bbb333ccc444ee",
agent_name="my-agent",
git_context={"branch": "main", "commitSha": "abc1234"},
)
# 2. Run agent against each test case
for tc in run.test_cases:
output = my_agent(tc.query or "") # tc.query is None if exposeTestInputs is off
score = tracer.submit_result(
run.run_id,
tc.index,
output,
latency_ms=350,
)
if score.gate_fired:
print("failFast triggered, run already finalized as FAIL")
break
# 3. Finalize and get the gate decision
result: CIRunResult = tracer.finalize_ci_run(run.run_id)
print(f"Gate: {result.gate} ({result.passed_questions}/{result.total_questions} passed)")