fix(ruby_llm): read token counts from RubyLLM 2.x turns - #6
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the adapter read token counts from a RubyLLM 2.x turn. 2.0 moved the per-message readers to
message.tokensand puts the round'sTokenson thechat.ruby_llmpayload; 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'stokensis 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.ymlpushes the core gem before the adapter). After merging, tagv0.3.1to 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