Skip to main content
To check on a run from somewhere other than where you started it, such as a serverless function, a job queue, or a plain REST caller with no waiter, poll for its status yourself instead of relying on a blocking call. create_and_wait / createAndWait cover the common case: see Basic run for the full walkthrough. This guide covers doing that by hand instead.

Create, then poll get

create returns immediately with the run in pending state. Poll get by id until status reaches a terminal state (completed, failed, or cancelled); stop_reason appears only once it does.
run.status prints as a raw integer in Python (3 for completed) unless you compare against the named constant or call .Name(). This is the same gotcha Monitor’s run status has. Over REST and in TypeScript, status is already the lowercase/named form ("completed", AgentRunStatus.COMPLETED).
This is exactly what wait / createAndWait do for you. Reach for them first, and write your own loop only when you need to poll from somewhere the blocking call does not fit, or need a different interval than the SDK default of 10 seconds.
timeout / timeoutMs bounds the wait client-side only. On expiry the SDK raises SeltzTimeoutError, but the run keeps executing server-side. Poll get again later, or see Cancel a run if you no longer want the result.

Next steps

  • List runs: paging this org’s runs, newest first
  • Cancel a run: best-effort cancellation, and why it can lose the race to completion
  • Reference: endpoints, fields, limits and errors
  • Agent API Reference: full REST request and response specification