Skip to content

chore: upgrade @anthropic-ai/sdk to 0.104.1 and @anthropic-ai/vertex-sdk to 0.17.1#600

Merged
edelauna merged 4 commits into
Zoo-Code-Org:mainfrom
p12tic:anthropic-sdk-upgrade
Jun 28, 2026
Merged

chore: upgrade @anthropic-ai/sdk to 0.104.1 and @anthropic-ai/vertex-sdk to 0.17.1#600
edelauna merged 4 commits into
Zoo-Code-Org:mainfrom
p12tic:anthropic-sdk-upgrade

Conversation

@p12tic

@p12tic p12tic commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

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

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A.

Documentation Updates

Not needed.

Additional Notes

None.

Get in Touch

Mention at github.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed image handling to respect image source type across providers/transformers: base64 images are converted to data URLs, URL images use their URL, and unsupported types fall back to an appropriate placeholder.
    • Corrected tool-result content mapping so non-text items don’t incorrectly contribute text (with consistent placeholders where images are involved).
  • New Features
    • Extended markdown export to recognize and render additional block types (document, search result, tool reference), including reasoning-related blocks.
  • Tests / Chores
    • Expanded unit and e2e coverage for image/tool-result edge cases; updated SDK dependency versions and test runner commands.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f07af88-036a-4d5a-9d22-d3fe89268313

📥 Commits

Reviewing files that changed from the base of the PR and between 866b56f and 11feb81.

📒 Files selected for processing (8)
  • apps/vscode-e2e/fixtures/openrouter.json
  • apps/vscode-e2e/src/suite/providers/openrouter.test.ts
  • src/api/providers/__tests__/native-ollama.spec.ts
  • src/api/providers/__tests__/openai-codex.spec.ts
  • src/api/providers/__tests__/openai-native.spec.ts
  • src/api/transform/mistral-format.ts
  • src/api/transform/openai-format.ts
  • src/api/transform/vscode-lm-format.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/api/providers/tests/openai-codex.spec.ts
  • src/api/providers/tests/native-ollama.spec.ts
  • src/api/transform/vscode-lm-format.ts
  • src/api/transform/mistral-format.ts
  • src/api/transform/openai-format.ts

📝 Walkthrough

Walkthrough

This PR tightens image-source handling across providers and transformers, adds markdown export support for additional content block types, and updates Anthropic SDK dependency ranges.

Changes

Image Source Type Safety

Layer / File(s) Summary
Provider image and text content type safety
src/api/providers/native-ollama.ts, src/api/providers/openai-codex.ts, src/api/providers/openai-native.ts, src/api/providers/__tests__/native-ollama.spec.ts, src/api/providers/__tests__/openai-codex.spec.ts, src/api/providers/__tests__/openai-native.spec.ts
Native Ollama only reads part.text for text tool-result parts. OpenAI Codex and OpenAI Native now emit image data URLs only when image sources are base64, and the provider tests cover mixed tool-result content and request payload handling for URL/base64 images.
OpenAI format transformer image and tool-result safety
src/api/transform/openai-format.ts, src/api/transform/__tests__/openai-format.spec.ts
Tool-result mapping now separates text, image, and other part types; non-text/non-image parts become empty strings. User image parts map to image_url only for base64 sources, with URL images mapped directly and unsupported sources rendered as [Image]. Tests cover URL images, unsupported sources, mixed tool-result content, and tool-result images.
Format transformers image source validation
src/api/transform/mistral-format.ts, src/api/transform/r1-format.ts, src/api/transform/responses-api-input.ts, src/api/transform/vscode-lm-format.ts, src/api/transform/zai-format.ts, src/api/transform/__tests__/mistral-format.spec.ts, src/api/transform/__tests__/vscode-lm-format.spec.ts, src/api/transform/__tests__/zai-format.spec.ts, src/api/transform/__tests__/r1-format.spec.ts, src/api/transform/__tests__/responses-api-input.spec.ts
Mistral, R1, Responses API, VS Code LM, and ZAI transformers now branch on part.source.type before building image payloads or placeholders. The related tests cover URL images, unsupported image sources, base64 image payloads, and VS Code LM placeholder text for user and tool-result content.

Extended Content Block Type Support

Layer / File(s) Summary
Markdown export content block type expansion
src/integrations/misc/export-markdown.ts, src/integrations/misc/__tests__/export-markdown.spec.ts
ExtendedContentBlock includes ToolReferenceBlockParam, and markdown export adds placeholders for document, search_result, and tool_reference. Tests assert the new output strings.

Anthropic SDK Version Update

