Skip to content

Upgrade to RubyLLM 2.0 - #2

Open
justwiebe wants to merge 1 commit into
mainfrom
upgrade-ruby-llm-2.0
Open

justwiebe wants to merge 1 commit into
mainfrom
upgrade-ruby-llm-2.0

Conversation

@justwiebe

Copy link
Copy Markdown
Collaborator

Why

RubyLLM 2.0 removed RubyLLM::Content and now keeps message text and attachments apart, so this gem no longer loaded against it. Tool results and message building both change shape to match, and the gem moves to 2.0.0 since its own users have to change code.

Sampling gained a Hash form for preferred_model. RubyLLM 2.0 resolves models more strictly and defaults OpenAI to the Responses API, so a bare model name can no longer say which provider or protocol sampling should use.

Prompt messages were reading image and audio content from content and mime_type, which the MCP spec does not define, so both were nil. They now read data and mimeType like the other three call sites.

The specs pin an explicit provider and hold OpenAI to Chat Completions, which keeps the existing VCR cassettes matching without re-recording them. Worth re-recording against 2.0 defaults when API keys are to hand.

What Changed

  • Require RubyLLM 2.0 and bump the gem to 2.0.0
  • Return tool results as text, or text plus attachments
  • Rename Tool#params_schema to #parameters_schema
  • Accept chat options in the sampling preferred_model config
  • Add a 1.0 to 2.0 upgrade guide and refresh the tool and resource docs

Post-merge

  • Re-record the VCR cassettes with VCR_REFRESH=true and real API keys, then drop the protocol: :chat_completions pin in spec_helper.rb. Until then the specs cover 1.x request shapes, not 2.0 ones.

Screenshots

N/A — no UI changes

RubyLLM 2.0 removed RubyLLM::Content and now keeps message text and
attachments apart, so tool results and message building both change shape.

MCP::Content becomes a value object carrying text and attachments, with
to_llm_result for tool returns and to_message for chat history. Tool#execute
returns a String, or the text followed by attachments. Tool#params_schema is
renamed to #parameters_schema. MCP::Attachment now builds on a real source,
so #content gives decoded bytes and #encoded the server's base64.

Sampling config gained a Hash form for preferred_model that passes keywords
to RubyLLM::Chat. RubyLLM 2.0 resolves models more strictly and defaults
OpenAI to the Responses API, so a bare model name can no longer say which
provider or protocol sampling should use.

Prompt messages read image and audio content from the data and mimeType keys
the MCP spec defines. They read content and mime_type before, which are not
in the spec, so both were nil.

The specs pin an explicit provider, assume the model exists, and hold OpenAI
to Chat Completions, which keeps the recorded cassettes matching.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@justwiebe justwiebe self-assigned this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant