Rails AI Agents: Tools, Approvals, and Background Jobs
Guides for building AI agent workflows in Ruby and Rails, written for developers wiring Claude or Gemini into an app that already has users, jobs, and a database. If the steps are predictable, use a workflow instead. Reach for an agent when the model has to choose the next step from intermediate results.
NEED CLAUDE IN RAILS
Start with the Anthropic walkthrough when you need the full loop: tools, approvals, background jobs, streaming, and tests.
ONLY NEED SDK SETUP
Use the Anthropic Ruby SDK reference for client setup, messages, streaming, tools, retries, and when another gem fits better.
NO RUBY SDK
Use the Gemini guide when the provider boundary is plain HTTP and your app owns request shapes, parsing, streaming, and retries.
Rails AI Agents with the Anthropic SDK
The Rails shape: agent loop, tool classes, streaming, MCP, authorization, approval gating, and tests.
Choose the client boundary
Anthropic Ruby SDK Reference
The official anthropic gem, not the renamed ruby-anthropic: client lifecycle, messages, streaming, tools, retries, and when another gem fits better.
Anthropic Ruby SDK vs ruby_llm
The official typed SDK against the multi-provider framework: feature coverage, real gaps, and when each wins.
Claude Agent SDK in Ruby
There is no official Ruby Agent SDK. The three real paths compared, with a working agent loop on the anthropic gem.
Claude Code for Rails
Set up Claude Code in a Rails project: CLAUDE.md, allowed commands, denied files, Skills, hooks, MCP, and editor diagnostics.
Ruby MCP Servers
Build a Model Context Protocol server in Ruby, expose Rails data as tools, and connect it to Claude.
Run the loop
Gemini API in Ruby Without an SDK
Faraday transport, Interactions API state, function calls, background execution, streaming, and parser fixtures.
Running AI Agents with Solid Queue
Queue isolation, worker throttling, resumable runs, human-in-the-loop pauses, and per-account cost tracking.
Recurring Agent Work
How Solid Queue recurring jobs affect polling agents, scheduled inference, and at-least-once execution safety.
Expose tools
Building an AI workflow inside Rails?
With agents, calling the model is the small part; the real work is deciding where the agent is allowed to read, write, retry, and stop. Map that permission boundary across your tools and tenant scope first, and the SDK choice, tool design, and execution hardening follow from it.
View AI agent services