Skip to content

Undo an agent turn

POST
/api/v1/ai/turns/{id}/undo
curl --request POST \
--url https://example.com/api/v1/ai/turns/example/undo \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "keep_conflicts": true }'

Undo file changes from an agent turn. Set keep_conflicts to leave changed items as they are and undo other safe changes. The response lists any items it kept. Ask turns cannot be undone. Route: /api/v1/ai/turns/{id}/undo. Inputs: id. Do not automatically replay this operation after an uncertain result.

id
required
string
Media typeapplication/json
One of:
object
keep_conflicts

Keep the items that changed after the turn and undo every other change. The report then lists the kept items as conflicts.

boolean
Examplegenerated
{
"keep_conflicts": true
}

The turn was undone; with keep_conflicts, conflicts lists the kept items

Media typeapplication/json
object
conflicts
required
Array<object>
object
path
required
string
reason
required
string
undone
required
boolean
Examplegenerated
{
"conflicts": [
{
"path": "example",
"reason": "example"
}
],
"undone": true
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json
object
conflicts
required
Array<object>
object
path
required
string
reason
required
string
undone
required
boolean
Examplegenerated
{
"conflicts": [
{
"path": "example",
"reason": "example"
}
],
"undone": true
}