Skip to main content
When developers want to keep a standard operating procedure in the agent service and start runs of it again and again, they can use the SOP support of the service layer. Procedures are stored as data, every run advances step by step in ordinary sessions, and a frontend can watch it live through the session event streams. The service-layer SOP provides the following capabilities:
The SOP service is experimental, and its interfaces and storage layout may change in later releases. A custom storage backend has to implement the SOP methods of StorageBase; until it does, these endpoints raise NotImplementedError while the rest of the service keeps working.

Define a Procedure

A procedure in the service is described by SOPData. Unlike the SDK, which holds agent objects directly, each step here refers to its executor and verifier by agent ID and session key. SOPData has the following fields: Each step (SOPStepDataV1) has the following fields:

Session Keys

session_key decides which session an agent works in. Two references with the same key share one session, and therefore one context; different keys put even the same agent into two sessions that cannot see each other. For example, to let a writer agent carry its context from one step to the next, give both steps’ executors the same key; to have a reviewer judge each time from a blank context, give it a key of its own. A session key belongs to exactly one agent. The session’s model and permission mode are also configured per key in session_settings, and every key in use must be configured there, with these fields:

Verifiers

There are two kinds of verifier, told apart by the type field:

Workspaces

A run’s sessions get their workspaces when they are created, and those workspaces belong to that run alone, never shared with another run. workspace_grain takes the following values: The following request creates a two-step procedure: a writer agent produces a draft that a reviewer agent accepts, and the final version is then signed off by a person:
Create a procedure
The following procedures are refused with 422 when created or updated, rather than failing once a run starts:

List the Endpoints

All SOP endpoints live under /sop, split into procedures and runs:
GET /sop/runs?phase=awaiting lists every run waiting on someone, whether for human sign-off or for a tool confirmation.

Run a Procedure

Starting a run first copies the procedure’s current contents into the run record, so editing the procedure later never affects a run already started. It then opens one session per session key, named “procedure name / session key”, and returns the run record immediately while the run advances in the background:
Start a run
In the returned SOPRunRecord, sessions maps each session key to its session ID, and state is the run state, whose phase tells where the run stands as a whole. Developers can subscribe to those sessions’ event streams at GET /sessions/{session_id}/stream to watch live, and poll GET /sop/runs/{sop_run_id} for progress.

Submit Results

Each step is handed to the agent in its session as an ordinary chat turn. That turn is equipped with one extra submit tool, through which the agent writes its result straight into the run state: If the agent’s reply ends without calling its submit tool, it is reminded to call it. After three reminders with nothing submitted, the reply ends in an error and counts as a refusal. An executor with no handover and a verifier with no verdict both spend the step’s max_attempts.
Only turns dispatched by the run get a submit tool. A developer or user typing directly into a step’s session is just having a conversation: they are neither asked to submit nor able to move the run.

Sign Off as a Person

With a HumanVerifier, the step enters awaiting once the executor hands over, and the run stops. A verdict filed through the following endpoint at any time lets the run carry on in the background:
File a human verdict
The request body has the following fields: The endpoint returns the updated run record as soon as the verdict is recorded. It answers 404 when the run or step does not exist, and 409 when the step is not judged by a person or is not currently waiting to be.

Handle Tool Confirmations

When an agent in a step asks for tool confirmation, the step also enters awaiting. Answering works exactly as in any session: send POST /chat to that session with a UserConfirmResultEvent or ExternalExecutionResultEvent as the body. The resumed turn still carries the submit tool, and once it finishes the run carries on in the background with no further call. If the resumed reply is interrupted, the run stays where it is.

Delete Procedures and Runs

Deletes cascade to the resources a run created: The run created these sessions, so they serve no purpose once it is gone, and a background tool finishing later could otherwise wake them up again. That is why they are deleted along with it.

Current Limitations

The SOP service currently has the following limitations: