Skip to content

RubyLLM2 W1-01: Accept RubyLLM 2.0's tool DSL names on the 1.16 fork - #37

Merged
samuelboland merged 2 commits into
mainfrom
dux-rubyllm2-w1-01-tool-dsl-names
Oct 19, 2026
Merged

samuelboland merged 2 commits into
mainfrom
dux-rubyllm2-w1-01-tool-dsl-names

Conversation

@supernova-dx-appf-io

@supernova-dx-appf-io supernova-dx-appf-io Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

RubyLLM2 W1-01. Supernova is moving from this fork's 1.16 to upstream RubyLLM 2.x. 2.0 renames the tool DSL, and Supernova declares about 1,780 tool parameters across 537 files with the 1.x names. This PR makes the fork accept the 2.0 names as well, so Supernova can rename everything on today's gem, in ordinary PRs, before the gem bump. This PR targets the fork's main only; it is not an upstream contribution.

The rename

1.x 2.0
Parameter.new(name, desc: ...) Parameter.new(name, description: ...) (already accepted before this PR)
class param :x, desc: '...' class parameter :x, description: '...'
class parameters (no-argument getter) class declared_parameters
class params(schema) / params do ... end class parameters(schema) / parameters do ... end
class params_schema_definition class parameters_schema_definition
instance parameters instance declared_parameters
instance params_schema instance parameters_schema

How the two sets of names relate

All changes are in lib/ruby_llm/tool.rb. Each concept is one chain of plain def methods, never alias (an alias binds to the method body when it is defined, so a subclass overriding one name would not be seen through the other):

  • Parameter hash: instance parameters -> instance declared_parameters -> class parameters (no arguments) -> class declared_parameters (storage).
  • Schema: instance params_schema -> instance parameters_schema (holds the existing logic) -> class params_schema_definition -> class parameters_schema_definition (storage).

The protocols call the head of each chain (tool.params_schema || ... from_parameters(tool.parameters) in anthropic/tools.rb:49, chat_completions/tools.rb:21, converse/chat.rb:333, gemini/tools.rb:95; responses/tools.rb:16 goes through ChatCompletions::Tools.parameters_schema_for). So an override of any link, under either name, at the class or the instance level, reaches every protocol. The protocol files are unchanged.

parameters with a schema or block is the 2.0 form of params. With neither, it stays the 1.x getter for the parameter hash (2.0 raises ArgumentError there; the fork keeps the getter until Supernova no longer calls it). params behaves as before: with no arguments it sets an empty definition and returns the class.

Overrides of either name are honored

