chore: upgrade @anthropic-ai/sdk to 0.104.1 and @anthropic-ai/vertex-sdk to 0.17.1#600
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis PR tightens image-source handling across providers and transformers, adds markdown export support for additional content block types, and updates Anthropic SDK dependency ranges. ChangesImage Source Type Safety
Extended Content Block Type Support
Anthropic SDK Version Update
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
edelauna
left a comment
There was a problem hiding this comment.
Thank you for taking on this dependency bump. Had a couple comments regarding image handling.
| @@ -361,7 +361,10 @@ export function convertToOpenAiMessages( | |||
| toolResultImages.push(part) | |||
There was a problem hiding this comment.
Should this push be guarded with if (part.source.type === "base64")? A URL-sourced image would get pushed here and emit "(see following user message for image)", but the follow-up flush block at line 385 is commented out — so the image silently disappears while the placeholder still goes to the model.
| if (part.type === "text") { | ||
| return part.text | ||
| } | ||
| return "" |
There was a problem hiding this comment.
In SDK 0.104.1, ToolResultBlockParam.content is Array<TextBlockParam | ImageBlockParam | SearchResultBlockParam | DocumentBlockParam | ToolReferenceBlockParam>. Could a SearchResultBlockParam or DocumentBlockParam inside a tool result end up here and get silently dropped as ""?
| image_url: { url: `data:${part.source.media_type};base64,${part.source.data}` }, | ||
| } | ||
| } | ||
| return { type: "text", text: "[Image]" } |
There was a problem hiding this comment.
OpenAI chat completions supports URL images natively via { type: "image_url", image_url: { url: "https://..." } }. ai-sdk.ts already handles this case at line 63 as a reference. Worth forwarding URL sources here instead of falling back to [Image]?
| }, | ||
| } | ||
| } | ||
| return { type: "text", text: "[Image]" } |
There was a problem hiding this comment.
Mistral also supports URL images natively (imageUrl: { url: "https://..." }). Could forward source.type === "url" here instead of substituting [Image], similar to openai-format.ts.
| if (part.type === "image") { | ||
| if (part.source.type === "base64") { | ||
| return new vscode.LanguageModelTextPart( | ||
| `[Image (${part.source?.type || "Unknown source-type"}): ${part.source?.media_type || "unknown media-type"} not supported by VSCode LM API]`, |
There was a problem hiding this comment.
Inside if (part.source.type === "base64"), part.source?.type is always "base64" — the optional chain and || "Unknown source-type" fallback are dead. Could simplify to [Image (base64): ${part.source.media_type} not supported by VSCode LM API].
dec03d6 to
843d235
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/integrations/misc/__tests__/export-markdown.spec.ts (1)
76-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid
anyin these SDK contract tests.These cases were added to validate newly supported Anthropic block types, but
as any as ExtendedContentBlockdisables the compiler checks that would catch SDK shape changes after this upgrade. Please type the fixtures withsatisfies ExtendedContentBlock(or the specific Anthropic block param types) so the tests fail at compile time when the upstream contract drifts.Suggested change
it("should format document blocks", () => { const block = { type: "document", source: { type: "base64", media_type: "application/pdf", data: "abc" }, - } as any as ExtendedContentBlock + } satisfies ExtendedContentBlock expect(formatContentBlockToMarkdown(block)).toBe("[Document]") }) it("should format search_result blocks", () => { const block = { type: "search_result", source: "https://example.com", title: "Example", content: [], - } as any as ExtendedContentBlock + } satisfies ExtendedContentBlock expect(formatContentBlockToMarkdown(block)).toBe("[Search Result]") }) it("should format tool_reference blocks", () => { const block = { type: "tool_reference", id: "tool-1", name: "read_file", - } as any as ExtendedContentBlock + } satisfies ExtendedContentBlock expect(formatContentBlockToMarkdown(block)).toBe("[Tool Reference]") })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/integrations/misc/__tests__/export-markdown.spec.ts` around lines 76 - 100, The new Anthropic block fixtures in export-markdown.spec.ts are bypassing type safety by casting through any, which hides upstream contract changes. Update the document, search_result, and tool_reference test fixtures to be typed with satisfies ExtendedContentBlock or the corresponding Anthropic block parameter types so the compiler validates their shape. Keep the assertions in formatContentBlockToMarkdown tests unchanged, and use the existing formatContentBlockToMarkdown and ExtendedContentBlock symbols to locate the cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/transform/__tests__/openai-format.spec.ts`:
- Around line 146-168: The test case in convertToOpenAiMessages is mislabeled
and only exercises the URL image branch instead of the base64 tool_result path.
Update the fixture in this spec so it matches the intended behavior: either
rename the test to reflect URL placeholder handling, or change the
Anthropic.Messages.MessageParam content to use the base64 image source and
assert the corresponding OpenAI output. If both behaviors matter, split this
into two focused cases in openai-format.spec.ts so the base64 and URL branches
are each covered by their own test.
---
Nitpick comments:
In `@src/integrations/misc/__tests__/export-markdown.spec.ts`:
- Around line 76-100: The new Anthropic block fixtures in
export-markdown.spec.ts are bypassing type safety by casting through any, which
hides upstream contract changes. Update the document, search_result, and
tool_reference test fixtures to be typed with satisfies ExtendedContentBlock or
the corresponding Anthropic block parameter types so the compiler validates
their shape. Keep the assertions in formatContentBlockToMarkdown tests
unchanged, and use the existing formatContentBlockToMarkdown and
ExtendedContentBlock symbols to locate the cases.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 08c5cc71-2ec5-46b9-b7f9-1dc234373e97
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
src/api/providers/native-ollama.tssrc/api/providers/openai-codex.tssrc/api/providers/openai-native.tssrc/api/transform/__tests__/mistral-format.spec.tssrc/api/transform/__tests__/openai-format.spec.tssrc/api/transform/__tests__/vscode-lm-format.spec.tssrc/api/transform/__tests__/zai-format.spec.tssrc/api/transform/mistral-format.tssrc/api/transform/openai-format.tssrc/api/transform/r1-format.tssrc/api/transform/responses-api-input.tssrc/api/transform/vscode-lm-format.tssrc/api/transform/zai-format.tssrc/integrations/misc/__tests__/export-markdown.spec.tssrc/integrations/misc/export-markdown.tssrc/package.json
✅ Files skipped from review due to trivial changes (3)
- src/api/transform/responses-api-input.ts
- src/api/transform/r1-format.ts
- src/api/providers/native-ollama.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/api/providers/openai-native.ts
- src/api/providers/openai-codex.ts
- src/package.json
- src/api/transform/zai-format.ts
- src/integrations/misc/export-markdown.ts
- src/api/transform/mistral-format.ts
- src/api/transform/openai-format.ts
- src/api/transform/vscode-lm-format.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/providers/__tests__/native-ollama.spec.ts`:
- Around line 119-126: The native Ollama test is asserting the current
empty-string join artifact instead of the intended dropped-block behavior.
Update the expectation in native-ollama.spec.ts around mockChat to use the
contract that non-text blocks are omitted, so the user content matches line
one\nline two; this keeps the test aligned with the behavior that
native-ollama.ts should implement.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d45f9392-0f89-4ee7-a397-3d9f0329b118
📒 Files selected for processing (5)
src/api/providers/__tests__/native-ollama.spec.tssrc/api/transform/__tests__/openai-format.spec.tssrc/api/transform/__tests__/vscode-lm-format.spec.tssrc/api/transform/__tests__/zai-format.spec.tssrc/integrations/misc/__tests__/export-markdown.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/integrations/misc/tests/export-markdown.spec.ts
- src/api/transform/tests/zai-format.spec.ts
- src/api/transform/tests/vscode-lm-format.spec.ts
- src/api/transform/tests/openai-format.spec.ts
0dd9cc6 to
866b56f
Compare
|
@edelauna Thanks for taking over and sorry for not finishing the PR in time. |
…sdk to 0.17.1 (Zoo-Code-Org#600) * chore: upgrade @anthropic-ai/sdk to 0.104.1 and @anthropic-ai/vertex-sdk to 0.17.1 * fix(transform): handle URL-sourced images and non-base64 blocks in format converters * test: bumping coverage * test(e2e): adding image test --------- Co-authored-by: Elliott de Launay <edelauna@gmail.com> # Conflicts: # src/api/transform/vscode-lm-format.ts
Related GitHub Issue
Closes: #438
Description
Upgrades Anthropic AI SDK to newer version.
Test Procedure
Check if Anthropic provider still runs fine.
Pre-Submission Checklist
Screenshots / Videos
N/A.
Documentation Updates
Not needed.
Additional Notes
None.
Get in Touch
Mention at github.
Summary by CodeRabbit