Mar 7, 2025
/
livestream
Refactoring Rails AI With Active Agent on thoughtbot (Live Coding)
Yesterday, I joined thoughtbot’s AI in Focus livestream to put Active Agent to the test in a real-world Rails project.
Hosted by thoughtbot CEO Chad Pytel, the episode focused on refactoring an existing retrieval-augmented generation (RAG) system—one that allows users to query internal documentation—using Active Agent instead of a custom-built AI integration.
Why Use Active Agent?
Active Agent is an open source framework designed to simplify AI-powered workflows in Rails applications. Instead of writing scattered AI logic across controllers, services, and background jobs, Active Agent allows you to define AI agents like Rails controllers, handling prompts, responses, and function calls in a structured way.
The livestream aimed to demonstrate how Active Agent can replace manual prompt engineering and API handling with a Rails-friendly abstraction.
Live Coding Recap
Chad and I worked through migrating a Rails application that already implemented a RAG system, fetching relevant documentation using Elasticsearch and passing it to an LLM for question-answering.
What We Achieved:
✅ Installed Active Agent and set up an AI agent
✅ Defined a QuestionAgent that could handle user queries
✅ Integrated it into the controller, replacing the existing custom prompt logic
✅ Explored function calling and contextual retrieval
✅ Debugged a Rails controller issue that caused unexpected behavior
Watch the Recording:
Highlights:
🔹 Live troubleshooting – The session gave a real-world look at debugging and integrating AI into a production Rails app.
🔹 Showcasing Active Agent’s Rails-native approach – We refactored a complex AI workflow into a cleaner, more maintainable Rails agent.
🔹 Community participation – Viewers asked great questions about function calling, AI workflows, and best practices.
Lessons Learned/Takeaways:
While the session highlighted the benefits of Active Agent, we also encountered a Rails-specific controller issue that didn’t appear when running the same code in the Rails console. This was a reminder that Rails controllers have their own context, and future integrations should account for potential method conflicts.
For future streams, I'll start with a pre-built demo to show the end result, then dive into live coding. (Unfortunately, I wasn't able to show the pre-built demo I had prepared due to issues with screen sharing on the stream.)
What’s Next for Active Agent?
I am currently working on a new release to address some of the issues we encountered in the livestream, ensuring even better integration with Rails controllers.
Beyond that, I’m moving quickly to expand the robust features of Active Agent. Sign up for my newsletter, join the Active Agent Discord, or follow me on social for updates! And if you’re using Active Agent, I’d love to hear your feedback. (PRs & issues are also welcome.)
Get Involved
Here’s how you can connect with me or get involved with Active Agent…
🛠️ Try it out (and open issues or submit a PR)
💬 Join the Active Agent Discord
✨ Hire me to work on your AI project (10% off contracts signed Feb-March 2025)
📩 Email me at justin@activeagents.ai or schedule a call