Agents and agent coordination in Ruby.

LittleGhost is a Ruby library for building AI features. Its agents answer questions and call your application code. Start with one agent, then bring several together when the task needs a team.

$ bundle add little_ghostRuby 3.3+
Docs → For coding agents →

Your first agent

After installing the gem, set OPENROUTER_API_KEY to a key from your OpenRouter account. This example sends your question to an AI model through that service. Getting Started walks through the setup.

customer_support_agent.rb ghost recording
require "little_ghost"
class CustomerSupportAgent < LittleGhost::Agent
model "openrouter:openai/gpt-5.6-luna"
system_prompt "Answer customer questions clearly and concisely."
end
run = CustomerSupportAgent.ask("Can you help with my order?")
puts run.response
under the hood
customer question I'm preparing a clear answer!CustomerSupportAgent clear answer
terminal
$ ruby customer_support_agent.rb
Hi! Tell me what happened, and I'll help you find the next step.

Grow your agent team

A Graph lays out a task as named steps (node) and routes between them (edge). Here, research and logistics run in parallel after planning; the writer combines both results. The Agent definitions are omitted so you can focus on how they work together.

book_club_launch_graph.rb ghost recording
class BookClubLaunchGraph < LittleGhost::Graph
# Agent classes live elsewhere in the application.
node :plan, PlannerAgent
node :research, ResearchAgent
node :logistics, LogisticsAgent
node :write, WriterAgent
start :plan
edge :plan, :research
edge :plan, :logistics
edge :research, :write
edge :logistics, :write
finish :write
end
run = BookClubLaunchGraph.ask("Launch a neighborhood book club")
puts run.response
under the hood
book club idea I'm splitting up the work!plan I'm choosing a book!research I'm planning the meetup!logistics I'm writing the plan!write launch plan
terminal
$ bundle exec ruby app.rb
Meet at the library next Thursday. Start with Why's Poignant Guide to Ruby, and invite neighbors through one shared signup page.

Batteries included

Tools

Ruby classes connect agents to application capabilities through declared inputs and ordinary method calls.

Agent coordination

Use Ruby-directed workflows and graphs, model-directed subagents and swarms, or compose both.

Configurable sandboxes

Choose where child processes run and which files and network connections they can access. The native backend enforces those restrictions with Seatbelt on macOS or Bubblewrap on Linux.

Provider support

Use OpenRouter, OpenAI-compatible APIs, Anthropic, Gemini, Vertex AI, or Bedrock behind the same interface.

Streaming & outputs

Display answers as they are written and follow tool activity. Read the completed answer as text or data checked against a shape you define.

Sessions & supervision

Save conversations between requests, set deadlines, cancel work, and inspect what happened during each request.