Skip to content

chore: upgrade @anthropic-ai/claude-agent-sdk to version 0.2.59 and add model usage logging#446

Merged
viper151 merged 1 commit into
mainfrom
chore/upgrade-claude-sdk-to-support-opus-and-sonnet-4.6
Feb 26, 2026
Merged

chore: upgrade @anthropic-ai/claude-agent-sdk to version 0.2.59 and add model usage logging#446
viper151 merged 1 commit into
mainfrom
chore/upgrade-claude-sdk-to-support-opus-and-sonnet-4.6

Conversation

@blackmammoth
Copy link
Copy Markdown
Collaborator

@blackmammoth blackmammoth commented Feb 26, 2026

this upgrades the claude-agent-sdk to the latest version to support opus 4.6 and sonnet 4.6.

We can verify which model we are using by observing the server side console logs.

Summary by CodeRabbit

  • Chores
    • Updated Claude Agent SDK dependency to the latest compatible version.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The pull request updates the @anthropic-ai/claude-agent-sdk dependency from version ^0.1.71 to ^0.2.59 and adds debug logging to track model usage information for incoming messages in the Claude SDK integration.

Changes

Cohort / File(s) Summary
Dependency Update
package.json
Updated @anthropic-ai/claude-agent-sdk dependency version from ^0.1.71 to ^0.2.59.
Debug Logging
server/claude-sdk.js
Added debug log statement to output model usage keys from incoming messages, positioned after session_id handling and before WebSocket transmission.

Suggested reviewers

  • viper151
  • jarrodshillo0-rgb

Poem

🐰 With Claude's SDK bumped up high,
Debug logs now reveal the "why,"
Models tracked with each request,
Your insights now are at their best!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both main changes: the SDK upgrade to version 0.2.59 and the addition of model usage logging, which align with the changeset modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/upgrade-claude-sdk-to-support-opus-and-sonnet-4.6

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 48: Update PR to verify and document the SDK upgrade: ensure your
environment uses Node.js >= 18 and that the project has a compatible Zod version
(peer dependency, e.g., zod ^4.x) before keeping
"@anthropic-ai/claude-agent-sdk": "^0.2.59" in package.json, run and commit the
results of npm run build and the test suite (npm test or the repo's test
script), and add a short note in the PR description confirming build/tests
passed and any Claude Code CLI compatibility checks performed (include the exact
Node and zod versions used and test output/log snippets).

In `@server/claude-sdk.js`:
- Around line 596-598: Remove the unconditional console.log that prints
Object.keys(message.modelUsage || {}) inside the streaming loop; instead, check
whether message.modelUsage is present before logging (matching the pattern used
later around the existing conditional at line 611). Locate the log by searching
for the console.log call that mentions "Model was sent using:" and wrap it in a
guard like if (message.modelUsage) { ... } so empty arrays are not logged when
modelUsage is absent.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ab94fc and e76b389.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json
  • server/claude-sdk.js

Comment thread package.json
"license": "GPL-3.0",
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.1.71",
"@anthropic-ai/claude-agent-sdk": "^0.2.59",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

@anthropic-ai/claude-agent-sdk 0.2.59 release notes changelog breaking changes

💡 Result:

@anthropic-ai/claude-agent-sdk v0.2.59 (TypeScript) changelog:

  • Added: getSessionMessages() to read a session’s conversation history from its transcript file, including pagination via limit and offset. [1]

Breaking changes: None are mentioned for v0.2.59 in the official TypeScript SDK changelog entry. [1]

Note (Python): The Python SDK uses a different version line; its latest changelog entry references bundling Claude CLI v2.1.59 under SDK v0.1.44. [2]

Sources: [1] [2]


🌐 Web query:

@anthropic-ai/claude-agent-sdk message.modelUsage support version

💡 Result:

message.modelUsage is supported on SDKResultMessage (both subtype: "success" and error subtypes) in the TypeScript Claude Agent SDK; it’s a per-model breakdown shaped like { [modelName: string]: ModelUsage }. [1]

To have this field available, use a current SDK version—v0.2.59 is the latest published as of Feb 26, 2026. [2]

Sources
[1] Claude API Docs – Agent SDK reference (TypeScript) (SDKResultMessage includes modelUsage) (platform.claude.com)
[2] GitHub Releases – @anthropic-ai/claude-agent-sdk v0.2.59 (github.com)

Citations:


🌐 Web query:

@anthropic-ai/claude-agent-sdk 0.1.71 0.2.59 upgrade compatibility

💡 Result:

