Inspiration
Users from around the world use LLMs and provide prompts to them in hopes of receiving the best response possible. However, they are bound to the fact that certain LLM models will provide better output for their specific use case. Our team was amused at the possible idea of multiple LLMs conversing with each other, arguing for who has the better response. Then we discovered the capabilities of AWS Bedrock, which would allow this idea to become a reality. Inspired by the MAGI supercomputer from Neon Genesis Evangelion (an anime that sparked our idea), we set out to build an AI system that fundamentally collaborates with itself. We wanted to force a deliberation between highly opinionated, specialized personas using multiple LLMs to reach a bulletproof consensus.
What it does
MAGI is a multi-agent orchestration platform that evaluates prompts through three distinct, collaborating perspectives simultaneously.
Users can select "Presets" that assign specific system prompts and LLM models to our three sub-agents. For example, in our "Code Architect" preset, one agent ruthlessly optimizes for Big-O efficiency, another defends clean code and maintainability, and the third attacks the proposal for security vulnerabilities.
When a user submits a prompt, a background Supervisor agent delegates the task to all three sub-agents. The frontend streams their real-time, independent deliberations, culminating in the Supervisor synthesizing their arguments and delivering a final consensus verdict.
How we built it
The architecture is divided into a sleek React frontend and a robust AWS backend.
The Brains (AWS Bedrock): We utilized Amazon Bedrock's multi-agent collaboration features to build the MAGI Supervisor and the three sub-agents. To ensure diverse reasoning, we mixed model families (Claude 3.5 Sonnet v2, Mistral Large 2, Nova Pro, Command R+) so the agents wouldn't suffer from shared underlying biases.
The Bridge (AWS Lambda Streams): Because multi-agent deliberation takes time, we couldn't rely on standard REST calls. We built a Node.js AWS Lambda function utilizing RESPONSE_STREAM to send Server-Sent Events (SSE) directly to our React frontend. This allows users to watch the models "think" in real-time.
The State (DynamoDB): A secondary serverless REST Lambda handles CRUD operations, interacting with Amazon DynamoDB to store custom user presets and past chat histories.
Challenges we ran into
Multi-Agent Routing: Getting the Bedrock Supervisor to reliably route prompts to all three sub-agents simultaneously, rather than trying to answer the prompt itself, required precise collaboration instructions.
Handling the Stream: Wiring up the AWS SDK
BedrockAgentRuntimeClientinside a streaming Lambda and properly decoding the byte chunks into a clean SSE feed for the React frontend was tricky to get right without dropping tokens.CORS: Configuring our streaming Lambda Function URL to properly accept cross-origin requests from our React frontend meant carefully setting up allowed origins and headers for both the preflight requests and the continuous Server-Sent Events (SSE) stream itself.
Permissions: Navigating AWS Identity and Access Management (IAM) required hefty work. We had to properly attach inline policies to our Lambda execution roles to ensure the streaming backend had the exact
bedrock:InvokeAgentpermissions required to trigger the MAGI Supervisor alias, while granting our REST Lambda secure access to query and update our DynamoDB tables.
Accomplishments that we're proud of
Successfully orchestrating multiple state-of-the-art foundational models to collaborate and debate within a single continuous workflow.
Building a completely serverless, highly scalable backend utilizing Bedrock, Lambda, and DynamoDB.
Nailing the UI/UX to make the multi-agent deliberation process transparent and visually engaging for the user.
What we learned
How to configure and deploy AWS Bedrock Multi-Agent systems and map aliases to live endpoints.
The intricacies of handling Server-Sent Events (SSE) and Lambda response streams to overcome API Gateway timeout limitations.
Advanced prompt engineering techniques to enforce rigid personas onto highly capable generalized models.
What's next for MAGI
We want to expand the platform's utility beyond a chat interface. We plan to integrate tools like AWS MCP servers so MAGI can directly interact with user environments. We also want to implement automated webhooks, allowing MAGI to act as an automated PR reviewer on GitHub or a proposal evaluator natively within platforms like Discord.
Built With
- amazon-web-services
- bedrock
- cloudwatch
- css
- dynamodb
- figma
- html
- iam
- javascript
- lambda
- node.js
- react
- typescript
- vite
Log in or sign up for Devpost to join the conversation.