Skip to main content
This guide covers how to kick off background runs for your agent. This can be useful for long running jobs.

Setup

First let’s set up our client and thread:
Output:

Check runs on thread

If we list the current runs on this thread, we will see that it’s empty:
Output:

Start runs on thread

Now let’s kick off a run:
The first time we poll it, we can see status=pending:
Output:
Now we can join the run, wait for it to finish and check that status again:
Output:
Perfect! The run succeeded as we would expect. We can double check that the run worked as expected by printing out the final state:
Output:
We can also just print the content of the last AIMessage:
Output: