Asia/Kolkata
Blog
August 19, 20256 min read

Can You Build AI Agents in Rust? Yep, and Here's How I Did It

Rohith Singh
Can You Build AI Agents in Rust? Yep, and Here's How I Did It
Everyone's building AI agents these days, and everyone's teaching you how to do it in Python or JavaScript. Nothing wrong with Python. It's fast to prototype with and has a mature ecosystem. But I wanted to try something different. What if we could build a multi-agent system that orchestrates different specialised agents, each connected to real-world tools via MCP (Model Context Protocol), and what if we built it in Rust? That's exactly why I built Codepilot, a multi-agent system that can handle Linear project management, GitHub repository operations, and Supabase tasks, all through a terminal UI. It's a fun side project, and if you're curious and want to try things with Rust, maybe you'll find this useful. The source code is available on my GitHub here: rohittcodes/codepilot. Traditional AI agents are great, but they often struggle when you need to handle multiple domains or complex workflows. What if you want to:
  • Create a GitHub issue and link it to a Linear project.
  • Query your Supabase database and create a summary report.
  • Manage repositories across different services.
A multi-agent system solves this by having specialized agents that can collaborate and orchestrate complex workflows. Rust isn't the usual go-to for AI, but it has some clear benefits:
  • Performance: zero-cost abstractions and memory safety mean your agent runs fast without eating resources.
  • Type safety: errors can be caught at compile time, not when your agent's halfway through a task.
  • Ecosystem potential: although the AI ecosystem is more mature in Python, Rust's async/await model and strict typing make it a good fit for agents juggling multiple tools, APIs, or tasks.
An AI agent is a program that can understand your intent and take actions on your behalf. Think of it as an assistant that doesn't just chat, it does things. In this case, the agent understands when you're asking about Linear issues, GitHub repositories, or Supabase data, and then calls the appropriate APIs to retrieve the information, combining it with natural language responses. One key insight: LLMs excel at understanding intent, but struggle to access real-time information. By combining LLMs with APIs, you get a program that automates tasks for you, natural language understanding plus real-time information access. Just a plain Rust binary project, a few crates to make async work easier, and enough structure to plug in the tools. Add these dependencies to Cargo.toml: The core idea: a multi-agent system with specialized agents, each with tools the LLM can call, then the LLM decides which agent to use based on the user's query. To connect each agent with real-world APIs, I used Composio MCP integration. These servers expose authenticated API actions your agents can call, without you having to handwrite integrations. For Codepilot, I set up MCP servers for:
  • GitHub: repos, issues, PRs.
  • Linear: project and issue management.
  • Supabase: querying and updating data.
The core architecture is built around three principles:
  1. Specialized agents: each agent (Linear, GitHub, Supabase) is an expert in its domain.
  2. MCP integration: all agents connect to MCP tools via Composio.
  3. Intelligent orchestration: a central orchestrator routes queries to the right agent.
Each agent discovers its tools dynamically from MCP servers: This means no hardcoded operations, the agents automatically adapt to whatever tools are available on their MCP servers. The system uses pure LLM-based tool selection with intelligent fallbacks. When you ask a question: To prevent the LLM from calling internal tools, each agent runs with a constrained configuration: When you ask "List all my GitHub repositories", the system:
  1. Orchestrator LLM → "USE_GITHUB_AGENT"
  2. GitHub Agent LLM → "I would use GITHUB_LIST_REPOSITORIES to fetch your repositories."
  3. Tool execution → executes GITHUB_LIST_REPOSITORIES with proper arguments.
  4. Result → LLM reasoning plus the GitHub operation result.
This was a fun project to work on, given the usual Python-heavy agent world. Rust isn't traditionally the go-to for these AI workflows, but it's surprisingly capable at handling real-world agent logic once you get past the initial setup. The type system gives you confidence, async works well enough, and once the tools are in place, everything is straightforward to plug together. Not production-ready yet, but as a weekend project to learn things, it's worth trying. The complete source code is here: rohittcodes/codepilot.
Share this post:

Subscribe to my newsletter

Thoughts on AI, backend systems, and building things that matter