The Runloop Agent Runtime
The Runloop Agent Runtime enables you to deploy long running Agents with no timeouts that can interact with devboxes, other agents on the platform, or with your other applications via API.Creating an agent for deployment with Runloop
Writing an agent
First, let’s create a new repository that will house your agent code. To start, you can fork the example repository here. Writing an agent as a Runloop lambda is as easy as annotating a normal python function with the@runloop.function decorator.
Any function that is annotated with @runloop.function will be automatically deployed as a lambda on Runloop’s serverless platform.
The parameters of the function will automatically become the request schema for the agent and the return type of the function will automatically become the response schema.
All function annotated with @runloop.function must explicitly declare all parameters and return types.
@runloop.function can declare a parameter of type runloop.SystemCoordinator which will automatically give your function access to the full suite of Runloop tools.
This includes the ability to create devboxes that can be used as isolated environments to run arbitrary code in.
Telling Runloop where to find your agent code
Now that we have the agent code written, we need to tell Runloop where to find it so it can be automatically deployed. All python agent repositories need to contain two files:- a
requirements.txtfile to declare dependencies for your agent - a
runloop.tomlfile to declare the path to your agent code
bot.py inside afolder called agent at the root of your repository, your runloop.toml file should look like this:
Deploying you first long running Agent
Now that we have written our agent code and indicated where in our repository to find our agent code, let’s deploy it onto Runloop’s serverless platform.Install the Runloop Github Application
Install the Runloop Github Application and give it access to your repository. Make sure to give access to the repository with your agent code. https://github.com/apps/runloopai/installations/new After installing the app you should be redirected the Runloop dashboard. You can go to the deployments page and see your agent deploying successfully. If there are any errors, you can click the details button for that deployment to see the logs of the failed deployment and fix any issues.Invoking your agent
Creating an API key
Now that your agent is deployed, you can create an API key to invoke it. Go to the API keys page and create a new API key. Then set theRUNLOOP_API_KEY environment variable to your new API key.
