FastAgency is an open-source framework designed to accelerate the transition of multi-agent AI workflows from prototype to production. It is not just another agentic AI framework; rather, it provides a unified programming interface for agent workflows written using the AG2 (formerly AutoGen) framework, helping developers deploy these workflows in development and production environments. With just a small amount of code, you can create a web chat application or REST API service that interacts with agents. If you need to scale workloads, FastAgency helps deploy a fully distributed system, using an internal message broker to coordinate multiple machines and multiple data centers, with only minor code changes to the local development setup.
Key capabilities:
- Unified programming interface across UIs: The core workflow only needs to be developed once and can then be reused across multiple user interfaces without rewriting code. It supports console-based applications (ConsoleUI) and web-based applications (MesopUI).
- Seamless external API integration: With just a small amount of code, you can import OpenAPI specifications and connect to agents, simplifying the process of enhancing AI agents with real-time data, external processing, or third-party services.
- Tester class for continuous integration: Provides a Tester class that enables developers to write and execute tests for multi-agent workflows, making it easy to integrate into CI pipelines and ensuring that workflows remain functional as they scale to production.
- Command-line interface (CLI): Provides a powerful CLI for orchestrating and managing multi-agent applications directly from the terminal, allowing you to quickly run workflows, pass parameters, and monitor agent interactions, making it suitable for automated deployment and integration into DevOps pipelines.
Supported runtimes: Currently only AG2 (formerly AutoGen) is supported.
Supported user interfaces:
- Console: Use the ConsoleUI interface for command-line-based interaction, suitable for developing and testing workflows in a text environment.
- Mesop: Use MesopUI for web-based applications, suitable for creating web applications with user-friendly interfaces.
Supported network adapters:
- REST API via FastAPI: Use FastAPIAdapter to serve workflows through a FastAPI server, supporting multiple worker processes and using an ASGI server.
- NATS.io via FastStream: Use NatsAdapter to leverage the NATS.io MQ message broker, enabling highly scalable production-gradesetup, suitable for VPN environments, or combined with FastAPIAdapter to serve public workflows in a secure manner.
Usage: It is strongly recommended to use Cookiecutter to set up a FastAgency project. It creates the project folder structure, a default workflow, automatically installs all necessary dependencies, and creates a devcontainer that can be used for Visual Studio Code development. Install Cookiecutter: pip install cookiecutter Run the cookiecutter command: cookiecutter https://github.com/ag2ai/cookiecutter-fastagency.git Follow the prompts to select the project name, application type (fastapi+mesop, mesop, nats+fastapi+mesop), Python version (3.12, 3.11, 3.10), and authentication method (none, google). Set the LLM API key, for example OpenAI: export OPENAI_API_KEY=openai_api_key_here Open the generated project in VS Code: code my_fastagency_app After reopening the project in the devcontainer, run the tests to verify the setup: pytest -s
Workflow development: Define the workflow in my_fastagency_app/workflow.py, specifying how the agents interact and what they do. The example code sets up a simple student-teacher learning chat.
Local testing: Use MesopUI to test the workflow locally; the code is located in my_fastagency_app/local/main_mesop.py. Run the Mesop app on Linux and MacOS, and use the corresponding command on Windows. Open a browser and visit http://localhost:8000 You can use the graphical interface to manually start, run, test, and debug autogen workflows.
Build a Docker image: After creating a project with Cookiecutter, run the provided script to build the Docker image. Run the Docker image: Likewise, run the provided script to run the Docker container.
Deploy to Fly.io: Cookiecutter generates built-in scripts that can deploy the workflow to Fly.io. You need to first check and keep the application name, then test the deployment. For official deployment, you should use GitHub Actions. Push the code to the main branch of the GitHub repository, and GitHub Actions will automatically deploy to Fly.io. You need to set secrets such as the Fly.io API token and OpenAI API key in the GitHub repository.
Use cases: Suitable for developers using the AG2 (formerly AutoGen) framework who want to seamlessly extend Jupyter notebook prototypes into fully featured production-grade applications. Whether building interactive console tools, developing full-featured web applications, or orchestrating large-scale multi-agent systems, FastAgency can help deploy faster, more reliably, and more flexibly.
Limitations: Currently, only the AG2 (formerly AutoGen) runtime is supported. The team is actively expanding capabilities and plans to integrate other frameworks, network providers, and UI frameworks.