Skip to main content
POST
AI Simulation needs an active Pro or Business plan. On another plan, every simulation endpoint returns 403 POLICY_DENY.
Write improved instructions for the agent from the failures of a finished run. This makes one paid model request and saves nothing. Show the result as a preview, then save it with apply below. Only failures that new instructions can fix are used: failed checks (a phrase missing or said, a tool used or not used, a detail, the caller’s goal) and calls that did not do what the story expected. Speed and service problems are left out.

Request

Headers

string
required
Bearer token with your API key (scope agents)

Path

string
required
The run_id of a finished run from Start a simulation

Response

200 OK.
The suggestion is built from what the agent actually said in the failed calls, so a check the agent already met in other words does not produce a new rule. New rules go in an ADDITIONAL RULES section at the end of the instructions; a rule the instructions already have is not added again.
string
SHA-256 of before. Send it with apply, so a changed agent is never overwritten.
array
What changed, in plain words
array
The failures the new instructions answer
array
Failures new instructions cannot fix: a tool the stories expect that the agent lacks, or one its instructions rule out. Present only when there are any

Apply and undo

POST /agents/simulations/{runId}/fix/apply saves after to the agent. Body: { "base_hash": "<from the suggestion>", "script": "<after>" }. The answer has the hash of the saved text:
The new instructions pass the same checks as a fix from Call analysis: not empty, not the same text, within the length a call can use, and no new placeholder, link, e-mail address or phone number. POST /agents/simulations/{runId}/fix/undo puts the earlier text back. Body: { "base_hash": "<from apply>", "script": "<before>" }. Both need the agent:write permission.

Errors

Example