AI Agents
Cancel Task
Preview. This endpoint is in preview and may change without notice.
POST
/api/preview/agents/{orgName}/tasks/{taskID}/cancelCancels an agent task. When force is true, immediately terminates the runtime session and resets the task to idle. This is the escalation path when a graceful cancel (via the user_cancel event in RespondToTask) is insufficient or the task is stuck. Unlike graceful cancel, force-cancel does not attempt to notify the agent runtime — it kills the session directly and resets the task state. Currently only force cancellation is supported; the force field must be set to true. Returns 409 if the session was stopped but the task status could not be reset to idle.
Request Parameters
orgNamestring path requiredThe organization nametaskIDstring path requiredThe agent task identifier
Request Body
Schema: CancelAgentTaskRequest
forceboolean requiredIf true, immediately terminate the runtime session and reset the task to idle without attempting a graceful cancel. Required to be true in the current implementation.
Responses
204
Task cancelled successfully
Errors:
400 force must be true (graceful cancel not yet supported via this endpoint)
404 task
409 session stopped but task status could not be reset to idle
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.