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:
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.
dbx_1234567890
). This ID will be used to perform operations on the Devbox.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 Python code and ask it to write a command-line script that prints command-line arguments as ascii words!
Create a Devbox for the agent to use
Let’s create a Devbox to use as a development environment for the agent.
dbx_1234567890
). This ID will be used to perform operations on the Devbox.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: Utilize the Ell framework to create tools and run an agent.
- TypeScript: Define each tool and pass them as a
ChatCompletionTool[]
.
However, the tools can easily be created in any language and any framework! Check out our examples repository for more examples in your favorite language or framework.
By default, Devboxes are configured to automatically shut down after 60 minutes of inactivity. They can also be configured to run for any amount of time or to automatically shut down after a specified idle period.
Run the agent with the tools
Now we can give the tools to the agent and ask it to generate a script and run the program in the devbox.
Shutdown the Devbox
Once we are done having our agent generate mazes, we can shut down the Devbox:
Explore the Runloop Examples Repository to discover how to implement AI agents to run in Runloop.
Was this page helpful?