RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Omakase 0.2 — agents as plain Ruby objects

I released Omakase 0.2, a small agent framework on top of RubyLLM about 800 lines. The idea is that an agent is an ordinary Ruby object: its fields are state, its public methods are what the model can call (no tool registry, no JSON schemas to keep in sync - describe above a method is the description the model reads), and the methods you declare without a body are written by the model at runtime. The return type is the contract: a schema block gives you validated data, a scalar unwraps to a value, and a Ruby class means the method hands back the object your code built - under the default :code_act strategy the model answers by writing Ruby that is evaluated on the agent itself and calling finish(value), so the answer is computed rather than retyped as JSON. There’s also :predict for one-shot structured output, MCP servers and SKILL.md directories that arrive as methods, per-method model selection, attachments, and a FakeChat so agents can be tested without a network. The transcripts in the README are from a 30B model on OpenRouter rather than a frontier one, on the theory that a strategy which only works on the biggest model available is a demo and not a library. The docs cover the Rails side - agents in app/agents, jobs, multi-turn built from your own tables - and are blunt about the fact that generated code runs with instance_eval, so untrusted input belongs to :predict unless you swap in your own executor. MIT, Ruby 3.2+.

```ruby class RefundAgent < ApplicationAgent describe “Every order this customer placed, newest first” def orders_for(email) = Order.where(email:).order(placed_on: :desc)

generates :decide, "Decide this refund, and name the policy you applied.", returns: Refund   end ```

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in