Correct a run
const url = 'https://example.com/v1/corrections';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"runId":"example","decisions":"right","shouldCall":[{"tool":"example","args":{}}],"mustNotCall":["example"],"answer":"right","shouldSay":"example","why":"example","items":[{"key":"example","pointer":"example","rank":1,"verdict":"right"}],"correctorGroupId":"example","participantId":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/corrections \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "runId": "example", "decisions": "right", "shouldCall": [ { "tool": "example", "args": {} } ], "mustNotCall": [ "example" ], "answer": "right", "shouldSay": "example", "why": "example", "items": [ { "key": "example", "pointer": "example", "rank": 1, "verdict": "right" } ], "correctorGroupId": "example", "participantId": "example" }'Records whether a finished run’s decisions and answer were right, and what was right instead, optionally under a corrector group that applies to the run’s project or agent (unclassified corrections count with weight 1). Each item’s pointer (a JSON Pointer) must resolve in the run’s output. It’s sorted at save: an end user’s correction stays open and unsorted; decisions: "wrong" goes to the agent’s owner (with-owner); a wrong answer goes to Improve (open); nothing wrong is fixed as recorded-right. The first correction of a run also stores a copy of the run’s input and output. madeBy is the authenticated caller, never the body. A second correction by the same caller for the same run and participantId supersedes the earlier one. Needs write on the run’s project.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the tenant is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5). A request whose key store can’t be read before it runs is answered 503 idempotency-store-unavailable with Retry-After: nothing ran, so retry with the same key (from 0.3.0).
Request Bodyrequired
Section titled “Request Bodyrequired”At least one of decisions, answer and items. decisions: "wrong" needs an entry in shouldCall or mustNotCall; answer: "wrong" needs shouldSay or why.
object
Only with decisions: "wrong": the calls the agent should have made.
object
Only when the inputs matter: the top-level argument fields to compare, by value. Left out, only the call is checked. At most 4000 characters in canonical JSON.
object
Only with decisions: "wrong": tools that shouldn’t have been called. A tool can’t be in both.
Only with answer: "wrong": what it should have said.
For an answer that is a ranked list: each item, and whether it was right. Each key once.
object
The caller’s stable id for the item, such as a matched case’s id, never the item’s own text.
Where the item is in the run’s output, as a JSON Pointer (RFC 6901), e.g. /matches/2.
The item’s position in the ranked list (0 = first).
Optional. When given it must exist and apply to the run.
An app’s opaque id for its end user, when correcting on their behalf.
Responses
Section titled “Responses”Correction recorded.
A person’s correction of one run: whether its decisions (the tool calls) and its answer were right, and what was right instead. It says at least one of decisions, answer and items.
object
What a corrected run ran: an agent at a version, or a flow at a version.
object
Whether the run’s decisions were right. Absent when it says nothing about them.
With decisions: "wrong": the calls the agent should have made.
object
The partial set of top-level argument fields to compare, by value. Fields left out are not compared; an empty object asks only that the tool was called. At most 4000 characters in canonical JSON.
object
With decisions: "wrong": the tools that should not have been called.
Whether the run’s answer was right. Absent when it says nothing about it.
With answer: "wrong": what it should have said.
For an answer that is a ranked list: each item, and whether it was right there.
object
The caller’s stable id for the item, such as a matched case’s id, never the item’s own text.
Where the item is in the run’s output, as a JSON Pointer (RFC 6901), e.g. /matches/2.
The item’s position in the ranked list (0 = first).
The corrector group the correction is recorded under. Absent when unclassified (counts with weight 1).
Present (true) when the corrector group was restricted (assertableBy) when the correction was recorded, so whoever recorded it was checked against it. A restriction added or lifted later doesn’t change it.
Who asserted a correction: the authenticated caller, never a typed name.
object
A user id, or for a service token its token or session id.
The app’s opaque id for its end user who corrected it, when an app corrected it on their behalf.
Where it is in being fixed. with-owner while the agent’s owner decides; fixed only when a pin or a deploy fixed it, or it said nothing was wrong; removed can’t come back.
Who works on it: Improve, a developer, or the agent’s owner. Absent while unsorted.
Present while it’s fixed, and beside reopenedIn after a test run reopened it.
object
The version that fixed it. Absent for recorded-right, which nothing had to fix.
pin: a pin fixed it. latest: a deploy or an add moved Latest in a project that follows it. recorded-right: it said nothing was wrong.
Who asserted a correction: the authenticated caller, never a typed name.
object
A user id, or for a service token its token or session id.
Present after a test run got a fixed correction wrong again: it’s open, or with-owner when it’s sorted to the owner, with the fixedIn it had beside it. A status set by hand clears both, and a re-sort alone keeps them. A test run that gets it right again makes it fixed with a new fixedIn.
object
The version that gets it wrong.
How the project came to run it. pin: a pin. went-back: a pin of a version earlier than the one it ran just before. unpin: an unpin. latest: a deploy or an add moved Latest in a project that follows it.
Who pinned, went back or unpinned. Absent when Latest moved.
object
A user id, or for a service token its token or session id.
object
Who asserted a correction: the authenticated caller, never a typed name.
object
A user id, or for a service token its token or session id.
When it last changed: createdAt until something changes it.
Set when the correction was removed or superseded.
The correction that replaced this one.
Example
{ "subject": { "kind": "agent" }, "decisions": "right", "answer": "right", "items": [ { "verdict": "right" } ], "expert": true, "madeBy": { "kind": "user" }, "status": "open", "sortedTo": "improve", "sorted": { "by": { "kind": "fix-job" } }, "link": { "kind": "improve-run" }, "fixedIn": { "how": "pin", "by": { "kind": "user" } }, "reopenedIn": { "how": "pin", "by": { "kind": "user" } }, "statusNote": { "by": { "kind": "user" } }}Malformed body, or item-not-found (an item’s pointer resolves to nothing in the output), or corrector-group-not-applicable.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}permission-denied: not allowed to correct this run. corrector-group-not-allowed: the corrector group is restricted (assertableBy) and the caller may not assert it.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}run-not-found.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}run-not-finished: the run has no output to correct yet.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}run-erased: an erasure cleared the run’s content (a person’s words were removed); there’s nothing to correct.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Server error (unmapped domain code or framework crash).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store couldn’t be read before the request ran (idempotency-store-unavailable), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}See also
GET /v1/corrections: List corrections- Kindgi 0.4.0
- Error code
corrector-group-not-allowed - Error code
corrector-group-not-applicable - Error code
idempotency-store-unavailable - Error code
item-not-found - Error code
permission-denied - Error code
request-too-large - Error code
run-erased - Error code
run-not-finished - Error code
run-not-found - Every error code