Supernova overrides these methods in three ways today and will use the 2.0 names after RubyLLM2 W1-02. Each is covered in spec/ruby_llm/tool_spec.rb, describe 'RubyLLM 2.0 tool DSL names':

  • class-level parameters merging another tool's parameters (Supernova's AutomationCreateTool): "honors a class-level parameters override through both names";
  • the same at declared_parameters: "honors a class-level declared_parameters override through both names";
  • instance-level parameters and params_schema (Supernova's ToolDiscovery::ToolHeadline): "honors instance-level parameters and params_schema overrides at the 1.x names", and at the 2.0 names: "honors instance-level declared_parameters and parameters_schema overrides at the 2.0 names";
  • for both instance-level classes, the tool definition each protocol builds carries the override's schema: "reaches Anthropic", "reaches Chat Completions", "reaches Converse", "reaches Gemini" and "reaches Responses", called directly with no stubs on the methods under test.

The 2.0 names sit further down each chain than the 1.x names, so an instance-level override of a 1.x name is not seen by a direct call to the 2.0 name. The protocols call the 1.x names, so they see it; the spec says so in a comment. W1-02 moves Supernova's overrides to the 2.0 names.

Every 1.x method keeps its behavior and the protocols are unchanged, so a Supernova lock bump that only picks up this PR is not expected to change any tool schema. RubyLLM2 W1-03 dumps every tool's schema before and after its rename, which measures this directly.

Also covered: the same schema from param/desc: and parameter/description:, compared against a literal ("builds the same schema from param/desc and parameter/description"); params and parameters with a schema hash and with a RubyLLM::Schema block; and the no-argument getter.

No inheritance change

2.0 copies a parent's declared parameters and schema definition into each subclass through an inherited hook; 1.16 does not. This PR deliberately does not add the hook, because it would change the schema of every Supernova tool that subclasses another tool. "does not copy declared parameters into subclasses" pins today's behavior. Supernova handles the difference at the gem bump.

Other readers in lib/

A grep of lib/ for params_schema, params_schema_definition, .parameters and @parameters found only the five protocol call sites above; none needed a change. The other .params hits are Faraday request.params in the xai, vertexai and mistral providers, unrelated to tools. No code in lib/ or in Supernova reads the moved instance variables (@parameters, @params_schema, @params_schema_definition) directly.

Docs

README.md and docs/ use the 2.0 names in every tool example and in the prose about the DSL. docs/_core_features/tools.md and docs/_core_features/tool-parameters.md each say that the 1.x names still work on this fork. with_params, docs/_advanced/agents.md, docs/_core_features/image-generation.md and the tool generator template are unchanged.

CI runner image

A separate commit pins .github/workflows/_test-matrix.yml to runs-on: ubuntu-24.04. ubuntu-latest moved to ubuntu-26.04 between Oct 14 and Oct 19, and ruby/setup-ruby has no Ruby 3.1.7 or JRuby 10.0.2.0 build for it, so those two jobs failed in "Set up Ruby" and fail-fast cancelled the other 17. The lint and gitleaks workflows still run on ubuntu-latest.

Tests

  • spec/ruby_llm/tool_spec.rb, three seeds: 36 examples, 0 failures.
  • The other tool-related specs (19 files), once: 585 examples, 0 failures, 62 pending (structured-output cases in chat_schema_spec.rb that skip because the model does not support structured output).
  • RuboCop clean on the changed Ruby files.
  • CI runs the full matrix.

Out of scope

with_params / provider_params (2.0: provider_options), 2.0's tool_name, requires_approval and the call(tool_call:, **arguments) signature. Supernova handles those at the gem bump.

Add parameter, declared_parameters, parameters(schema/block),
parameters_schema_definition and instance parameters_schema. Each 1.x name
calls its 2.0 name through plain methods, so overrides of either name are
honored by the protocols. Docs use the 2.0 names.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Co-authored-by: Sam Boland <sam.boland@appfolio.com>
@samuelboland

samuelboland commented Oct 19, 2026 •

Copy link
Copy Markdown

Review of 3dd533f. The code, specs and docs match the brief. The only thing blocking merge is CI, and the cause is not this PR.

1. CI never ran the specs. Fix the runner image in its own commit.

ubuntu-latest moved from ubuntu-24.04 to ubuntu-26.04 between Oct 14 and today (each job's "Set up job" log prints Image:; the Oct 14 runs on #35 and #36 say ubuntu-24.04, this run says ubuntu-26.04). ruby/setup-ruby has no build of Ruby 3.1.7 or JRuby 10.0.2.0 for 26.04, so these two jobs failed in "Set up Ruby":

Error: Unavailable version 3.1.7 for ruby on ubuntu-26.04
Error: Unavailable version 10.0.2.0 for jruby on ubuntu-26.04

The matrix has no fail-fast: setting, so the default (true) cancelled the other 17 test jobs during "Install dependencies" or "Run tests". No spec failed anywhere; none finished.

Change .github/workflows/_test-matrix.yml:18 from runs-on: ubuntu-latest to runs-on: ubuntu-24.04, with a one-line comment above it saying ubuntu-26.04 has no Ruby 3.1 or JRuby 10.0.2.0 build. Make it a separate commit ("Pin the test matrix to ubuntu-24.04"). Leave _lint.yml and _gitleaks.yml alone; they passed on 26.04. Do not change the Ruby versions in the matrix.

2. No PR description work needed. I will write the description after your last push.

Verified and fine:

  • lib/ruby_llm/tool.rb: both call chains are plain def methods in the brief's order, define_parameters_schema is private, with_params / provider_params stay public, no inherited hook, and the protocol files are untouched.
  • No reader in lib/ or in Supernova's monolith/ uses the renamed instance variables (@parameters, @params_schema, @params_schema_definition) directly, so moving the storage to @declared_parameters / @parameters_schema / @parameters_schema_definition is safe.
  • spec/ruby_llm/tool_spec.rb covers tests 1-5 and 7 as briefed, including the Gemini converted literal.
  • Docs: every listed site uses the 2.0 names, the one-sentence 1.x note is in tools.md and tool-parameters.md, and with_params, agents.md, image-generation.md and the generator template are unchanged.

@supernova-dx-appf-io

Copy link
Copy Markdown
Author

@samuelboland

Review of 3dd533f. The code, specs and docs match the brief. The only thing blocking merge is CI, and the cause is not this PR.

1. CI never ran the specs. Fix the runner image in its own commit.

ubuntu-latest moved from ubuntu-24.04 to ubuntu-26.04 between Oct 14 and today (each job's "Set up job" log prints Image:; the Oct 14 runs on #35 and #36 say ubuntu-24.04, this run says ubuntu-26.04). ruby/setup-ruby has no build of Ruby 3.1.7 or JRuby 10.0.2.0 for 26.04, so these two jobs failed in "Set up Ruby":

Error: Unavailable version 3.1.7 for ruby on ubuntu-26.04
Error: Unavailable version 10.0.2.0 for jruby on ubuntu-26.04

The matrix has no fail-fast: setting, so the default (true) cancelled the other 18 test jobs during "Install dependencies" or "Run tests". No spec failed anywhere; none finished.

Change .github/workflows/_test-matrix.yml:18 from runs-on: ubuntu-latest to runs-on: ubuntu-24.04, with a one-line comment above it saying ubuntu-26.04 has no Ruby 3.1 or JRuby 10.0.2.0 build. Make it a separate commit ("Pin the test matrix to ubuntu-24.04"). Leave _lint.yml and _gitleaks.yml alone; they passed on 26.04. Do not change the Ruby versions in the matrix.

2. No PR description work needed. I will write the description after your last push.

Verified and fine:

  • lib/ruby_llm/tool.rb: both call chains are plain def methods in the brief's order, define_parameters_schema is private, with_params / provider_params stay public, no inherited hook, and the protocol files are untouched.
  • No reader in lib/ or in Supernova's monolith/ uses the renamed instance variables (@parameters, @params_schema, @params_schema_definition) directly, so moving the storage to @declared_parameters / @parameters_schema / @parameters_schema_definition is safe.
  • spec/ruby_llm/tool_spec.rb covers tests 1-5 and 7 as briefed, including the Gemini converted literal.
  • Docs: every listed site uses the 2.0 names, the one-sentence 1.x note is in tools.md and tool-parameters.md, and with_params, agents.md, image-generation.md and the generator template are unchanged.

I've queued the runner fix and I'm working on it now. It changes .github/workflows/_test-matrix.yml:18 from ubuntu-latest to ubuntu-24.04. A one-line comment above it will say that ubuntu-26.04 has no Ruby 3.1 or JRuby 10.0.2.0 build. It will go in as its own commit, "Pin the test matrix to ubuntu-24.04". _lint.yml, _gitleaks.yml and the matrix Ruby versions stay as they are.


🔍 View trace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@supernova-dx-appf-io

Copy link
Copy Markdown
Author

@samuelboland

Review of 3dd533f. The code, specs and docs match the brief. The only thing blocking merge is CI, and the cause is not this PR.

1. CI never ran the specs. Fix the runner image in its own commit.

ubuntu-latest moved from ubuntu-24.04 to ubuntu-26.04 between Oct 14 and today (each job's "Set up job" log prints Image:; the Oct 14 runs on #35 and #36 say ubuntu-24.04, this run says ubuntu-26.04). ruby/setup-ruby has no build of Ruby 3.1.7 or JRuby 10.0.2.0 for 26.04, so these two jobs failed in "Set up Ruby":

Error: Unavailable version 3.1.7 for ruby on ubuntu-26.04
Error: Unavailable version 10.0.2.0 for jruby on ubuntu-26.04

The matrix has no fail-fast: setting, so the default (true) cancelled the other 18 test jobs during "Install dependencies" or "Run tests". No spec failed anywhere; none finished.

Change .github/workflows/_test-matrix.yml:18 from runs-on: ubuntu-latest to runs-on: ubuntu-24.04, with a one-line comment above it saying ubuntu-26.04...

Pushed 536d6a2. I have a question for you.

Changed 1 file (+2 −1): .github/workflows/_test-matrix.yml

Questions:

  • None.

View the full session

@samuelboland samuelboland changed the title feat: support RubyLLM 2.0 tool DSL names alongside 1.x RubyLLM2 W1-01: Accept RubyLLM 2.0's tool DSL names on the 1.16 fork Oct 19, 2026
@samuelboland
samuelboland marked this pull request as ready for review October 19, 2026 17:58
@samuelboland
samuelboland requested a review from a team as a code owner October 19, 2026 17:58

@samuelboland samuelboland left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: both call chains as briefed, override specs for both names across all five protocols, docs, and the ubuntu-24.04 pin; full CI matrix green.

@samuelboland
samuelboland merged commit 43d98e5 into main Oct 19, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants