Watch, Wait For and Cancel a Run
Starting an image, a Recipe, a video or a Work execution gives you a handle, not a result. Checking on it, waiting for it and stopping it start no new paid work. This is still where agents get it wrong: they start a second generation to “check”, read a timeout as a failure, or report a handle that is gone by tomorrow.
Cancel is not a refund. Cancel removes work that has not yet reached the provider. A request already sent to the provider may still finish and incur usage. For video, Gavana marks the job canceled and stores the message “Canceled in Gavana. The upstream provider may still finish and charge for the run.” Nothing in the cancel path reverses a charge, so this page cannot promise a refund. Cancel only when the user asks you to.
Scopes. Every operation here needs job:manage (“Check and resume the generation jobs this connection starts”). It depends on no other scope. get_canvas_workflow_run and work: snapshots also need canvas:read. Reading or cancelling one image or Action run also needs owner or editor access to its canvas. A read-only hosted connection cannot use any of these tools. Of the tools on this page, a local server started read-only offers only run_list and run_snapshot.
Which handle you have
| You started | Handle | Local MCP and CLI | Hosted MCP |
|---|---|---|---|
| Image generate, edit or variations, or an Image Action | run:<uuid>. The same record also answers to job:<uuid> | run_* / gavana run, or job_* / gavana job | get_image_run |
| A Recipe or canvas workflow | run:recipe-… | run_* / gavana run | get_canvas_workflow_run |
| A video | job:<uuid> only | job_* / gavana job | get_video_job |
| A Work execution | work:<id> | run_snapshot, work_get / gavana work get | run_snapshot, work_get |
Use the handle family you were given. The run commands reject a job: handle with “Expected run:<id>.”, and the job commands reject a run: handle the same way. A video job is not a Run, so run get cannot find it. Hosted get_image_run also accepts the generationRunId an image node carries, and get_canvas_workflow_run accepts a node’s recipeRunId.
Reading is not always read-only
| Tool | What calling it does |
|---|---|
run_snapshot | Read-only. It never submits, resumes, repairs or cancels anything, and its observation is always { "readOnly": true, "reconciliationPerformed": false }. Its view can lag the provider |
list_image_runs / run_list | Read-only |
get_image_run / run_get / gavana run get | Reconciles. It may finalize or repair canvas outputs, sync node status, clear cancellation markers and acknowledge completed jobs. For a Recipe it can also submit remaining steps the run already authorized |
get_video_job / job_get / gavana job get | For a video, polls the provider and stores the latest status. For an image or Action job: handle, reconciles the same way run_get does |
get_canvas_workflow_run | Reconciles or advances a workflow run, including its remaining already-authorized steps |
None of these starts work the user did not already approve. Only run_snapshot is pure observation.
Call sequence
[approved paid start] → handle
→ run_snapshot (poll) or run wait / job wait (bounded)
→ terminal status
→ report node: / asset: handles, or the video file
lost the handle? list_image_runs / run_list → run: handle
user says "stop it" run cancel / job cancel → read again until terminalSteps
Recover the handle if you no longer have it
Hosted MCP: list_image_runs. Local MCP: run_list. Both take the same input:
{ "status": "all", "canvasId": "canvas:OWNER_UID:CANVAS_ID", "limit": 20 }status defaults to active (queued or running only). limit is 1–50, default 20.
CLI: there is no run list command. Call the endpoint through gavana api:
gavana api GET /runs --field status=all --field limit=20 --jq '.runs[].run' -rThe result is runs, newest first, each with run, id, status, canvasId, canvasTitle and createdAt, plus activeCount and activeLimit.
Check. The list covers image and Action runs only. Recipe runs, video jobs and Work never appear in it, so keep those handles from the reply that started them. If activeCount has reached activeLimit, new image work is refused until a run finishes. Find the existing run before you consider starting anything again.
Read the state without side effects
Hosted and local MCP: run_snapshot with a run:, job: or work: handle:
{ "runId": "run:RUN_ID" }Hosted, run_snapshot is not in the default listing. It answers to its exact name, and the creative and advanced profiles list it.
CLI: there is no snapshot command, and gavana api refuses : in a path. Use MCP, or call GET /runs/{runId}/snapshot directly.
The response keeps the run’s own fields and adds snapshot: version, run, type (image, recipe, video, work or action), state, outputs, warnings, permittedNextActions and observation.
Check. While the run is active, permittedNextActions names only run_snapshot again. A delivery_blocked warning means the stored state does not prove the outputs are on the canvas, and canvas_changed means the canvas moved on after Work last synchronized.
Wait with a bounded timeout, or poll
CLI:
gavana run wait run:RUN_ID --timeout 600 --progress
gavana job wait job:JOB_ID --timeout 1800 --interval 5 --output markdownBoth default to a 900-second timeout and a 1.5-second interval, in seconds. --progress writes each status change to stderr as JSON. For a run it looks like {"ok":true,"progress":{"run":"run:…","status":"running"}}.
Local MCP: run_wait (runId) or job_wait (jobId), each with timeoutSeconds from 1 to 3,600, default 900. Progress notifications go out only when the client asked for them, and they carry a status word and nothing else.
Hosted MCP: there is no wait tool. generate_video, run_canvas_workflow, and generate_image_in_canvas with wait: true block for at most waitSeconds (1–50, default 45) and then hand back a resumable handle. Poll with run_snapshot, or with the tool a returned nextAction names, and leave a pause between calls. Hosted tool calls can be rate-limited.
Check. A timeout means you stopped waiting. The run did not fail. The message says so: “Waiting for run:… timed out. This wait did not cancel the work. Last observed status: running. Resume with run wait run:…”. The CLI exits 8, and the error carries status, lastObservedStatus, completionKnown and resumeCommand. Wait again or poll. Never start the work again.
Read the terminal state
| Kind | Still active | Terminal |
|---|---|---|
| Image or Action run | preparing, queued, running, finalizing, canceling | succeeded, failed, canceled, expired |
| Recipe Run | queued, running | succeeded, failed, canceled |
| Video job | queued, running | succeeded, failed, canceled |
| Work | Work’s own planning states, reported as snapshot.state |
| Terminal status | What it means | What to read |
|---|---|---|
succeeded | The provider finished and Gavana stored the result | Image and Action: images[] with nodeId and assetId. Recipe: outputs[] with nodeHandle and assetId. Video: video.downloadUrl |
failed | The provider or Gavana could not finish | failure.code, failure.message, failure.retryable |
canceled | Stopped in Gavana | Image and Action: cancelReason (user_requested, stale_preparing or setup_failed). Recipe: failure.code recipe_run_canceled. Video: failure.code canceled |
expired | Image and Action only. The temporary record lapsed before Gavana could verify a durable output | failure.code result_expired |
Check. On succeeded, read doneClaimAllowed (or completionReview.doneClaimAllowed) before you tell the user the work is done. run wait and job wait exit 9 on failed, canceled or expired, and still print the full terminal record to stdout.
Never retry a failed paid run automatically. failure.retryable: true is information for the user, not permission. Report the code and message and ask. If they say yes, that is a new intent: a new idempotency key and a new approval.
Cancel, only when the user asks
CLI:
gavana run cancel run:RUN_ID --yes
gavana job cancel job:JOB_ID --yesWithout --yes the CLI refuses, exits 2, and sends nothing.
Local MCP: run_cancel ({ "runId": "run:RUN_ID" }) or job_cancel ({ "jobId": "job:JOB_ID" }). Both are annotated destructive, and Hermes leaves them off by default.
Hosted MCP: the hosted server has no cancel tool. Say so plainly rather than looking for a workaround. Cancelling needs the local MCP server, the CLI, or the API, each with job:manage.
What cancel does depends on how far the work has gone:
| Kind | While queued or running | Already finished |
|---|---|---|
| Image or Action | Work still queued is removed and becomes canceled with cancelReason: "user_requested". Work the provider already has comes back canceling (HTTP 202). It may still finish, incur usage and end succeeded | Returns the finished result unchanged |
| Recipe | Remaining steps stop. A running image step is canceled as above, and the run reports currentStep: "Canceling" until that step settles. Outputs that already succeeded are kept, the rest become canceled, and the run ends canceled | If every output already succeeded, the run stays succeeded |
| Video | Marked canceled in Gavana at once. Gavana has no upstream cancel, so the provider may still finish and charge for the run | Returns the final state unchanged |
Work has no cancel on any surface.
Check. canceling is not terminal. Read the run again until it settles, and report what it settled on, including when that turns out to be succeeded.
Report the durable handles
run: and job: handles are observation records, and they expire:
| Record | Kept for |
|---|---|
Image or Action, succeeded | 24 hours before the first successful server finalization, and 15 minutes after it. An authenticated Run read or the worker’s own finalization counts |
Image or Action, failed or canceled | 24 hours |
Image or Action, expired tombstone | 7 days |
| Recipe Run | Currently kept, with no temporary window |
| Video job | 30 days |
Report the node: and asset: handles from images[] or outputs[]. They stay valid after the run record is gone. For video, report the downloaded file (gavana video download job:JOB_ID --file ./result.mp4) or the protected link hosted returned. A video is not a canvas node.
Check. The first read that finalizes a successful image starts its 15-minute window, so copy the durable handles out of that read.
When it fails
| Symptom | Cause | What to do |
|---|---|---|
403 forbidden “This agent token is missing required permissions: job:manage.” (CLI exit 3) | The token lacks job:manage | Ask the user for a token with job:manage. Do not start the work again to get a fresh handle |
Hosted insufficient_scope “Reconnect Gavana with the required permission: job:manage.” | The connection lacks job:manage | The user has to reconnect and grant it |
403 “This account cannot edit that canvas.” | Image and Action runs need owner or editor access to their canvas | Use an account that can edit the canvas |
404 not_found “Image job was not found.”, “Video job was not found.” or “Run was not found.” (CLI exit 5) | Wrong handle family, the record expired, or it is not yours. A Recipe run on a canvas you cannot edit also cancels as “Run was not found.” | Check the handle family, then list_image_runs. Missing does not mean failed |
“Expected run:<id>.” or “Expected job:<id>.” (CLI exit 2) | A job: handle passed to run, or the reverse | Use the matching command group |
400 “The selected Run is not an image generation.”, “The selected job is not a video generation.” or “The selected Run is not a reusable workflow run.” | The hosted read tool does not match the kind of work | Use the reader for what started it, or run_snapshot |
| Hosted: ”… identifies an imported image, not a generation.” | An import: id from an imported picture | Imported pictures have no run. Nothing to watch |
“run cancel stops active Recipe, image, or Action work. Re-run with —yes.” (exit 2) | Cancel without --yes | Confirm the user asked, then add --yes |
Code timeout (CLI exit 8) | Your wait ended first | Wait again or poll. The work is still going |
expired with result_expired: “Temporary job data has expired, and no matching durable output could be verified on its Canvas.” | The record lapsed before a durable output was confirmed | Inspect the canvas and assets before deciding anything with the user |
429 rate_limited “Too many Gavana tool calls. Retry in N seconds.” | Hosted polling too fast | Slow down and retry after the stated wait |
429 “This account already has N active image or Action jobs, which is the limit of N.” | The concurrent-job limit | Read details.activeRuns. Wait for one to finish, or cancel one only if the user says so |
Terminal failure.code values, by kind:
-
Image and Action:
provider_authentication_failed,provider_timeout,provider_rate_limited,provider_rejected,provider_unavailable,runtime_failed,action_input_invalid,result_expired,output_finalization_failed,canvas_target_deleted,canvas_target_reassigned. -
Recipe:
recipe_input_invalid,recipe_step_failed,recipe_output_missing,recipe_run_canceled,delegation_revoked. -
Video:
video_generation_failed,canceled.
What you end up with
- One terminal status per run, read from Gavana and never assumed
- Durable
node:andasset:handles, or a downloaded video file - No second paid start, and no cancel the user did not ask for