Layer / File(s) Summary
Anthropic SDK dependency versions
src/package.json
@anthropic-ai/sdk and @anthropic-ai/vertex-sdk dependency ranges are bumped.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I hopped through the code with care,
Base64 images now know where,
Text blocks stay text, and placeholders gleam,
Markdown learned a new rabbit dream,
While SDK carrots got a fresher sheen. 🥕

Suggested labels

awaiting-review

Suggested reviewers

  • hannesrudolph
  • navedmerchant
  • taltas
  • edelauna
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The linked issue asks for HTTP proxy support in Anthropic, but the PR mainly changes SDK versions and image/message formatting without a proxy fix. Add the actual Anthropic proxy-handling change and verify the provider works through the configured VSCode HTTP proxy.
Out of Scope Changes check ⚠️ Warning The PR includes broad image-formatting, markdown-export, e2e, and provider test changes that are unrelated to the proxy bug fix. Remove unrelated format/export/e2e changes or split them into separate PRs focused on the proxy issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main dependency upgrade in the changeset.
Description check ✅ Passed The description follows the required template and includes all major sections, even though some details are brief.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/transform/vscode-lm-format.ts 71.42% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@edelauna edelauna left a comment

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.

Thank you for taking on this dependency bump. Had a couple comments regarding image handling.

Comment thread src/api/transform/openai-format.ts Outdated
@@ -361,7 +361,10 @@ export function convertToOpenAiMessages(
toolResultImages.push(part)

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.

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 ""

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.

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]" }

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.

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]" }

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.

Mistral also supports URL images natively (imageUrl: { url: "https://..." }). Could forward source.type === "url" here instead of substituting [Image], similar to openai-format.ts.

Comment thread src/api/transform/vscode-lm-format.ts Outdated
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]`,

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.

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].

@github-actions github-actions Bot added the awaiting-author PR is waiting for the author to address requested changes label Jun 25, 2026
@edelauna edelauna force-pushed the anthropic-sdk-upgrade branch from dec03d6 to 843d235 Compare June 27, 2026 17:19

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/integrations/misc/__tests__/export-markdown.spec.ts (1)

76-100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid any in these SDK contract tests.

These cases were added to validate newly supported Anthropic block types, but as any as ExtendedContentBlock disables the compiler checks that would catch SDK shape changes after this upgrade. Please type the fixtures with satisfies 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

📥 Commits

Reviewing files that changed from the base of the PR and between dec03d6 and 843d235.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • src/api/providers/native-ollama.ts
  • src/api/providers/openai-codex.ts
  • src/api/providers/openai-native.ts
  • src/api/transform/__tests__/mistral-format.spec.ts
  • src/api/transform/__tests__/openai-format.spec.ts
  • src/api/transform/__tests__/vscode-lm-format.spec.ts
  • src/api/transform/__tests__/zai-format.spec.ts
  • src/api/transform/mistral-format.ts
  • src/api/transform/openai-format.ts
  • src/api/transform/r1-format.ts
  • src/api/transform/responses-api-input.ts
  • src/api/transform/vscode-lm-format.ts
  • src/api/transform/zai-format.ts
  • src/integrations/misc/__tests__/export-markdown.spec.ts
  • src/integrations/misc/export-markdown.ts
  • src/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

Comment thread src/api/transform/__tests__/openai-format.spec.ts Outdated

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 843d235 and 0dd9cc6.

📒 Files selected for processing (5)
  • src/api/providers/__tests__/native-ollama.spec.ts
  • src/api/transform/__tests__/openai-format.spec.ts
  • src/api/transform/__tests__/vscode-lm-format.spec.ts
  • src/api/transform/__tests__/zai-format.spec.ts
  • src/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

Comment thread src/api/providers/__tests__/native-ollama.spec.ts Outdated
@edelauna edelauna force-pushed the anthropic-sdk-upgrade branch from 0dd9cc6 to 866b56f Compare June 28, 2026 01:26
edelauna
edelauna previously approved these changes Jun 28, 2026
@edelauna edelauna enabled auto-merge June 28, 2026 02:48
@edelauna edelauna added this pull request to the merge queue Jun 28, 2026
Merged via the queue into Zoo-Code-Org:main with commit 5b7ae24 Jun 28, 2026
11 checks passed
@p12tic p12tic deleted the anthropic-sdk-upgrade branch June 28, 2026 10:23
@p12tic

p12tic commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

@edelauna Thanks for taking over and sorry for not finishing the PR in time.

hacker-b2k pushed a commit to hacker-b2k/Zoo-Code that referenced this pull request Jun 29, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author PR is waiting for the author to address requested changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] HTTP proxy is ignored on Anthropic provider

2 participants