Durable sessions

Stream ordered events, switch harness mid-session, and pick up where you left off.

  1. Send work and stream replies

    Every event has a monotonic sequence number. Disconnects never stop a turn.

    Read the docs
    await client.sessions.events.send(session.id, {  events: [{ type: "user.message", content: [{ type: "text", text: "Summarize the open ticket." }] }],}) for await (const event of await client.sessions.events.stream(session.id)) {  if (event.type === "agent.message") console.log(event.content.map((b) => b.text).join(""))  if (event.type === "session.status_idle" || event.type === "session.status_terminated") break}
  2. Resume from any cursor

    Reopen a stream with after or Last-Event-ID to continue without missing events.

    Read the docs
    for await (const event of await client.sessions.events.stream(session.id, { after: lastSeq })) {  if (event.type === "agent.message") console.log(event.content.map((b) => b.text).join(""))  if (event.type === "session.status_idle") break}
  3. Switch harness mid-session

    Pick another harness or model while idle. History, mounts, and files stay intact.

    Read the docs
    await client.sessions.selectRuntime(session.id, {  harness: "codex",  model: "gpt-5.4",})

Managed agents for any harness

Pick the harness and model. Checkfu runs everything around them.