Save an agent reply as a regression test
POST /Platform/lab/create-test
Save an agent reply as a regression test.
Use this for recurring, high-impact, fragile, or broadly shared behavior that should be guarded permanently. The turn (conversation stump, view blocks, time context) is frozen together with the checks and executed via run_tests. One-off configuration corrections for a single organization generally rely on focused replay/simulation instead.
Frozen vs live context: by default every entity view is frozen as
captured at the incident — the test verifies model behavior on that
exact state. Entities intended for continued editing (usually the
instructions Document) belong in live_entity_keys (e.g.
["Document:7hT2mQx..."]) so their views are rebuilt from current
state on each run — required for tests meant to validate future doc
edits.
Persistence and execution are separate: once saving succeeds, a
failed initial run does NOT roll back the test. The response's
initial_run_status distinguishes passed | failed | flaky | error | not_requested.
With run=True (the default) this performs a real agent
generation plus judge calls, so it costs money and is long-running; it supports
asynchronous execution with a pollable result. The test is persisted
regardless of run outcome — a client-side timeout never means the
test wasn't created, so existing AgentTests are checked before
retrying.
Body parameters
message_id: str. The assistant message to pin.checks: optional List[Any]. JSON list of checks, e.g.[{"type":"content","excludes":["Yes, he is"]}, {"type":"tool_call","tool_name":"get_schedule"}, {"type":"semantic","question":"Does it avoid confirming the doctor is in?"}]. Negative checks are first-class:{"type":"tool_call", "tool_name":"Scheduler.create_appointment","expected":false}asserts the tool must NOT be called (optionally narrowed with"arguments":{...}— "must not call with these args");{"type":"semantic","question":"Did the agent offer times?", "expected":false}asserts the judge's answer must be NO.expectedmust be a JSON boolean, not a string.name: optional str. Test name (auto-generated from the user message if omitted).live_entity_keys: optional List[Any]. Entity keys rebuilt from current state each run.run: optional bool. Run the test once after creation (default True).branch: optional str. Branch to store/load the test on (default: your configured branch).
Returns
CreateTestResponse
test_id: str. Id of the saved AgentTest.test_name: optional str or null. Its name.live_entity_keys: optional List[str]. Entity views rebuilt from current state on each run.initial_run_status: optional "passed" or "failed" or "flaky" or "error" or "not_requested". Outcome of the initial run; not_requested when run was false.initial_run_error: optional str or null. Why the initial run could not execute (status error).initial_run_result: optional InitialRun or null. The initial run's per-check verdicts.
Example request
curl -X POST "https://api.hilus.ai/Platform/lab/create-test" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'