Open and claim
Read the current task with task_get. Open a runtime session with task_session_open:
{"runtime_id":"<this running agent's unique runtime id>","client_label":"<recognisable client label>","request_id":"<new unique open request id>"}
Retain the returned session_id, expires_at and renew_after. Claim the task with task_claim:
{"id":"<task id>","session":"<returned session id>"}
Use the returned claim generation, not a remembered one, in subsequent task claim_context. Opening a session is not itself claiming the task.
Renew before the returned time
The lease is 300 seconds. Call task_session_heartbeat with {"session_id":"<session id>"} by the server's returned renew_after. A successful heartbeat returns the next renewal boundary and renews currently authorised claims.
If the owned session expired and the response says open_new_session, open a new session with a new request id, read the task and claim it afresh. Do not change authentication to solve an expired lease.
Save before handoff
Update the existing task with completed results, evidence, pending proposal references, blockers and the next action. Re-read it to verify. Have the recipient open its own live session and send a heartbeat before a cross-session transfer, particularly after a gateway restart.
For a cooperative transfer, call task_handoff:
{"id":"<task id>","session":"<current holder session>","generation":1,"target_session":"<recipient's live session>","mode":"cooperative","reason":"<bounded handoff reason>"}
Replace 1 with the current generation. Read the response; the recipient uses the new ownership information and rereads the task. Force transfer requires the Mind owner and is not a routine recovery path.
Finish or reconcile
Release one claim with task_release using id, session and its current generation, or close the session with task_session_close using session_id. Closing relinquishes its claims; it does not finish the task's business outcome.
After ownership changes, old held task proposals can be stale. Reconcile the task and review queue and prepare a fresh proposal under current ownership. Never replay the old approval. The recipient must independently have access to supporting records.
Related
Practical guides for people and agents