Upgrading @anthropic-ai/claude-agent-sdk from 0.1.71 → 0.2.59 is generally a minor-version bump (0.1 → 0.2), but there are a few practical compatibility constraints to check:

  • Node runtime: 0.2.59 requires Node >= 18. [1]
  • Zod peer dependency: 0.2.59 declares zod as a peerDependency ^4.0.0, so projects still on Zod v3 will need to upgrade (or you’ll get peer-dep warnings / possible type/runtime mismatches). [1]
  • Claude Code CLI coupling: 0.2.59 is built against Claude Code CLI 2.1.59 (field claudeCodeVersion: "2.1.59"). In practice, you should ensure your environment is running a compatible/new-enough Claude Code CLI (often installed separately via npm install -g @anthropic-ai/claude-code``). [1][2]
  • API surface changes vs earlier generations: if your code still relies on older “Claude Code SDK” defaults (auto-loading filesystem settings / default system prompt), those were breaking changes introduced earlier in the Agent SDK line—double-check your query({ options: ... }) configuration if behavior changes after upgrading. [3]

Recommended upgrade steps

  1. Upgrade CLI (if you use it separately): npm i -g @anthropic-ai/claude-code`` (aim for compatibility with 2.1.59). [1][2]
  2. Upgrade SDK: npm i @anthropic-ai/claude-agent-sdk@0.2.59. [1]
  3. Ensure zod@^4 is installed in your app. [1]

Sources: [1] (0.2.59 package metadata), [2] (Agent SDK hosting/system requirements mentioning Claude Code CLI), [3] (Agent SDK migration guide on behavior-breaking defaults).


Provide build/test verification and confirm dependency compatibility for this SDK upgrade.

The @anthropic-ai/claude-agent-sdk v0.2.59 upgrade has no documented breaking changes and properly supports message.modelUsage on SDKResultMessage. However, ensure the following practical dependencies are satisfied:

  • Node.js >= 18 (required by v0.2.59)
  • Zod ^4.0.0 (peer dependency; confirm your app has this version)
  • Claude Code CLI 2.1.59 compatibility (if used in this environment)

Per Contributing.md guidelines, add evidence to the PR that npm run build and tests pass with this upgrade.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 48, Update PR to verify and document the SDK upgrade:
ensure your environment uses Node.js >= 18 and that the project has a compatible
Zod version (peer dependency, e.g., zod ^4.x) before keeping
"@anthropic-ai/claude-agent-sdk": "^0.2.59" in package.json, run and commit the
results of npm run build and the test suite (npm test or the repo's test
script), and add a short note in the PR description confirming build/tests
passed and any Claude Code CLI compatibility checks performed (include the exact
Node and zod versions used and test output/log snippets).

Comment thread server/claude-sdk.js
Comment on lines +596 to +598
// logs which model was used in the message
console.log("---> Model was sent using:", Object.keys(message.modelUsage || {}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the actual code context around lines 596-598
cat -n server/claude-sdk.js | sed -n '580,620p'

Repository: siteboon/claudecodeui

Length of output: 1793


🏁 Script executed:

# Let's also check the broader context to understand the loop structure
cat -n server/claude-sdk.js | sed -n '560,600p'

Repository: siteboon/claudecodeui

Length of output: 1985


🏁 Script executed:

# Search for where message.modelUsage is used or set
rg "modelUsage" server/claude-sdk.js -B 2 -A 2

Repository: siteboon/claudecodeui

Length of output: 783


🏁 Script executed:

# Check if there are any other uses of console.log in streaming loops
rg "console\.(log|debug)" server/claude-sdk.js -B 3 -A 1

Repository: siteboon/claudecodeui

Length of output: 3392


Remove unconditional logging of empty model-usage keys from streaming loop.

This logs on every streamed message and produces empty arrays when modelUsage is absent, adding noise without value. Gate it by checking if modelUsage exists, matching the existing conditional pattern in the file (line 611).

-      // logs which model was used in the message
-      console.log("---> Model was sent using:", Object.keys(message.modelUsage || {}));
+      // logs which model was used in the message
+      if (message.modelUsage) {
+        console.log("---> Model was sent using:", Object.keys(message.modelUsage));
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/claude-sdk.js` around lines 596 - 598, Remove the unconditional
console.log that prints Object.keys(message.modelUsage || {}) inside the
streaming loop; instead, check whether message.modelUsage is present before
logging (matching the pattern used later around the existing conditional at line
611). Locate the log by searching for the console.log call that mentions "Model
was sent using:" and wrap it in a guard like if (message.modelUsage) { ... } so
empty arrays are not logged when modelUsage is absent.

@viper151 viper151 merged commit 917c353 into main Feb 26, 2026
4 checks passed
@blackmammoth blackmammoth deleted the chore/upgrade-claude-sdk-to-support-opus-and-sonnet-4.6 branch March 5, 2026 10:50
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.

3 participants