Preview. Operations are available to organisations in the Wordsmith MCP and files pilot. See the preview overview. This page describes how they work as built.
The operation object
statusmoves fromqueuedtorunning, then to one ofsucceeded,failedorcancelled.resourcenames the object the operation works on. Read it for the full picture, for exampleGET /reviews/{id}.resource.idisnulluntil the work has created its resource, such as the session a draft runs in.progressis set while the work runs, and a finished operation keeps its lastprogress.resultis set on success. For a review it holds finding counts and the redlinefile_id. For a document action it holds the newfile_ids. Get Operation lists the result of every type. Numbers inresultare JSON numbers.erroris set on failure, with acode, amessageandretryable.
Three ways to wait
- Long-poll (recommended for scripts)
- Callback (recommended for servers)
- Poll
Call Get Operation with A three-minute review costs about nine requests this way.
wait=20. The request holds for up to 20 seconds and returns the moment the operation finishes.Getting the result in one call
Every endpoint that starts an operation also takeswait, from 0 to 20 seconds. Quick work, such as comparing two short files or filling a blueprint from your own values, then comes back finished in the same response:
wait runs out, you get the operation as usual and carry on from there. Code written for the slow path always works.
Retrying safely with Idempotency-Key
If your request times out, you cannot tell whether the review started. Send an Idempotency-Key header on every request that starts an operation:
- The first request with a key starts the operation.
- A repeat with the same key and body within 30 days returns the same operation with
200. Nothing runs twice, and you are not charged twice. - If the key’s operation failed before its work started, with
error.coderequest_failedandretryabletrue, a repeat starts the work in a new operation with a new id, and the key then returns that one. The failed operation keeps its id, its outcome and its callback. - A repeat with the same key and a different body returns
409 idempotency_key_reused.
When an operation fails
error.retryable says whether the same request can succeed on a new attempt. A retryable request_failed operation never started, so a repeat with the same Idempotency-Key starts the work in a new operation. For any other failure, start the work again with a new key.
Cancelling
Cancel Operation asks the worker to stop. Cancellation is best-effort: the operation may readrunning for a few seconds before it turns cancelled. Work already done, such as cells computed in a report, is kept and charged.
Limits
Each endpoint that starts an operation keeps its own limits, such as the request limit and credits. A long-poll counts once against the request limit, however long it holds.
Which endpoints return an operation
The proposal also planned a research report (
research_report). It was not built: for a researched memo, ask an agent with Create Question.
Questions keep their existing status endpoint, and each one also gets an operation, so the same waiting code works for them.