Content Hub

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.

Start here

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

Run the loop

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