Skip to main content

Upgrading Nexo to a New Version

Upgrading Nexo from 0.12 to 0.17: the move to ruby_llm 2.2, new file tools, hyphenated skill names, three security fixes, stricter defaults, and each change to make in your code.

What breaks between releases, and what to do about it.


0.12.0 → 0.17.0

Six releases shipped between 0.12.0 and 0.17.0: 0.13.0, 0.14.0, 0.15.0, 0.16.0, 0.16.1 and 0.17.0. This guide takes you from 0.12.0 straight to 0.17.0 and covers all six. If you are already on a release in between, the sections still apply: skip the ones you have done.

  • 0.13.0 moved Nexo to ruby_llm 2.2 (~> 2.2.0, verified against 2.2.3). ruby_llm 1.x is no longer supported: that line ended at 1.16.0 and carries denial-of-service advisories that are fixed only in 2.0.
  • 0.14.0 fixed three guarantees the documentation made and the code did not keep: the local shell’s environment, shell timeouts, and approvals.
  • 0.15.0 added pieces of ruby_llm 2.2 behind Nexo’s permission gate, and a cap on tool calls per round.
  • 0.16.0 removed what ruby_llm now provides. Nexo’s own file tools are gone and ruby_llm’s take their place, a tool you did not declare is refused by default, and approvals run on ruby_llm’s mechanism.
  • 0.16.1 made two workflow methods public. It changes nothing for existing code.
  • 0.17.0 made a resume carry the paused conversation on instead of asking the model again, and moved skill parsing to ruby_llm’s parser, which requires hyphenated skill names.

This upgrade breaks your Gemfile, any RubyLLM::Tool you wrote yourself, and any skill, prompt or event consumer that names Nexo’s old file tools. The rest of the Nexo API you call — mcp, mcp_allow, skills, Nexo::Skills.find, Nexo::Session, workflows — is unchanged.

# Gemfile
gem "nexo_ai", "~> 0.17"
# Remove these two lines if you have them:
# gem "ruby_llm-mcp"
# gem "ruby_llm-skills"
bundle update nexo_ai ruby_llm

Work through the seventeen sections below in order. The first three stop your app from booting until they are done, and section 14 lists options that now raise. Sections 8 to 13, 16 and 17 change behaviour without raising, so read them even if your app boots and its tests pass.

1. Remove ruby_llm-mcp and ruby_llm-skills

Both gems pin ruby_llm 1.x, so Bundler cannot resolve them next to Nexo 0.13 or later. ruby_llm-mcp also defines the same RubyLLM::MCP constant that ruby_llm 2.x now ships itself, so the two can never be loaded together.

Nothing replaces them in your Gemfile. MCP comes with ruby_llm, and Nexo reads SKILL.md packages itself.

Check your transitive dependencies. Removing a gem also removes everything it pulled in. If your code calls require "bigdecimal", require "httpx", or a JSON Schema library without declaring it, it worked only because ruby_llm-mcp depended on it. Declare it yourself:

gem "bigdecimal"

2. Rename param and desc: in your own tools

ruby_llm 2.0 removed the old tool DSL names. A tool that still uses them raises NoMethodError when its class loads.

Before After
param :path, desc: "..." parameter :path, description: "..."
params do ... end parameters do ... end
class LookupOrder < RubyLLM::Tool
  description "Look up an order by id"
  parameter :order_id, type: :string, required: true, description: "The order id"

  def execute(order_id:)
    Order.find_by(id: order_id)&.attributes || {error: "order #{order_id} not found"}
  end
end

Nexo’s built-in tools are already renamed. Tool names the model sees do not change.

3. Tool wrappers must accept keywords

ruby_llm 2.x calls every tool with keywords: tool.call(**arguments). Under 1.16 it passed one positional Hash. If you wrap MCP tools through wrap_mcp_tool, update the wrapper:

# Before
def call(args = {})
  cap(@tool.call(args))
end

# After
def call(**arguments)
  cap(@tool.call(**arguments))
end

The schema reader was renamed too: params_schema is now parameters_schema.

An MCP tool returns a RubyLLM::MCP::Result, not a String. Read its text with result.text. Calling to_s on it gives an object address, so a wrapper that measures or cuts result.to_s silently does nothing.

