Skip to content

Upgrade ruby_llm to 2.1.1 (more built-in code + prompt_cache_key for every OpenRouter model + billed OpenRouter cost) - #13

Merged
ardecvz merged 8 commits into
rails:mainfrom
ardecvz:feat/update-ruby-llm
Oct 27, 2026
Merged

ardecvz merged 8 commits into
rails:mainfrom
ardecvz:feat/update-ruby-llm

Conversation

@ardecvz

@ardecvz ardecvz commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator
  • Miniswen: upgrade ruby_llm to 2.1.1 (use its new built-in caching, finish reasons and reasoning replay, keep the ~10 min retry window, honor RUBYLLM_DEBUG, allow JSON 3).
  • Miniswen: send prompt_cache_key for every OpenRouter model, not only Muse, so a session keeps its cache without a pinned provider order.
  • Miniswen: turn on prompt caching for every model, so models that need it (like Claude, including on the Anthropic API) cache, and those that cache automatically are unaffected.
  • Miniswen: OpenRouter runs cost what OpenRouter actually billed (including discounts or a pricier provider), with registry prices as the rare fallback.
  • Miniswen: trajectories record which upstream provider served each OpenRouter turn.
  • lemans-remote: forward all provider keys RubyLLM reads, not only OPENROUTER_API_KEY.

@ardecvz
ardecvz requested review from baygeldin, palkan and skryukov and a balanced review from Copilot October 20, 2026 21:04

Copilot AI 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.

🟡 Changes recommended

Unresolved accounting and API migration issues can undercount charges and break agent result collection or malformed-call recovery.

3 open issues
What changed in this PR

Upgrades Miniswen to RubyLLM 2.1.1 and integrates its built-in request handling and accounting features.

Changes:

  • Migrates caching, reasoning replay, finish reasons, and output limits.
  • Extends OpenRouter cache keys and uses provider-reported costs.
  • Updates dependencies and remote credential forwarding.
File Description
test/​miniswen/​agent_test.rb Updates API migration and accounting coverage.
test/​lemans/​agents/​test_miniswen.rb Tests content-filter outcome details.
miniswen.gemspec Upgrades RubyLLM dependency.
lib/​miniswen/​testing.rb Migrates test models and responses.
lib/​miniswen/​ruby_llm.rb Updates logging, retries, and parsing overrides.
lib/​miniswen/​cli.rb Updates registry refresh invocation.
lib/​miniswen/​agent.rb Migrates requests, reasoning, and cost accounting.
lib/​miniswen.rb Updates registry refresh API.
lib/​lemans/​agents/​miniswen.rb Revises content-filter reporting.
lemans.gemspec Updates dependencies and permits JSON 3.
Gemfile Upgrades RubyLLM test support.
exe/​lemans-remote Expands provider credential forwarding.
CHANGELOG.md Documents upgrade behavior.

Review effort: Balanced

Comment thread lemans.gemspec Resolved
Comment thread lib/miniswen/agent.rb Resolved
Comment thread lib/miniswen/ruby_llm.rb Resolved
@ardecvz
ardecvz force-pushed the feat/update-ruby-llm branch from df6a500 to b232e2a Compare October 20, 2026 21:45

@baygeldin baygeldin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, but before merging I think we should double-check manually that caching works as expected (especially for Muse and Anthropic) - it should be higher than ~95%.

Comment thread lib/miniswen/agent.rb Resolved

@palkan palkan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good 👍

Comment thread CHANGELOG.md
- Miniswen: send `prompt_cache_key` for every OpenRouter model, not only Muse, so a session keeps its cache without a pinned provider order.
- Miniswen: turn on prompt caching for every model, so models that need it (like Claude, including on the Anthropic API) cache, and those that cache automatically are unaffected.
- Miniswen: OpenRouter runs cost what OpenRouter actually billed (including discounts or a pricier provider), with registry prices as the rare fallback.
- Miniswen: trajectories record which upstream provider served each OpenRouter turn.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@ardecvz
ardecvz merged commit 9da79eb into rails:main Oct 27, 2026
2 checks passed
@ardecvz
ardecvz deleted the feat/update-ruby-llm branch October 27, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants