Follow an action's work to its end with Operations
Use this page when an action answers with an Operation instead of a result. An Operation is the record of one action that Harnesty carries through to its end.
An action that declares itself durable answers at once with the Operation's id in operationId, and the work continues after the answer. With that id you read the state, follow the work to its end, or cancel it.
Reading, listing and cancelling an Operation cost no Credits, and watching one costs nothing either. The cost of the work belongs to the action, as that action declares it. An Operation is not a charge of its own.
What an Operation records
Each Operation that operation.get and operation.list return carries:
- the action it records;
- the Principal that submitted it (the person, Agent, AI tool or Machine that called the action);
- the Mandate that permitted it, the signed record that this Principal may use the action;
- its
state, and when each change happened; - its
cost.
The Workspace REST and MCP reference lists every field. The next section explains how to read cost.
Read an Operation
- Call the durable action, and keep the
operationIdfrom its answer. - Call
operation.getwith that id inoperation. - Read
state. Until the work ends, it tells you where the work is. When the work ends, it tells you how it ended, andresultcarries the action's output where the action returned one. - Read
cost. Once the work settles, it is the settled amount. A free action reads 0, and so does work that ended without success and holds no charge. For any other work,costis null until the charge is known.
You can read an Operation when your Mandates let you use the action it records. An Operation in another Workspace and one that your Mandates do not reach give the same refusal, so a refusal never tells you which Operations exist.
List your Operations
operation.list returns your own Operations, newest first, one page at a time. To read the next page, pass the next value of the current page as after.
- Set
scopetoworkspaceto list every Operation in the Workspace. Only an owner of the Workspace can do this, and anyone else is refused. - Set
heldto true to list only the held Operations: work that stopped after its retries ran out. The order stays the same, so you find each held Operation however far down the full list it sits.
Watch an Operation to its end
operation.watch opens one stream for one Operation. Over HTTP the stream is Server-Sent Events, and each event names its kind. The work ends at the terminal event: its state says how the work ended, and the stream closes. A small result arrives inside that event. A large one arrives as a reference that names the Operation and the digest of the result, and you read the result itself with operation.get.
To resume a dropped stream, reconnect with the standard Last-Event-ID header. Set it to the id of the last event you received that carried one. A browser EventSource sends that header for you. The stream continues after that event.
If the Operation has already ended, the stream sends its history and the terminal event, then closes. The watch reads the workspace audit log itself, never a copy. When an entry has aged out of that log, the replay starts at the oldest entry the log still keeps.
We check your access again while you watch, at a fixed interval. If your Principal is barred, the stream closes at the next check with a refusal. If your Mandate for the watch or for the Operation's action is revoked, the stream also closes with a refusal. A watch you may not open refuses as operation.get does.
Cancel an Operation
Call operation.cancel with the operation id. What happens depends on where the work is:
- Work that has not started ends at once as
canceledand is charged nothing. - Work that stopped after its retries ran out ends at once too.
- On other running work, your cancel records a request to stop, and the work may still finish.
Read outcome in the answer: ended means your cancel ended the work, stopping means the running work now carries your request to stop, and already-stopping means an earlier request to stop is already recorded.
Work that already ended keeps its state, and outcome reads finished. The cancel does not fail: operation in the answer holds the state the Operation has now, so you always learn where the work stands.
You can cancel an Operation when your Mandates let you make changes with the action it records. Read access to that action is not enough, because a cancel changes the work. Without it, the cancel refuses and changes nothing.
Sources
- Workspace REST and MCP reference
- HTML Standard: Server-sent eventsread November 25, 2026