If you overrode the private apply_mcp, move that code to the public wrap_mcp_tool hook. chat.tools is now rebuilt on every call, so mutating it with transform_values! silently does nothing.

4. max_turns is now a hard cap

Agent#prompt, Session#prompt, and Workflow#run_agent all take max_turns: (default 25). Until 0.12 it was telemetry: a run that passed it kept going. It now caps tool rounds, the number of model responses that ask for tools within one prompt.

When a prompt uses up its rounds, RubyLLM::ToolRoundLimitError is raised instead of the model being asked again. Inside a workflow that fails the run.

  • A run that used to pass its number now stops. Raise max_turns for runs that legitimately need more rounds.
  • max_turns: nil runs uncapped. Use it only for trusted workloads.
  • The :turn_limit_exceeded event is gone (removed in 0.16). Rescue the error instead.
begin
  agent.prompt("Triage the inbox", max_turns: 30)
rescue RubyLLM::ToolRoundLimitError
  # the run used its 30 rounds
end

A second run over a working directory that still holds the last run’s files costs extra rounds, because the write tools make the model read a file before changing it. Size budgets for that case.

5. Loops::AgentSDK is removed

Nexo::Loops::AgentSDK, Agent#permission_mode, and Agent#allowed_tools are gone. The ruby_llm-agent_sdk gem that loop wrapped was never published, so it never ran against real code. Its one purpose, a hard turn cap, is what max_turns now does on the default loop.

Remove any loop: Nexo::Loops::AgentSDK.new argument. Nexo::Loop remains as the seam for a loop of your own.

6. MCP servers: three behaviour changes

The mcp macro and mcp_allow work as before. Three behaviours are inherited from ruby_llm’s own MCP client:

  • A callable token: is read again for every request. A rotated token is picked up without agent.close and a reconnect.
  • A :stdio server starts with a short, safe environment. It inherits PATH, HOME, LANG, and a few more variables, not your application’s secrets. Pass anything else with env:.
  • A :stdio server’s stderr is your process’s stderr. A chatty server prints into your terminal or log.
mcp :github, transport: :stdio, command: "github-mcp",
  env: {GITHUB_TOKEN: ENV.fetch("GITHUB_TOKEN")}

# Drop a noisy server's stderr
mcp :mail, transport: :stdio, command: "sh",
  args: ["-c", 'exec "$0" 2>/dev/null', "apple-mail-mcp"]

An unknown transport, or a :stdio server with no command:, now raises Nexo::ConfigurationError when the server is built.

7. Sessions on ActiveRecord: run ruby_llm’s schema upgrade

This applies only if you use Nexo::Session with persisted chats. ruby_llm 2.x keeps the model registry and tool calls in its own ruby_llm_* tables, so your app owns only the Chat and Message models. Delete your Model and ToolCall classes and remove config.use_new_acts_as from the initializer, then run the generator one minor version at a time:

bin/rails generate ruby_llm:upgrade
bin/rails db:migrate

Follow ruby_llm’s upgrade guide for the order and for its copy mode, which keeps downtime to seconds. Your agent_name and instance_id columns on chats stay as they are.

8. The local shell no longer inherits your environment

Before, a command an agent ran on sandbox :local could read every variable in your process environment, API keys included. The documented narrowing to PATH, HOME and LANG was only added on top of the inherited environment. Now the command gets those three and nothing else.

If a command relied on an inherited variable, pass it explicitly:

class Builder < Nexo::Agent
  sandbox :local, env: {"BUNDLE_GEMFILE" => "/app/Gemfile"}
end

A shell timeout also stops the command now. Before, the timeout error was raised only after the command had finished by itself. The command and everything it started are killed, and the model receives the timeout as a tool error instead of the run failing.

9. One approval answers one call

This affects workflows that use permissions :approve with run_agent.

Before, resume(run_id, approved: true) approved the pending call and every gated call after it in the same prompt. Now the answer applies to the call recorded in run.state["__approval__"] and nothing else. A different gated call suspends the run again:

run = ApprovedWrite.run                              # suspended: write a.txt
run = ApprovedWrite.resume(run.id, approved: true)   # suspended again: write b.txt
run = ApprovedWrite.resume(run.id, approved: true)   # done

