Quickstart: Giving Agents a Development Environment
Running AI generated code securely with Runloop
Runloop Devboxes are a secure and isolated environment for running AI-generated code.
Let’s see how we can use Devboxes to safely run AI generated code to generate mazes.
Set Up Your Environment
Set up your API keys as environment variables:
Replace the placeholders with your actual API keys. Note you can get your Runloop API key from the Runloop Dashboard.
Use AI to generate a maze generator program
First, we’ll use the OpenAI API to generate Python code that generates a maze.
Create a Devbox to securely run the AI generated code
Now, let’s create a Devbox to use as our sandbox environment. Once a Devbox is created, Runloop will automatically provision a secure microVM that can be used to load and run any coding projects.
A Devbox starts in the ‘provisioning’ state. Once the Devbox is ready, it will transition to the ‘running’ state at which point we can begin using it.
This command will return a Devbox ID (e.g., dbx_1234567890
). Save this for later use.
Upload the Maze Generator Program to the Devbox
Now, let’s upload the Python script to the Devbox so we can run it securely.
Run the Maze Generator Program
Shutdown the Devbox
Once we are done generating mazes, we can shut down the Devbox to free up resources:
By default, Devboxes are configured to automatically shut down after 60 minutes of inactivity but they can be configured to run for any amount of time or even to automatically shut down after some idle period.
Giving agents a secure development environment via Tools
In addition to just using the Runloop API to manually upload and run code, you can also use Runloop Tools to give full access to the Devbox to an agent.
For example, let’s make a simple coding agent that can generate any Python code and again ask it to generate a maze!
Create a Devbox for the agent to use
Let’s create a Devbox to use as a development environment for the agent.
This command will return a Devbox ID (e.g., dbx_1234567890
). Save this for later use.
Create tools so the agent can use the Devbox
Next, let’s create tools bound to the Devbox so the agent can use it. In the examples below, we will use:
- (python) the Ell framework to create tools and run an agent
- (typescript) the Vercel AI SDK to create tools and run an agent However, the tools can easily be created in any language and any framework! Checkout our examples repository for more examples for your favorite language or framework.
By default, Devboxes are configured to automatically shut down after 60 minutes of inactivity but they can be configured to run for any amount of time or even to automatically shut down after some idle period.
Run the agent with the tools
Now we can give the tools to the agent and ask it to use the remote devbox to generate a maze and run the progrem
Shutdown the Devbox
Once we are done having our agent generate mazes, we can shut down the Devbox:
Was this page helpful?