Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## [Unreleased]

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

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.

👍

- `lemans-remote`: forward all provider keys RubyLLM reads, not only `OPENROUTER_API_KEY`.

## [1.5.2] - 2026-10-14

- `lemans --require/-r [command]`: load agent, backend plugins (`lemans -r plugin.rb restart RUN`)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ gem "minitest-mock", "~> 5.27"
gem "rubocop", "~> 1.89"
gem "rubocop-rails-omakase", require: false

gem "ruby_llm-test", "~> 0.2.0"
gem "ruby_llm-test", "~> 0.3.0"
12 changes: 6 additions & 6 deletions examples/codex/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def usage_for(events, token_usage: nil)
end

def priced_model
info = RubyLLM.models.find(model.to_s.split("#", 2).first, "openai")
info if info.input_price_per_million.is_a?(Numeric) && info.output_price_per_million.is_a?(Numeric)
info = RubyLLM.models.find(model.to_s.split("#", 2).first, provider: "openai")
info if info.price(:input).is_a?(Numeric) && info.price(:output).is_a?(Numeric)
rescue RubyLLM::ModelNotFoundError
nil
end
Expand All @@ -164,10 +164,10 @@ def priced_model
def estimated_cost(totals, info)
return unless info

input = info.input_price_per_million
output = info.output_price_per_million
cache_read = info.cache_read_input_price_per_million || input
cache_write = info.cache_write_input_price_per_million || input
input = info.price(:input)
output = info.price(:output)
cache_read = info.price(:cache_read) || input
cache_write = info.price(:cache_write) || input
totals.sum do |tokens|
cached = tokens["cached_input_tokens"].to_i
written = tokens["cache_write_input_tokens"].to_i
Expand Down
8 changes: 5 additions & 3 deletions exe/lemans-remote
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
# exe/lemans-remote snapshots
# exe/lemans-remote deprovision [--name SNAPSHOT]
#
# Credentials come from the host ENV: DAYTONA_API_KEY (or DAYTONA_TOKEN),
# OPENROUTER_API_KEY, LEMANS_PROVIDER_ORDER (or OPENROUTER_PROVIDER_ORDER);
# Credentials come from the host ENV: DAYTONA_API_KEY (or DAYTONA_TOKEN), every
# provider key RubyLLM reads (OPENROUTER_API_KEY, ANTHROPIC_API_KEY, ...),
# LEMANS_PROVIDER_ORDER (or OPENROUTER_PROVIDER_ORDER);
# forward extras with --env KEY.

lib_path = File.expand_path("../lib", __dir__)
Expand Down Expand Up @@ -101,7 +102,8 @@ module LemansRemote # :nodoc: all
REMOTE_META = "/tmp/lemans-remote-run.json"
REMOTE_REQUIRES_DIR = "/tmp/lemans-remote-requires"

ENV_ALLOWLIST = %w[OPENROUTER_API_KEY LEMANS_PROVIDER_ORDER OPENROUTER_PROVIDER_ORDER].freeze
ENV_ALLOWLIST = (RubyLLM::Provider.providers.values.flat_map(&:configuration_requirements).map { it.to_s.upcase } +
%w[LEMANS_PROVIDER_ORDER OPENROUTER_PROVIDER_ORDER]).uniq.freeze

Backend = Lemans::Environments::Daytona

Expand Down
5 changes: 2 additions & 3 deletions lemans.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ Gem::Specification.new do |spec|
spec.add_dependency "concurrent-ruby", "~> 1.3"
spec.add_dependency "csv", "~> 3.3"
spec.add_dependency "daytona", "~> 0.203"
spec.add_dependency "json", "< 3" # positional args change is not yet supported by faraday
spec.add_dependency "faraday", "~> 2.10"
spec.add_dependency "faraday", "~> 2.14", ">= 2.14.4"
spec.add_dependency "faraday-multipart", "~> 1.1"
spec.add_dependency "rack", "~> 3.1"
spec.add_dependency "rackup", "~> 2.2"
spec.add_dependency "rexml", "~> 3.4"
spec.add_dependency "ruby_llm", "~> 1.16"
spec.add_dependency "ruby_llm", "~> 2.1.1"
Comment thread
ardecvz marked this conversation as resolved.
Resolved
spec.add_dependency "thor", "~> 1.5"
spec.add_dependency "webrick", "~> 1.9"
spec.add_dependency "zeitwerk", "~> 2.8"
Expand Down
4 changes: 2 additions & 2 deletions lib/lemans/agents/miniswen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def detail_for(result)
when :format_error
"#{::Miniswen::Agent::MAX_CONSECUTIVE_FORMAT_ERRORS} consecutive responses without a valid bash tool call"
when :content_filter
"the provider stopped the model: #{::Miniswen::Agent::MAX_CONSECUTIVE_FORMAT_ERRORS} consecutive turns " \
"ended with #{::Miniswen::Agent::REFUSAL_FINISH_REASONS.join("/")} and no tool call"
"the provider stopped the model with content_filter: " \
"#{::Miniswen::Agent::MAX_CONSECUTIVE_FORMAT_ERRORS} consecutive turns ended with no valid tool call"
end
end

Expand Down
8 changes: 2 additions & 6 deletions lib/miniswen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ class InfrastructureError < Error; end
class AccountingError < Error; end

class << self
def refresh_registry!(persist: false)
def refresh_registry!
return true if @ruby_llm_refreshed

RubyLLM.models.refresh!
# save_to_json writes to the registry file every boot loads from (the
# gem's own models.json by default), so a persisted refresh outlives
# this process — later runs in the same environment boot from it.
RubyLLM.models.save_to_json if persist
RubyLLM.models.refresh
@ruby_llm_refreshed = true
rescue StandardError => e
warn "Failed to refresh RubyLLM registry: #{e.message}"
Expand Down
Loading
Loading