Your approval screen needs no change if it already renders run.state["__approval__"] and resumes with approved:. Expect it to be shown once per distinct call.

Since 0.16 the pause is ruby_llm’s own: the call is held before the tool runs, where it used to be an exception raised from inside the tool. Four things follow:

  • Several calls can wait at once. A model response may ask for more than one gated call. run.state["__approvals_pending__"] lists each one with its "key", and resume(run.id, approvals: {key => true, other_key => false}) answers them together. "__approval__" is still the first, and approved: true still answers it.
  • A declined call gets ruby_llm’s refusal ("The user denied the … tool call.") and records no tool events, because the tool never runs.
  • A catch-all rescue_from StandardError on a tool no longer swallows an approval. If you narrowed a handler to work around that, you can leave it as it is.
  • Since 0.17 a resume carries the paused conversation on. The held call runs and the model is not asked again; see section 17.

A custom agent class you pass to the agent macro receives decisions: (a Hash) where it received decision:.

10. Declare your own tools with tools

If you attach tools by overriding chat, they stop working: since 0.16 a tool Nexo did not attach is refused, because no permission check ever saw those calls. The model is told the call did not run, and Nexo prints a notice once per tool naming it. Declare them instead:

# Before
class Archivist < Nexo::Agent
  def chat(base: nil)
    super.with_tools(Today.new, ArchiveRun.new)
  end
end

# After
class Archivist < Nexo::Agent
  tools Today                              # no side effects: no gate
  tools ArchiveRun, capability: :write     # decided by the agent's permissions
end

A tool declared with capability: is refused under :read_only, put to your on_ask hook under :ask, and suspends the run under :approve, exactly like the write tools.

To get the 0.15 behaviour back while you migrate (the tool runs, with a warning):

Nexo.configure { |config| config.strict_tools = false }

11. MCP tools outside mcp_allow are no longer offered

Under :read_only, an MCP tool that is not in mcp_allow was attached and then denied when the model called it. Now it is not attached. Nothing that worked before stops working. If you list the tools on a chat in a test, expect fewer.

12. A cap on tool calls per round

max_turns counts model responses, and one response may ask for any number of tool calls. A response now runs at most 20 of them. The rest are answered with an error straight away and never execute, and the model can ask again.

If an agent legitimately issues more than 20 calls in one response, raise the cap or remove it:

Nexo.configure { |config| config.tool_calls_per_round = 50 }   # or nil for no cap

13. The file tools are ruby_llm’s

Nexo’s own ReadFile, WriteFile and Glob were removed in 0.16. Every agent now gets ruby_llm’s file tools over its sandbox, behind the same permission gate:

Before Now
nexo--tools--read_file read_file (answers with line numbers, 1,000 lines or 20,000 characters a call)
nexo--tools--write_file write_file, or edit_file to change part of a file
nexo--tools--glob list_files (with pattern:), or search_files to search contents
— delete_file (new in 0.17, on a sandbox that can delete)

What to change:

  • Skills and prompts that name a tool. “Use nexo--tools--write_file” must become write_file.
  • Code that reads tool events by name or by result shape. write_file returns the text Wrote <path> (<size>). where the old tool returned {ok: true, path:}; read_file returns numbered lines, not the bare content.
  • Files with very long lines. read_file cuts a line longer than 2,000 characters. If your agent reads back a file your code writes (JSON on one line, say), write it with shorter lines.
  • file_tools :nexo raises Nexo::ConfigurationError. Remove the line.
  • A custom sandbox class needs #files. The default runs find through your sandbox’s shell.

Reading, listing and searching need :read; writing and editing need :write, and under :read_only those two tools are not attached. A write or an edit to an existing file needs a read of it first in the same chat, on every sandbox. The :glob capability is still accepted in allow:, so your permissions need no change.

An MCP server with the same tool names. A filesystem MCP server usually calls its tools read_file, write_file and search_files too. Two tools cannot share a name, so an agent that allows one of them now raises Nexo::ConfigurationError when its chat is built. Pick one side:

