
Rust Multi-Agent Marketing Console
A high-performance, type-safe implementation of an iterative creative workflow built with Rust and WebAssembly.
Project details
Overview
The Rust Multi-Agent Marketing Console is a high-performance, type-safe implementation of an iterative creative workflow. Built with Rust and the Leptos framework, it compiles to WebAssembly (WASM) to run natively in the browser with near-native performance.
This project demonstrates 'Governance as Code'—leveraging Rust's strict type system to model complex state machines. Unlike Python scripts that rely on fragile runtime checks, this system enforces business logic and safety policies at the compiler level.
Demo Video: Governance in Action
Multi-Agent Governance Workflow
This video demonstrates a 'Governance as Code' workflow where an AI agent team creates a marketing slogan. It highlights a critical failure scenario (using a cliché) and the system's ability to self-correct via the Manager guardrail without human intervention.
Workflow Breakdown
- Phase 1: The Setup (00:00)
The dashboard initializes. The user inputs a generic brief: "a new revolutionary AI-powered productivity app". The UI clearly distinguishes between the Creator (Copywriter) and the Approvers (Manager/Director). - Phase 2: The Guardrail (00:03)
The Copywriter generates "AI: Your new productivity superpower." The Manager Agent immediately flags this. The status changes to Rejected by Manager citing the reliance on the overused "superpower" cliché. - Phase 3: The Feedback Loop (00:13)
The rejection triggers a state transition. A "Learning Context" alert appears. The Copywriter receives the critique as a negative constraint for the next prompt. - Phase 4: Course Correction (00:18)
The Copywriter generates a refined slogan: "AI: Productivity, reimagined." The Manager evaluates this, finds no clichés, and stamps the proposal as Valid. - Phase 5: Deep Think & Consensus (00:28)
The Director Agent (Head of Marketing) begins evaluating. The UI shows a deliberate "Evaluating..." pause representing the Reasoning Model's (Gemini 3 Pro) thinking budget, where it checks for deeper strategic alignment beyond just surface-level grammar.
Technical Observations
State Machine Reliability: The video shows the UI locking and unlocking specific cards based on the state (Drafting vs. Reviewing). This visualizes the Rust enum safety—the Director cannot approve until the Manager has signed off.
Latency as a Feature: The delay during the Director's phase is a UX feature, not a bug. It signals that a more expensive, compute-heavy model is performing a final safety/strategy check.
Deep Dive: Governance as Code
In the context of AI Orchestration, 'Governance' is often a manual process or a set of loose guidelines. Here, we bake it into the code. By using Rust's Algebraic Data Types (enums), we make invalid orchestration states mathematically impossible.
// The Compiler guarantees that a Campaign cannot exist
// without first passing through the approval chain.
pub enum WorkflowState {
Idle,
Drafting(String), // Only raw text exists
Reviewing(Draft), // Text has become a 'Draft' type
Thinking(CritiqueContext),// Director is reasoning
Approved(FinalCampaign), // Final state
Rejected(Feedback) // Loop back
}- Benefit: An agent cannot accidentally 'skip' the Director's review because the
Approvedvariant requires data that is only produced by the Director'sapprove()function. - Auditability: Every state transition is recorded in a type-safe vector, creating an immutable audit log of the decision process.
Pro Tip
Zero-Cost Abstractions: These complex safety checks compile down to the same efficient machine code as if you wrote the logic by hand, adding no runtime overhead.
System Architecture & Structure

The project follows a clean separation of concerns, isolating the API bindings, the UI components, and the core state machine logic.
├── src/
│ ├── api/
│ │ ├── mod.rs # Provider Factory
│ │ ├── gemini.rs # Google Gemini bindings
│ │ ├── openai.rs # OpenAI GPT bindings
│ │ └── anthropic.rs # Anthropic Claude bindings
│ ├── components/
│ │ ├── agent_card.rs # Agent UI Component
│ │ ├── history_log.rs # Event Logger
│ │ └── dashboard.rs # Metrics Display
│ └── models/
│ ├── state.rs # State Machine Enums
│ └── agents.rs # Agent Logic & TraitsThe "Thinking" Director Agent
The Director is not just a prompt; it is a configurable reasoning agent. It acts as a deterministic guardrail, ensuring no content reaches the final state without passing specific criteria.
- Reasoning Telemetry: The system exposes the Director's hidden chain-of-thought (CoT). This 'Glass Box' approach allows auditors to verify why a campaign was approved or rejected, moving beyond 'Black Box' AI.
- Iterative Feedback Loop: Rejection logic is handled via
Result<Approved, Rejected>types. Feedback is propagated back to the Copywriter via a mutable history vector for refinement.

Reactive Performance with Leptos
The frontend utilizes Leptos, a modern Rust web framework that leverages fine-grained reactivity (Signals). Unlike React's Virtual DOM, Signals allow the application to surgically update only the specific text or numbers that change (like the Iteration Count) without re-rendering the entire component tree. This results in exceptional performance, especially when handling high-frequency updates from AI streams.
Trustworthy AI Security Layer
We implement a multi-layered security approach following the Trustworthy AI Lifecycle, ensuring the system is lawful, ethical, and robust from design to deployment.
- Design Phase (Formal Verification): We use Rust's type system to formally specify allowable agent behaviors, preventing 'Prompt Injection' attacks from altering the application flow.
- Development Phase (Safety): Rust’s ownership model guarantees memory safety without a garbage collector, eliminating classes of vulnerabilities like buffer overflows.
- Deployment Phase (Privacy): The entire orchestration logic runs inside the browser's WebAssembly sandbox, creating a secure boundary between the AI logic and the host OS.
Model Agnostic Architecture
The system uses the Strategy Pattern to define agent interactions. This means the business logic (the 'Agent') doesn't care which AI model answers the prompt. By using Rust Traits, we can swap Gemini 1.5 Pro for Claude 3.5 Sonnet at compile time or runtime without rewriting behavior.
#[async_trait]
trait LlmProvider {
async fn complete(&self, prompt: &str) -> Result;
}
// Implementations for specific vendors
impl LlmProvider for GeminiClient { ... }
impl LlmProvider for OpenAIClient { ... }
impl LlmProvider for AnthropicClient { ... } Tech Stack
Rust
Edition 2021. Used for core logic, type safety, and zero-cost abstractions.
Leptos
A modern, high-performance web framework for Rust that leverages fine-grained reactivity (Signals).
WebAssembly
Compiling Rust to WASM allows the app to run natively in the browser with near-native performance.
Gemini API
Primary reasoning engine for the Director agent.


