<?xml version="1.0" encoding="UTF-8"?>
<mxfile host="eli.ai" agent="eli.ai diagram exporter" version="1">
  <diagram id="sdk-durable-run-reattachment-afc808bc" name="SDK durable run reattachment">
    <mxGraphModel dx="1600" dy="1200" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1600" pageHeight="1200" math="0" shadow="0">
      <root>
        <mxCell id="0"/>
        <object id="1" label="SDK durable run reattachment" schemaVersion="1" diagramId="sdk-durable-run-reattachment-afc808bc" canonicalAppearanceKey="tsx:src/app/(docs)/docs/api/sdk/page.tsx:runFlow#1" sourceSha256="afc808bcbfad3a043154ed09eac58c0aae0168fe7763ab57d48029b421417c08" metadataPayloadSha256="e042b0bae3bc6b6a66f9036e90616fe4e9fcc19bc07b641fedc81f97926750fd" generationKey="0025e49c0eb5e889df5aa39013a70ba27f94d0bc76a8c4efa3d1b2d9722c40ba" concepts="[&quot;Run flow&quot;,&quot;SDK&quot;]" keywords="[&quot;eli.ai web&quot;,&quot;model_call / tool_call&quot;,&quot;agents.createRun(slug, input)&quot;,&quot;persist queued run&quot;,&quot;execute + persist steps&quot;,&quot;GET /runs/{id}/stream&quot;,&quot;replay, then tail&quot;,&quot;POST /runs/{id}/approve&quot;,&quot;reconnect stream&quot;,&quot;POST /agents/{slug}/runs&quot;,&quot;Postgres&quot;,&quot;agents.streamRun(runId)&quot;,&quot;App&quot;,&quot;EliClient&quot;,&quot;Worker&quot;,&quot;suspended&quot;,&quot;final&quot;,&quot;error&quot;]" application="{&quot;name&quot;:&quot;eli-ai&quot;,&quot;version&quot;:&quot;0.1.0&quot;}" packages="{&quot;mermaid&quot;:&quot;11.16.0&quot;,&quot;mermaidCli&quot;:&quot;11.16.0&quot;,&quot;playwright&quot;:&quot;1.62.1&quot;,&quot;playwrightCore&quot;:&quot;1.62.1&quot;,&quot;puppeteer&quot;:&quot;25.6.0&quot;,&quot;puppeteerCore&quot;:&quot;25.6.0&quot;}" environment="{&quot;architecture&quot;:&quot;x64&quot;,&quot;containerImage&quot;:&quot;playwright:v1.62.1-noble@sha256:c091b21d9fae78c76e85cd4356431e9b018402f172a214fc7d7a5e9a7e29d8ac+node:26.3.1-bookworm-slim@sha256:209558c3e5e40e8adff68959d3c2ba7cd73723e716d89196878a0c362fa1e109&quot;,&quot;node&quot;:&quot;v26.3.1&quot;,&quot;platform&quot;:&quot;linux&quot;,&quot;yarn&quot;:&quot;4.17.1&quot;}" renderer="{&quot;browser&quot;:{&quot;executableSha256&quot;:&quot;0b20b130e7edd9dd51873be867761295fe0cfad490c2b9a64f95bd3cfc08fa71&quot;,&quot;name&quot;:&quot;chromium&quot;,&quot;revision&quot;:&quot;1234&quot;,&quot;version&quot;:&quot;151.0.7922.34&quot;},&quot;font&quot;:{&quot;family&quot;:&quot;Eli Diagram Inter Variable&quot;,&quot;fileSha256&quot;:&quot;3100e775e8616cd2611beecfa23a4263d7037586789b43f035236a2e6fbd4c62&quot;,&quot;licenseSha256&quot;:&quot;3b0a5fca3d17942cde889069889dedbbbd075e9b599968c82a95f4d944e9b345&quot;},&quot;mermaidConfigSha256&quot;:&quot;68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101&quot;,&quot;themeCssSha256&quot;:&quot;c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033&quot;}" adapterVersions="{&quot;diagramGenerator&quot;:&quot;2&quot;,&quot;drawioFlowchart&quot;:&quot;1&quot;,&quot;drawioGantt&quot;:&quot;1&quot;,&quot;drawioSequence&quot;:&quot;1&quot;,&quot;drawioState&quot;:&quot;1&quot;}" mermaidType="sequence" generatedAt="2026-08-12T23:42:01.059Z" mermaidSource="sequenceDiagram&#10;  participant App&#10;  participant SDK as EliClient&#10;  participant Web as eli.ai web&#10;  participant Worker&#10;  participant DB as Postgres&#10;&#10;  App-&gt;&gt;SDK: agents.createRun(slug, input)&#10;  SDK-&gt;&gt;Web: POST /agents/{slug}/runs&#10;  Web-&gt;&gt;DB: persist queued run&#10;  Web--&gt;&gt;SDK: 202 { runId, stream }&#10;  Worker-&gt;&gt;DB: execute + persist steps&#10;  App-&gt;&gt;SDK: agents.streamRun(runId)&#10;  SDK-&gt;&gt;Web: GET /runs/{id}/stream&#10;  Web-&gt;&gt;DB: replay, then tail&#10;  Web--&gt;&gt;SDK: model_call / tool_call&#10;  alt approval required&#10;    Web--&gt;&gt;SDK: suspended&#10;    App-&gt;&gt;Web: POST /runs/{id}/approve&#10;    App-&gt;&gt;Web: reconnect stream&#10;  else complete&#10;    Web--&gt;&gt;SDK: final&#10;  else terminal stream error&#10;    Web--&gt;&gt;SDK: error&#10;  end">
          <mxCell parent="0"/>
        </object>
        <object id="c:i17" label="alt [approval required] / [complete] / [terminal stream error]" mermaidId="i17" mermaidShape="frame">
          <mxCell parent="1" vertex="1" style="collapsible=0;container=1;dashed=1;fillColor=none;fontColor=#333333;html=1;recursiveResize=0;rounded=0;strokeColor=#9370DB;whiteSpace=wrap;">
            <mxGeometry x="64" y="525" width="579" height="385" as="geometry"/>
          </mxCell>
        </object>
        <object id="n:DB" label="Postgres" mermaidId="DB" mermaidShape="participant">
          <mxCell parent="1" vertex="1" style="fillColor=#eaeaea;fontColor=#333333;html=1;participant=umlActor;shape=umlLifeline;strokeColor=#666;whiteSpace=wrap;">
            <mxGeometry x="1055" y="0" width="150" height="65" as="geometry"/>
          </mxCell>
        </object>
        <object id="n:Worker" label="Worker" mermaidId="Worker" mermaidShape="participant">
          <mxCell parent="1" vertex="1" style="fillColor=#eaeaea;fontColor=#333333;html=1;participant=umlActor;shape=umlLifeline;strokeColor=#666;whiteSpace=wrap;">
            <mxGeometry x="757" y="0" width="150" height="65" as="geometry"/>
          </mxCell>
        </object>
        <object id="n:Web" label="eli.ai web" mermaidId="Web" mermaidShape="participant">
          <mxCell parent="1" vertex="1" style="fillColor=#eaeaea;fontColor=#333333;html=1;participant=umlActor;shape=umlLifeline;strokeColor=#666;whiteSpace=wrap;">
            <mxGeometry x="557" y="0" width="150" height="65" as="geometry"/>
          </mxCell>
        </object>
        <object id="n:SDK" label="EliClient" mermaidId="SDK" mermaidShape="participant">
          <mxCell parent="1" vertex="1" style="fillColor=#eaeaea;fontColor=#333333;html=1;participant=umlActor;shape=umlLifeline;strokeColor=#666;whiteSpace=wrap;">
            <mxGeometry x="293" y="0" width="150" height="65" as="geometry"/>
          </mxCell>
        </object>
        <object id="n:App" label="App" mermaidId="App" mermaidShape="participant">
          <mxCell parent="1" vertex="1" style="fillColor=#eaeaea;fontColor=#333333;html=1;participant=umlActor;shape=umlLifeline;strokeColor=#666;whiteSpace=wrap;">
            <mxGeometry x="0" y="0" width="150" height="65" as="geometry"/>
          </mxCell>
        </object>
        <object id="e:lifeline:DB" label="" mermaidId="lifeline:DB" mermaidKind="lifeline">
          <mxCell parent="1" source="n:DB" target="n:DB" edge="1" style="dashed=1;dashPattern=4 4;edgeStyle=none;endArrow=none;endFill=0;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#999;strokeWidth=0.5;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="1130" y="65" as="sourcePoint"/>
              <mxPoint x="1130" y="930" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:lifeline:Worker" label="" mermaidId="lifeline:Worker" mermaidKind="lifeline">
          <mxCell parent="1" source="n:Worker" target="n:Worker" edge="1" style="dashed=1;dashPattern=4 4;edgeStyle=none;endArrow=none;endFill=0;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#999;strokeWidth=0.5;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="832" y="65" as="sourcePoint"/>
              <mxPoint x="832" y="930" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:lifeline:Web" label="" mermaidId="lifeline:Web" mermaidKind="lifeline">
          <mxCell parent="1" source="n:Web" target="n:Web" edge="1" style="dashed=1;dashPattern=4 4;edgeStyle=none;endArrow=none;endFill=0;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#999;strokeWidth=0.5;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="632" y="65" as="sourcePoint"/>
              <mxPoint x="632" y="930" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:lifeline:SDK" label="" mermaidId="lifeline:SDK" mermaidKind="lifeline">
          <mxCell parent="1" source="n:SDK" target="n:SDK" edge="1" style="dashed=1;dashPattern=4 4;edgeStyle=none;endArrow=none;endFill=0;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#999;strokeWidth=0.5;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="368" y="65" as="sourcePoint"/>
              <mxPoint x="368" y="930" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:lifeline:App" label="" mermaidId="lifeline:App" mermaidKind="lifeline">
          <mxCell parent="1" source="n:App" target="n:App" edge="1" style="dashed=1;dashPattern=4 4;edgeStyle=none;endArrow=none;endFill=0;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#999;strokeWidth=0.5;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="75" y="65" as="sourcePoint"/>
              <mxPoint x="75" y="930" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i0" label="agents.createRun(slug, input)" mermaidId="i0" mermaidKind="message">
          <mxCell parent="1" source="n:App" target="n:SDK" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="76" y="115" as="sourcePoint"/>
              <mxPoint x="364" y="115" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i1" label="POST /agents/{slug}/runs" mermaidId="i1" mermaidKind="message">
          <mxCell parent="1" source="n:SDK" target="n:Web" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="369" y="165" as="sourcePoint"/>
              <mxPoint x="628" y="165" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i2" label="persist queued run" mermaidId="i2" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:DB" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="633" y="215" as="sourcePoint"/>
              <mxPoint x="1126" y="215" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i3" label="202 { runId, stream }" mermaidId="i3" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:SDK" edge="1" style="dashed=1;dashPattern=3  3;edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="631" y="265" as="sourcePoint"/>
              <mxPoint x="372" y="265" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i4" label="execute + persist steps" mermaidId="i4" mermaidKind="message">
          <mxCell parent="1" source="n:Worker" target="n:DB" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="833" y="315" as="sourcePoint"/>
              <mxPoint x="1126" y="315" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i5" label="agents.streamRun(runId)" mermaidId="i5" mermaidKind="message">
          <mxCell parent="1" source="n:App" target="n:SDK" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="76" y="365" as="sourcePoint"/>
              <mxPoint x="364" y="365" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i6" label="GET /runs/{id}/stream" mermaidId="i6" mermaidKind="message">
          <mxCell parent="1" source="n:SDK" target="n:Web" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="369" y="415" as="sourcePoint"/>
              <mxPoint x="628" y="415" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i7" label="replay, then tail" mermaidId="i7" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:DB" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="633" y="465" as="sourcePoint"/>
              <mxPoint x="1126" y="465" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i8" label="model_call / tool_call" mermaidId="i8" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:SDK" edge="1" style="dashed=1;dashPattern=3  3;edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="631" y="515" as="sourcePoint"/>
              <mxPoint x="372" y="515" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i10" label="suspended" mermaidId="i10" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:SDK" edge="1" style="dashed=1;dashPattern=3  3;edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="631" y="610" as="sourcePoint"/>
              <mxPoint x="372" y="610" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i11" label="POST /runs/{id}/approve" mermaidId="i11" mermaidKind="message">
          <mxCell parent="1" source="n:App" target="n:Web" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="76" y="660" as="sourcePoint"/>
              <mxPoint x="628" y="660" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i12" label="reconnect stream" mermaidId="i12" mermaidKind="message">
          <mxCell parent="1" source="n:App" target="n:Web" edge="1" style="edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="76" y="710" as="sourcePoint"/>
              <mxPoint x="628" y="710" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i14" label="final" mermaidId="i14" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:SDK" edge="1" style="dashed=1;dashPattern=3  3;edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="631" y="805" as="sourcePoint"/>
              <mxPoint x="372" y="805" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
        <object id="e:i16" label="error" mermaidId="i16" mermaidKind="message">
          <mxCell parent="1" source="n:Web" target="n:SDK" edge="1" style="dashed=1;dashPattern=3  3;edgeStyle=none;endArrow=block;endFill=1;html=1;jettySize=auto;orthogonalLoop=1;rounded=0;strokeColor=#333333;strokeWidth=2;">
            <mxGeometry relative="1" as="geometry">
              <mxPoint x="631" y="900" as="sourcePoint"/>
              <mxPoint x="372" y="900" as="targetPoint"/>
            </mxGeometry>
          </mxCell>
        </object>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
