Paolino iconPaolinoAug 28, 2026 ~4 min source read

RubyLLM 2.0: The Agentic Loop, Exposed

RubyLLM 2.0 breaks the sealed agent loop from 1.x into explicit Ruby verbs so you can control model calls, tool execution, persistence, batching, cancellation, and resumable runs.

RubyLLM 2.0: The Agentic Loop, Exposed

Share this story

Send the public story page.

Useful takeaways from this story.

RubyLLM 2.0 exposes the agentic loop as explicit verbs (ask_later, generate, run_tools, step, complete?), letting you control each model/tool round.

Each agent turn can be one job: persist messages, run a single step per job, and resume safely after restarts or failures.

# What this change is

# The verbs you get

  • ask: unchanged convenience that runs the full conversation to completion.
  • ask_later: stage a user message without sending it.
  • step: perform whichever move is next (run tools if any are unanswered, otherwise generate).
  • complete?: check whether the conversation is settled (the model answered without calling a tool).

These verbs compose: ask is ask_later followed by complete (or repeated step calls). That decomposition is purposeful: it gives you hooks between model and tool rounds for batching, human approval, logging, or persistence.

# Why you'd use this

  • Fine-grained control over iteration budgets and the number of model calls.
  • Insert human review before tools run.
  • Batch generation for many chats at once, then run tools locally between rounds.
  • Persist conversation state and resume runs across processes or deploys.

# One move per job: reliable, resumable runs Because each verb reads and writes persisted messages, you can implement an agent as a chain of jobs where each job performs a single turn. Example pattern: schedule an AgentTurnJob that loads the chat, calls chat.step, and enqueues itself again unless chat.complete?. Benefits:

  • Granular retries when a job fails.
  • Workers are not monopolized by long runs.
  • If a run dies mid-tool-round, run_tools skips tool calls that already have results so remaining tools complete on resume.

If you use Rails 8.1 ActiveJob Continuations, you can checkpoint after each move and survive redeploys without managing an external cursor.

# Cancellation and stopping

break if handed_off? # your own stop condition

If you instead want exactly one tool call per model response, use chat.with_tool_options(calls::one). For total budget control, count your step or generate calls in the loop you control.

# Practical patterns

  • Resumable agent: persist messages, run one step per job, re-enqueue unless complete.
  • Batching: schedule generate for many chats, then run_tools locally between rounds to keep external calls efficient.
  • Human-in-the-loop: ask_later, show proposed tool calls to a reviewer, run_tools only after approval.

RubyLLM 2.0 turns the agentic loop into explicit, testable, and resumable Ruby code so you can integrate it into job queues, web controllers, and multi-process systems without hidden control flow.

More context around this story.

Rubyflow iconRubyflowAug 14, 2026

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),

RubyLLM 2.0: Providers, Protocols, and Provider Gems
Paolino iconPaolinoAug 27, 2026

RubyLLM 2.0: Providers, Protocols, and Provider Gems

Originally appeared on Carmine Paolino . RubyLLM 2.0 is almost ready. It isn’t out yet, but it will be soon, and I have been looking forward to showing you what is in it. There is a lot in this release. Too much for one enormous announcement, and most of it deserves more than a bullet point. So this is the first in a s

what actually makes a system agentic?
Dev iconDevAug 8, 2026

what actually makes a system agentic?

LLM + Tools ≠ Agent I used to think an AI agent was simply: LLM + tools = Agent After exploring agentic system design, I’m starting to see it differently. The LLM is only one component. The real engineering challenge is designing the execution loop around it. A basic LLM application looks like: "Input → LLM → Response"

Rubyflow iconRubyflowAug 26, 2026

llm.rb v15.1.0 released

llm.rb is an advanced runtime for building agentic AI applications on CRuby. It has zero runtime dependencies by default, supports concurrent and parallel tool execution and has a single coherent API that spans 14+ providers.

Agentic RAG: Basic RAG Plus MCP Tool Calls
Dzone iconDzoneAug 4, 2026

Agentic RAG: Basic RAG Plus MCP Tool Calls

That second question isn't a retrieval problem — it's a computation problem that depends on live, structured, user-specific data. This is exactly the gap agentic RAG closes: it keeps the semantic search RAG is good at, and bolts on tool calls (via MCP) so the agent can reach into live systems, fetch real numbers, and r

Loading more related stories...

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app