active_agent 🤖
The Native Multi-Agent AI Framework for Ruby & Rails.
Inspired by Python's CrewAI and Microsoft AutoGen, active_agent provides a clean, idiomatic Ruby DSL to orchestrate teams of autonomous AI agents with roles, backstories, tools, tasks, and multi-provider LLMs.
Key Features 🚀
- 👥 Autonomous Agent Teams: Define specialized personas (
Agent) with goals, backstories, and assigned capabilities. - 🛠️ Custom Executable Tools: Agents dynamically select and execute custom Ruby tools (
ActiveAgent::Tool) to perform real-world tasks (Web Search, Database Queries, API calls). - 📋 Task Orchestration: Assign discrete objectives (
Task) with expected outputs and context passing across workflow steps. - 🌐 Multi-Provider LLM Adapters: Built-in support for OpenAI (
gpt-4o), Anthropic Claude (claude-3-5-sonnet), Google Gemini (gemini-1.5-flash), and Ollama (Local AI). - ⚡ Sequential & Parallel Processes: Run agent teams in sequential pipelines where outputs pass from step to step.
Installation
Add this line to your application's Gemfile:
gem 'active_agent_ai'
And then execute:
bundle install
Quickstart Example
Define tools, agents, tasks, and kick off your agent team in 100% native Ruby:
require 'active_agent'
# 1. Define a Custom Executable Tool
class WebSearchTool < ActiveAgent::Tool
description "Searches the web for latest software benchmarks and language features"
param :query, type: :string, desc: "Search query", required: true
def perform(query:)
# Execute actual search or API call here
"Ruby 3.4 introduces Prism parser by default and 20% YJIT performance gains."
end
end
# 2. Define Specialized AI Agents
researcher = ActiveAgent::Agent.new(
role: "Senior Tech Researcher",
goal: "Find cutting-edge developments in Ruby & Rails",
backstory: "An expert language analyst with 10 years of compiler and AST experience.",
tools: [WebSearchTool],
provider: :openai # or :claude, :gemini, :ollama
)
writer = ActiveAgent::Agent.new(
role: "Technical Journalist",
goal: "Draft engaging tech articles from technical research reports",
backstory: "A skilled writer capable of explaining complex software benchmarks simply.",
provider: :openai
)
# 3. Define Tasks
research_task = ActiveAgent::Task.new(
description: "Research Ruby 3.4 JIT benchmarks and Prism parser updates",
expected_output: "Detailed technical report with benchmarks",
agent: researcher
)
write_task = ActiveAgent::Task.new(
description: "Write a high-converting blog post based on the research findings",
expected_output: "Formatted Markdown article ready for publication",
agent: writer
)
# 4. Assemble and Kickoff Team
team = ActiveAgent::Team.new(
agents: [researcher, writer],
tasks: [research_task, write_task],
process: :sequential
)
result = team.kickoff
puts result
Multi-Provider Support
active_agent seamlessly works with all top LLM providers:
# OpenAI
agent = ActiveAgent::Agent.new(role: "Coder", goal: "Refactor", provider: :openai, model: "gpt-4o")
# Anthropic Claude
agent = ActiveAgent::Agent.new(role: "Analyst", goal: "Audit", provider: :claude, model: "claude-3-5-sonnet-20241022")
# Google Gemini
agent = ActiveAgent::Agent.new(role: "Data Engine", goal: "Parse", provider: :gemini, model: "gemini-1.5-flash")
# Ollama (100% Local AI - No API keys needed)
agent = ActiveAgent::Agent.new(role: "Local Assistant", goal: "Summarize", provider: :ollama, model: "llama3")
License
MIT License.