Most AI agent tutorials assume Python and a greenfield repo. Most real businesses run on a mature app with users, data, and revenue, and a lot of them run on Ruby on Rails. The good news: Rails is an excellent place to ship production AI agents, precisely because agents in production are less about the model and more about the boring, reliable machinery Rails already gives you.
A production AI agent is mostly the parts around the model: background jobs to run long tool calls, a database to hold state and results, retries and idempotency, access control, and an audit trail of what the agent did and why. Rails ships all of that out of the box, ActiveJob, ActiveRecord, strong conventions, so you spend your time on the agent logic, not the plumbing. The model call is a small piece in the middle of a system Rails is already built to run reliably.
| Pattern | Why it matters in production |
|---|---|
| Tools as plain Ruby objects | Each tool is a testable service object with clear inputs and outputs, not a prompt trick. |
| Agent runs in a background job | Long, looping tool calls belong in ActiveJob, not a web request, with retries and timeouts. |
| State in the database | Persist each step so a failed run can resume, and so you can see what the agent decided. |
| A human gate on the hard case | When confidence is low or a lookup fails, stop and ask a person. Decide that case on purpose. |
| Climb only as high as needed | Most tasks are a chain or a workflow. Reach for a full agent only when the path is genuinely unspecifiable. |
The demo is the easy part. Production means the agent reads your real data through the models you already have, writes back through the same validations your app enforces, runs under monitoring and cost controls, and has an owner. That is an engineering job inside your codebase, not a proof of concept bolted on the side, and it is exactly the kind of work a forward deployed engineer does. When you decide whether a workflow even warrants an agent, the discipline is the same one from agentic AI, explained from production: reach for the loop only when the task demands it.
The full method is in Building AI Agents with Rails: ship production AI agents on Ruby on Rails, part of the Density Labs AI Series. Need senior Rails and AI engineers who ship? We forward deploy them, and we place pre-vetted engineers through PreVetted.