class RemoteFiles < Nexo::Agent
  file_tools :none        # the server's tools are the file tools
  mcp :files, transport: :stdio, command: "npx", args: %w[-y @modelcontextprotocol/server-filesystem /data]
  mcp_allow "read_file", "search_files"
end

Or, under :read_only, keep the built-in tools and leave the clashing names out of mcp_allow. See Tools.

14. Options that were removed

Each of these raises when used. All were removed in 0.16.

Removed Use
context_budget per_result: 0.25 on an agent llm { context_budget per_result: 0.25 }
Permissions.new(approve_when: ...) Permissions.new(ask_when: ...)
Permissions.new(decision: ...), Agent.new(decision: ...) decisions:, a Hash of call key to true/false
file_tools :nexo Remove it (see section 13)

The llm block is new: it takes ruby_llm’s own agent options, applied to every chat the agent builds.

class Reviewer < Nexo::Agent
  model "claude-sonnet-5-5"

  llm do
    thinking effort: :high
    temperature 0.2
    context_budget per_result: 0.25, per_request: 0.7
  end
end

15. Run statuses, events and custom stores

Read this if you list run statuses, consume loop events, or wrote a run store.

  • Two new statuses. cancelling and cancelled, for Nexo::Workflow.cancel(run_id). The column is a string, so no migration is needed. Update any code that lists statuses.
  • Three new loop events. The block you pass to prompt also receives :usage, :tool_progress and :fallback. A block that assumes only :tool_call, :tool_result and :done should ignore the rest.
  • A custom run store’s claim_for_resume! must accept from: to support Workflow.retry, and needs request_cancel!, cancel_requested? and clear_cancel! to support cancelling a running run.
  • An MCP tool’s result in a run’s event log is now its text. It used to be recorded as an object address.

16. Skill names are hyphenated

Since 0.17 a skill is read by ruby_llm’s parser, which follows the Agent Skills specification. Three things it requires that Nexo’s own reader did not:

  • name and description are both required.
  • The name is lower-case letters, digits and single hyphens: email-triage, not email_triage.
  • The name equals its folder’s name.

Rename each skill folder and its name: line:

git mv app/skills/email_triage app/skills/email-triage
---
name: email-triage
description: Classifies the messages in an inbox and produces a digest.
---

skills :email_triage on an agent keeps working: a name given with underscores resolves to the hyphenated folder. You can also write skills "email-triage".

An underscore-named skill you have not renamed still loads in 0.17 and prints a notice saying what to rename. It stops loading in 0.18. A skill with no description, or whose name: differs from its folder, raises Nexo::Error now.

Nothing changes in how a skill reaches the model: Nexo still puts its text in the instructions and gives the model no tool to load skill files with.

17. A resume carries the conversation on

Until 0.16, resuming a run that had paused for an approval or a question asked the prompt again from the start. The model planned the task a second time, and a tool that had already run could run twice.

Since 0.17 the conversation is saved with the run when it pauses. The resume restores it: the held call runs or is refused, nothing before it runs again, and the model is asked only for what comes next.

  • Nothing to change in your workflows. resume(run_id, approved: true) and resume(run_id, answers: {...}) are the same.
  • Tests that script the model. If a test stubs the model’s replies before a resume, stub only what comes after the approved call. Stubbing the tool call again makes it run twice.
  • The run’s state has a new reserved key, "__chat__", holding the conversation while the run is paused. It is removed when the prompt finishes. Do not use that key for your own data.
  • Runs paused by an earlier version have no saved conversation and are asked again, as before.
  • Your own #call is still re-entered from the top. Work outside a checkpoint, and outside the run_agent that paused, runs again.

A direct caller, with no workflow, does the same by hand:

begin
  agent.prompt("Archive the run")
rescue Nexo::ApprovalRequired => e
  decided = Archivist.new(decisions: {e.key => true})
  decided.prompt("Archive the run", continue: e.transcript)
end

Two additions make approvals easier to live with:

# Say what identifies a call, so a free-text argument does not make each attempt a new one
tools IssueRefund, capability: :write, detail: ->(args) { "refund #{args[:order]}" }

# Approve every later call of the same kind in this run
ApprovedWrite.resume(run.id, approved: true, remember: true)

New, and opt-in

