Skip to content

fix(claude): move model usage log to result message only#454

Merged
blackmammoth merged 1 commit into
siteboon:mainfrom
louis-thorp-datacom:fix/move-model-usage-log-to-result-message
Mar 2, 2026
Merged

fix(claude): move model usage log to result message only#454
blackmammoth merged 1 commit into
siteboon:mainfrom
louis-thorp-datacom:fix/move-model-usage-log-to-result-message

Conversation

@louis-thorp-datacom
Copy link
Copy Markdown
Contributor

@louis-thorp-datacom louis-thorp-datacom commented Feb 28, 2026

Summary

  • The 'modelUsage' debug log on line 597 of 'server/claude-sdk.js' ran on every streamed SDK message, but 'modelUsage' is only populated on 'result' messages per the SDK type definitions. This produced repeated '---> Model was sent using: []' console output for every non-result message during streaming.
  • Moved the log inside the existing 'if (message.type === 'result')' block so it fires once with the actual model data.

Summary by CodeRabbit

  • Refactor
    • Optimized debug logging by moving it to be more targeted and conditional, improving performance efficiency during result processing.

The modelUsage debug log ran on every streamed SDK message, but
modelUsage is only populated on result messages. This produced
repeated "Model was sent using: []" console output for every
non-result message during streaming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 28, 2026

📝 Walkthrough

Walkthrough

A debug log statement for modelUsage was relocated from the global message handler to the result message branch with a conditional guard to only log when modelUsage entries exist, refining debug output specificity.

Changes

Cohort / File(s) Summary
Debug Logging Adjustment
server/claude-sdk.js
Moved modelUsage debug log into the message.type === 'result' branch with a conditional guard for non-empty modelUsage, removing the unconditional log from the general message processing flow.

Possibly related PRs

Suggested reviewers

  • viper151

Poem

🐰 A log finds a new home today,
Guarded and wise, no longer at play,
In the result's embrace it shall stay,
Only when models have something to say! 📝

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving the model usage log from outside to inside the result message handling block.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@blackmammoth blackmammoth merged commit 506d431 into siteboon:main Mar 2, 2026
1 check 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