As a non-rubyist who nevertheless understands Ruby, and has a keen interest in cross-provider LLM frameworks / abstractions, chat.rb is the most beautiful implementation of the agentic tool-calling loop I've ever seen.
People point at pi-agent (Typescript) as a good one, but I find the Ruby version far more elegant, far more concise, and generally easier to read.
I think it could be simplified further at the cost of making the API a bit uglier — and perhaps an educational fork should be — but it's still really good.