Skip to main content

Agent Testing API

Test cases and test runs that check an agent against expected behavior.

๐Ÿ“„๏ธImport evals from bundle onto existing agent

Imports the evals from an exported agent bundle onto an existing agent, leaving the agent itself untouched. Accepts the same file as `importAgents` โ€” `application/json` or `multipart/form-data` with a `file` field โ€” and reads its `agent.evals` plus the `agent.evalMockBaseline` those evals rely on. Evals are matched by name, so re-importing the same file updates the test cases rather than duplicating them. Nothing is executed: use `POST /api/v1/agents/{agentId}/test-cases/{testCaseId}/run/` to run one. Fails with 422 when an imported eval references an evaluation criterion the target agent does not have.

๐Ÿ“„๏ธRun test case

Queues the evaluation and returns immediately with a stable `runId`. The queued run is visible immediately; the worker atomically claims it before evaluation. The evaluation replays the eval spec steps against the agent and records per-step results. Poll `GET /api/v1/agents/{agentId}/test-runs/{runId}/` to track progress and use `POST /api/v1/agents/{agentId}/test-runs/{runId}/stop/` to cancel. The test case must be enabled and associated with an application. Accepts an optional JSON body `{ repeats?, minPassRate?, target? }` to override the eval spec's own values for this run only and/or evaluate a specific branch instead of the current main draft.

๐Ÿ“„๏ธReplace baseline node mocks

Baseline node mocks are the fallback underneath every eval of this agent. When an eval runs, its own `nodeMocks` win per node id and the baseline answers for the rest. An agent without a baseline behaves exactly as it did before baselines existed: a node with no mock performs a real webhook call. This replaces the whole set rather than patching it. Every node id must exist somewhere in the agent tree, including sub-agent workflows; unknown ids are rejected.

๐Ÿ“„๏ธGet test run

Returns the run with the parent test case id and name and an `overallScore` averaged from the smart assertion scores. `responseShape=summary` replaces the heavy `stepResults` with one-line step verdicts โ€” the right shape for polling; the default `full` response embeds the complete `stepResults`. While `status` is `RUNNING`, `passed` and `finishedAt` are null, so poll this endpoint until the run finishes. The `applicationId` query parameter is optional: when omitted, it is derived from the run itself.

๐Ÿ“„๏ธStop queued or running test run

Runs with status `QUEUED` or `RUNNING` can be stopped; a queued run is cancelled before the worker ever claims it. Stopping aborts the agent executions of the run thread, then marks the run as `ERROR` with the reason `Cancelled by user`. The terminal write is a compare-and-set: if the run finishes first, the response is `409` and the completed result stands. The `applicationId` query parameter is optional: when omitted, it is derived from the run itself.

๐Ÿ“„๏ธGet how much of agentโ€™s workflow its eval suite exercises

Returns coverage across three layers โ€” workflow nodes (also broken down by node type), declared transitions, and decision criteria โ€” as covered/total plus the ids never reached. Advisory evals count, because they execute for real. Criteria on decision nodes whose transitions never route on a named criterion score cannot be attributed to a fired transition and are reported separately, excluded from both sides of the ratio.