beam-logo

Petri Nets as an Agent Architecture

author-profile-picEli Mernit
December 5 2024
Product

We’re launching a new agent framework that incorporates compute orchestration directly into the agent, giving you sandbox code execution, GPU parallelism, and session management.

Do We Really Need Another Agent Framework?

It feels like everyone is building an AI agent framework these days. And it was hard to justify shipping this, because there are just so many companies providing tools for agents. But we thought hard about this, and we've got a pretty good reason for doing so.

For background, Beam is a distributed compute runtime. Think of it like an open-source Modal that can run on any cloud.

Developers come to us, wrap their Python code in special decorators, and we containerize it and run their code on the cloud. We're really good at scaling out containers to run ML inference and providing sandboxed compute environments for running untrusted user code.

A few months ago, we had the idea of combining our compute directly into an agent framework. When we looked at the landscape of agent companies, we saw many high-level frameworks, but nothing that included sandboxing or concurrency. While neither of these features were included in the frameworks we saw, they felt essential for building AI agents.

By building an agent framework on Beam, we're able to give a bunch of batteries-included features that we’ve been providing for the past several years. This includes task management, deployment versioning, distributed volumes, secrets, and scheduling.

The Problem: Existing Agents are Single Threaded

Now that we've addressed the elephant in the room, let's talk about the problems with existing agent frameworks.

Nearly all agents are based on Directed Acyclic Graphs, or DAGs. In most DAG architectures, things proceed sequentially, and there’s nothing in the network structure itself that synchronizes results. There are branched execution models, but they aren’t true concurrency models.

content-image

However in the real-world, interactions aren’t linear. For starters, people might ask many questions to an AI agent at once. I want to search Google, and actually can I also search Bing too? In a DAG, these two steps would be fired sequentially. But that's not practical; in the real-world, these steps need to fire at the same time.

Luckily, there's another workflow we can use to solve this.

Introducing Petri Nets

Beam uses a new concurrency model based on Petri Nets, which are capable of multi-tasking complex, multi-threaded workflows.

Concurrency is built into the Petri Net architecture. It allows users to build agents that spawn 100s of different tasks at the same time, while synchronizing the results at the end.

Given our example above, a user could say, why yes, I would like to search Bing and Google at the same time, and the network will be aware that both tasks are running and wait until both are completed before moving to the next action.

content-image

Built for Complex Interactions in the Real-World

In the video below, we'll walk-through the process of running a bot that scrapes and summarizes product reviews across multiple websites, using the Petri Net:

It Can Do Things That Other Frameworks Can’t

In addition to the Petri Net workflow, Beam gives you a bunch of other powerful primitives for building your AI agent armies.

content-image

🛠️ Sandboxed Code Execution

The actions in your agent run in secure and isolated containers in the cloud.

The different actions in your agent can also run on different images with different GPU, Memory, and CPU configuration.

Each action in your bot can run on a totally different runtime.

👽 Human-in-the-loop

We provide various tools for interacting with bots. For example, it's easy to require confirmation from a user before the bot is allowed to take action.

🚄 Parallelism

Your agent can run hundreds of containers in parallel. Imagine a research assistant on steroids that's able to scrape 1000 websites at the same time.

⏰ Session Management

Beam also handles user sessions, auth, and logging, and much more.

🚀 Production Ready Deployments

When you deploy your agent, you’ll get features to manage tasks, view compute utilization and traffic metrics, API authentication, and an enterprise-grade infrastructure that we’ve used to run over 1B inference requests.

content-image

🔐 Run On the Cloud, or Your Own Infrastructure

Beam is entirely open-source, and can be self-hosted on your own hardware or in your cloud account.

What's Next?

We're really excited about the things you can build with this framework. There's clearly a massive opportunity to solve business problems with AI, and by giving developers a scalable platform to build on, we're hoping power of wave of incredible products.

Beam Bots are available today. Check out the documentation to get started!

Keep Reading

card-cover-image
Product

Top Heroku Alternatives

Modern PaaS solutions similar to Heroku that may better suit your use case.

author-profile-picSamuel Liu
card-cover-image
Product

Zonos TTS: A Text-to-Speech Alternative to ElevenLabs

Deploying Zonos with Beam

author-profile-picMia Gouffray

Deploy your app in minutes

Get started with $30 of free credit, refreshed every month