AI agents: autonomous
This course builds AI agents in Ruby against the Claude API, without a framework. It defines an agent as a loop where the model chooses the next step and your code runs the requested tools. Lessons cover writing that loop by hand, branching on stop_reason, and designing tool descriptions and schemas. They also cover the Ruby SDK tool runner, approval gates, budgets and prompt injection, plus context editing, compaction and memory for long runs. The final lesson assembles an agent as Rails objects with recorded steps and tests.
What you'll learn
- ✓Telling a single call, a workflow and an agent apart
- ✓Writing the agentic loop by hand and branching on stop_reason
- ✓Designing tool descriptions, schemas and result sizes
- ✓Gating irreversible actions and limiting the reach of prompt injection
- ✓Managing long runs with caching, context editing, compaction and memory
- ✓Recording, testing and evaluating agent runs in Rails
What makes a system an agent
Everything in the previous four courses had the same shape: you decide what happens, and the model fills in one step. You retrieve chunks, build a prompt, make one call, parse the answer. The control flow is yours.
Read the full lesson free →Curriculum
7 lessonsWhat makes a system an agent
Defines an agent as a loop where the model picks each step, and when a workflow fits better.
The agentic loop, by hand
Writes the agentic loop by hand in Ruby, covering stop_reason, tool_use_id matching, errors as results and iteration limits.
Designing the tool surface
Shows how to write tool descriptions that say when to call, choose tool breadth and trim results.
The tool runner, and your own loop
Uses the Ruby SDK tool runner, adds approval gates inside tools, and explains when a manual loop fits.
Gates, budgets, and injection
Covers prompt injection through tool results, authorization in handlers, gates by reversibility and budgets for iterations, tokens and time.
Long runs: context, memory, and cost
Explains why long runs grow costly and how caching, context editing, compaction and memory manage the conversation.
Putting it together: an agent in Rails
Assembles an agent as Rails objects with a background job, recorded steps, layered tests and trajectory evaluation.