Skip to content

fix(ruby_llm): read token counts from RubyLLM 2.x turns - #6

Merged
TonsOfFun merged 1 commit into
mainfrom
claude/ruby-llm-2x-tokens
Sep 21, 2026
Merged

TonsOfFun merged 1 commit into
mainfrom
claude/ruby-llm-2x-tokens

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

Makes the adapter read token counts from a RubyLLM 2.x turn. 2.0 moved the per-message readers to message.tokens and puts the round's Tokens on the chat.ruby_llm payload; the adapter only knew the 1.x readers, so every 2.x trace reported 0 tokens while its spans, timings and errors were correct. The payload's tokens is read first, then the round's messages with either generation's readers, so 1.x traces are unchanged.

Core and adapter suites pass (63 tests, 177 assertions). The fix was also run in a Rails 8.1 app mounting the dashboard, on RubyLLM 1.16.0 and 2.0.0, from the built gems: with the released adapter every 2.x trace stored 0/0 tokens; with 0.3.1 a plain chat stores 11/7 and a two-round tool turn 22/14.

Both gems are bumped to 0.3.1 (the core gem is republished unchanged so the two stay on one version, since release.yml pushes the core gem before the adapter). After merging, tag v0.3.1 to publish both through the release workflow.

Notes for this change live under docs/{issues,branches,milestones,pull-requests}/ruby-llm-2x-tokens.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hv8MDTNWmBxbus7M5ccJdv


Generated by Claude Code

RubyLLM 2.0 moved the per-message token readers to message.tokens and
puts the round's Tokens on the chat.ruby_llm payload, so the adapter
reported 0 tokens for every 2.x trace. Read the payload's tokens first,
then the round's messages with either generation's readers; 1.x traces
are unchanged. Bump both gems to 0.3.1 so the release workflow, which
pushes the core gem before the adapter, can publish from one tag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hv8MDTNWmBxbus7M5ccJdv
@TonsOfFun
TonsOfFun merged commit 314a203 into main Sep 21, 2026
6 checks passed
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.

2 participants