None of these change anything until you turn them on.

  • Confine the local shell. sandbox :local, isolation: :confined runs each command in an OS sandbox that can write only inside the working directory, cannot read your home directory, and has no network. Nexo::Sandboxes::ContainerRunner does the same with a throwaway container per command. See Sandboxes.
  • OAuth for MCP servers. mcp ..., oauth: true and Agent.new(mcp_owner:), with a credential store that can encrypt what it keeps. See MCP.
  • More from an MCP server. resources: true lets the model read what a server offers, defer: true keeps a large server’s tools out of the context until they are searched for, tasks: true waits for a call the server finishes later, and agent.mcp_prompt uses a prompt the server wrote. See MCP.
  • A context budget. llm { context_budget ... } bounds what any tool returns as a share of the model’s context window. See Tools.
  • Retry and cancel a run. Nexo::Workflow.retry(run_id) runs a failed or interrupted run again without repeating its finished checkpoints. Nexo::Workflow.cancel(run_id) stops one. See Durable workflows.
  • What a run used. Nexo::Workflow.usage(run) totals the tokens and cost of a run’s prompts.
  • A tool that asks the person something suspends the run; resume(run_id, answers: {...}) answers it.
  • Provider-side tools (0.17). provider_tools :web_search, capability: :search attaches a tool that runs on the provider’s servers, only when the agent’s permissions allow that capability for every call. See Tools.
  • A declined approval is on the record (0.17): the :tool_declined event, and agent_tool_declined in a run’s log.
  • hardening_gaps on every sandbox reports what it does not contain. A :local sandbox reports an unconfined shell.
  • A workflow that prompts its agents itself (0.16.1) records their events with emit_agent_event(type, payload) and passes cancel: -> { cancel_requested? } to prompt.

Smaller changes

  • Skills need YAML front matter. A SKILL.md without it now raises Nexo::Error naming the file.
  • Nexo::MCP.load! and Nexo::Skills.load! are gone. There is no optional gem left to load.
  • Workflow events store tool arguments with string keys in both run stores. Code that read event["data"]["args"][:path] from the memory store must use "path".
  • Hash and Array tool results reach the model as JSON, not Ruby inspect output.
  • OpenAI defaults to the Responses API in ruby_llm 2.x. Set config.openai_protocol = :chat_completions to keep the old wire format. Ollama and other OpenAI-compatible providers are unaffected.
  • Tests: ruby_llm-test is no longer needed. ruby_llm ships RubyLLM::TestHelper, whose stub_replies scripts the model’s replies and drives real tool calls.
  • A custom agent class you pass to a workflow’s agent macro now receives decisions: (a Hash) where it received decision:. It is given answers: only when a run has answers, and cancel: only when its prompt accepts it.
  • A command that times out in a container is now stopped inside the container. Before, only the runtime’s client on the host was stopped.
  • ContainerRunner on a Linux host needs user: "#{Process.uid}:#{Process.gid}" to write to the workspace. macOS runtimes need nothing.
  • Nexo’s notices go to standard error even under ruby -W0.
  • RunStore::Disk#all lists runs by when they started (0.17), newest first. It used to go by file time.
  • A custom agent class given a Permissions instance works on a copy of it (0.17).
  • A timed-out MCP task answers its call with an error (0.17) and the prompt goes on. It used to fail the prompt.
  • An absolute path outside the sandbox is refused by name (0.17), where the file tools reported it as not found.
  • Tools::Fetch tries each address a host resolves to, so a host with an unreachable IPv6 address no longer fails every fetch.

Check the upgrade

Build an agent and list its tools. A default agent shows the three reading tools and nothing that writes:

agent = MyAgent.new
agent.chat.tools.keys
# => [:list_files, :read_file, :search_files]

An agent that may write shows six: those three plus write_file, edit_file and delete_file.

Then run one real prompt against your model, one agent that uses the shell, one that writes a file, and one workflow that suspends for approval. In that last one, check that the approved tool ran once. Confirm the shell still finds its commands and the workflow asks once per call. Nexo’s own suite proves the permission gate, the MCP gate, the turn cap, and approval suspension through ruby_llm’s real loop, but only a live run exercises your tools and your provider.


Next steps