activeagents/activeagent

ActiveAgent Rails framework for Agent Apps

Active Agent – AI‑first framework for Ruby on Rails

What it is – A Ruby gem that adds an agent‑oriented layer on top of Rails. Agents are treated like controllers, letting you write modular, reusable AI‑powered components using the same Ruby/Rails conventions you already know.

Why it matters – It bridges the gap between traditional web development and generative AI. By turning prompts, tool calls, and context handling into first‑class Rails objects, developers can embed LLM‑driven features (chat, extraction, translation, etc.) without leaving the Rails ecosystem.


Quick start (from the README)

  1. Add the gem
    bundle add activeagent   # core framework
    # pick one or more LLM providers
    bundle add openai        # or anthropic, ollama, deepseek, ruby_llm …
    
  2. Run the installer – generates config files and a base agent class:
    rails generate active_agent:install
    
  3. Define an agent
    class ApplicationAgent < ActiveAgent::Base
      generate_with :openai, model: "gpt-4o-mini"
    end
    
    response = ApplicationAgent.prompt(message: "Hello, world!").generate_now
    puts response.message   # => "Hello! How can I help you today?"
    
  4. Create a custom agent
    rails generate active_agent:agent TravelAgent search book confirm
    
    Then implement actions (search, book, confirm) that call prompt.

Core features (as listed in the README)

  • Agent‑oriented programming – agents behave like Rails controllers, fitting naturally into MVC.
  • Multi‑provider support – OpenAI, Anthropic, Ollama, DeepSeek, RubyLLM, and any OpenAI‑compatible API.
  • Action‑based design – each public method on an agent is an action that can be invoked and traced.
  • Prompt templating – ERB view templates for text, JSON, or HTML prompts.
  • Streaming – real‑time response via ActionCable.
  • Tool / function calling – agents can invoke external services (e.g., fetch a cat image) and incorporate results.
  • Delegation – hand sub‑tasks to other agents with budget/timeout contracts.
  • Context management – automatic conversation history handling.
  • Structured output – JSON‑schema validation for predictable responses.
  • Telemetry & dashboard – optional actionagent gem provides a Rails engine with traces, token usage, cost estimates, and a UI at /activeagents.

Example use‑cases from the README

Use case Code snippet What it does
Data extraction DataExtractionAgent.with(image_path: …).parse_content.generate_now Pull structured data from images, PDFs, or raw text.
Translation TranslationAgent.with(message: "Hi, I'm Justin", locale: "japanese").translate.generate_now Translate a string into another language.
Tool usage SupportAgent.prompt(message: "Show me a cat").generate_now Agent calls a tool (e.g., image search) and returns the result.
Delegation See the SummarizerAgent / ResearchAgent example – a research agent delegates summarisation to a sub‑agent with a cost/latency budget.

Installation & ecosystem

  • Core gem – activeagent (contains the framework, providers, generation, telemetry).
  • Dashboard gem – actionagent (mountable engine for monitoring, runs on its own ActiveRecord models; optional).
  • Provider gems – you install the LLM client you need (openai, anthropic, etc.) and configure them in config/active_agent.yml.
  • Ruby version – ≥ 3.1; Rails 7.2, 8.0, 8.1 supported.

Documentation & community

  • Official docs: https://docs.activeagents.ai
  • Getting‑started guide, API reference, and example agents are all hosted there.
  • Contributions are welcomed via the usual GitHub workflow (see CONTRIBUTING.MD).
  • Licensed under MIT.

TL;DR

Active Agent lets Rails developers treat LLM‑driven functionality as first‑class agents, using familiar generators, controllers‑style actions, and a built‑in dashboard for observability. Install the gem, pick a provider, generate an agent, and you can start prompting, streaming, calling tools, and delegating work—all inside a standard Rails app.

Related

  • Project
  • Project
  • Project
  • Project
  • Project