SID-2 Swarm

Reconnecting

Resume a run after a dropped connection, and acknowledge events you have processed.

Swarms can tolerate socket drops. Agents that aren't waiting for tool responses continue generating.

Resuming a run

Open a new connection with the same headers and send response.resume instead of response.create, with the run's ID and the last sequence_number you processed:

async with client.beta.responses.connect(extra_headers={"OpenAI-Beta": "responses_multi_agent=v1"}) as conn:
    await conn.send({
        "type": "response.resume",
        "model": MODEL,
        "response_id": response_id,
        "last_sequence_number": last_sequence_number,
    })
    # Re-send every inject that was never acknowledged (see below), then continue the loop.

Every event after last_sequence_number is sent again, with its original sequence number. Omit last_sequence_number to receive every event the server still holds.

  • Re-send unacknowledged injects. An inject sent just before the drop may or may not have reached the server. Keep each inject until its response.inject.created or response.inject.failed arrives, and re-send the rest after resuming. One the server already applied is refused as already answered and changes nothing.
  • Answer calls you received but didn't answer. They aren't sent again if you processed them before the drop.
  • If the resume is refused with run_owned_elsewhere, the run is being moved on the server side. Wait a few seconds and resume again.
  • If it's refused with response_not_found, the run is unknown or has expired.

Acknowledging events

Send response.ack with the last sequence_number you have processed. The server then drops earlier events and won't replay them.

await conn.send({"type": "response.ack", "response_id": response_id, "sequence_number": last_sequence_number})

Time limits

  • A swarm that receives no responses for 30 minutes ends with response.failed, code run_abandoned. Unanswered tool calls count as no progress.
  • A finished swarm can still be resumed for 5 minutes, to collect missed events.

Content