SESSION_URL, TURN_ID, and AGENTSCOPE_API_KEY. Once a task is submitted, users may need to change requirements, answer an Agent’s question, or stop and resume execution. This page explains how those operations apply to an existing Session and Turn. An authorized platform Bearer token can also access a Session. Application credentials need both the required scope and an explicit grant for the target resource.
How Sessions and Turns relate
Session creation freezes the target and its configuration. Subsequent Turns use that configuration, so editing an Agent does not silently change an existing conversation. Create a new Session to use the updated definition. Workflow Sessions select a published revision, either explicitly or by resolving the latest published revision at creation.Update Managed runtime resources
Update Managed runtime resources
A Managed Session can update runtime resource bindings with
PATCH. Complete an initial Turn to establish its runtime Session, then fill in an Environment ID you may use. This changes only the Environment and keeps the frozen Agent definition version./capabilities before displaying controls.
A 202 Accepted response with status queued means the task has been accepted and has not finished. Retry a network request with the same Idempotency-Key and body to retrieve the original Turn. Use a new key only for a new task. When a page refreshes, read the existing Session snapshot and events instead of resubmitting input.
Read results and restore a page
ReadGET /turns/{turnId} for task status. To restore the full page, load the Session /snapshot, then connect to /events/stream with the returned as_of. A view limited to one Turn should pair that Turn’s /snapshot with its own /events/stream. Session and Turn cursors are not interchangeable.
List Sessions and previous Turns
List Sessions and previous Turns
The Session list defaults to active records;
status=all also includes archived records. Both lists return items and next_offset; pass a non-null next offset as offset in the next request.Add requirements or context
Submit a new Turn for a new question. To change the subsequent steps of an active Managed task, usesteer when supported. Steering cannot change a model request that has already been sent. To add background context without starting inference, use the Session /inputs/inject resource.
Read the Turn’s available commands before displaying controls:
message or an input array of user messages, but not both. Structured input carries text and file references; see Files and artifacts. input.accepted means persisted, while input.applied means consumed by the runtime. Do not present acceptance as completed processing.
Add context without starting inference:
Answer a required action
An Agent creates a required action when it needs confirmation or an external execution result. Save itsrequest_id, explain the requested operation to the user, and submit their actual decision to the corresponding Turn. Replace the placeholder below with an ID returned by the service:
request_id and check the required answer type. For a tool confirmation, use the following answer; set allow to false and explain the reason to deny it.
interact scope permits interaction requests but does not turn an application credential into a named human approver. Identity-bound approvals still require an authorized user.
External tool results and designated approval
External tool results and designated approval
Use real For a business approval, use the current version from the pending action and the designated approver’s
output only for an action asking for external tool results. Set is_error: true and report the actual error if execution failed. This is a different answer from a tool permission decision.TOKEN. Replace EXPECTED_VERSION with the actual number; use decision: "rejected" to reject it.Cancel and resume
Cancellation and resumption operate on an existing Turn and require stable idempotency keys. After a cancellation receipt, wait for an explicit terminal state. Cancellation cannot guarantee reversal of operations already sent to external systems, so reconcile their outcomes before another execution.failed still holds later Turns in its Session. When its available_commands includes cancel, submit /cancel to discard it. The Turn keeps the failed status, no tool call is repeated, and the next queued Turn can start.
When available_commands from /turns/{turnId}/capabilities includes resume, submit to that Turn’s /resume path. Resumption retains the Turn ID and continues from persisted state. Answer pending actions first, and reconcile uncertain tool results before continuing. Resume is not a general replacement for submitting a new task.
Usage, subagents, and budgets
A Managed Session’s/subagents resource lists associated child sessions. Follow those associations to inspect child snapshots and events. Each child has its own cursor. GET /usage?include_children=true aggregates reported subtree usage, but does not represent an atomic snapshot of every child at the same moment.
Inspect a subagent’s progress
Inspect a subagent’s progress
Read the associations and select a child session ID from the response. The snapshot and stream below both belong to that child:
/budget to limit Managed model calls or accumulated usage. This example allows up to 30 model calls and checks the reported token total before further execution:
Continue from a checkpoint
A Managed Session’s/checkpoints resource lists restorable context records. Select a returned checkpoint_id, call /checkpoints/restore, and submit a new Turn. Restoration appends an audit fact, preserves history, and does not undo external effects.
/fork on the source with {target_session_id, checkpoint_id, reason} and an idempotency key. The sessions must be idle and eligible for recovery, without queued tasks, unresolved actions, or uncertain tool results. Fork copies Agent state, not the environment, credentials, working files, or budget.
Create an empty Session and fork
Create an empty Session and fork
"$BASE_URL/api/v1/agent-sessions/$TARGET_SESSION_ID/turns"./archive blocks new submissions and /restore unarchives it; neither restores a checkpoint. Deleting a Session removes application access but does not immediately erase underlying audit data. See Operations for backup and retention.
Archive, unarchive, and delete
Archive, unarchive, and delete
Ensure no active or queued Turns remain before archiving or deleting; otherwise the request returns 409. Choose the operation you need below. Restore only applies to an archived Session. Deletion removes application access.Archive:Unarchive:Delete:
Background notifications and clients
Register a Session or Turn Webhook for backend notifications after users leave the page. See Webhooks for signatures and retry behavior. Managed/export provides public execution records as JSONL.
frontend/src/api/agentSessions.ts for detailed Managed resources and serviceSessions.ts for generic task views. Both use the same Session API. Keep snapshots paired with their event resource and treat returned IDs as opaque values.
To connect these operations to your own chat page, continue with Integration example: resumable chat. It combines task submission, progress display, and user actions, including how to continue the same work after leaving or refreshing the page.