Skip to content

vertex + anthropic fixes#3055

Merged
akshaydeo merged 3 commits intomainfrom
04-26-vertex_anthropic_fixes
Apr 27, 2026
Merged

vertex + anthropic fixes#3055
akshaydeo merged 3 commits intomainfrom
04-26-vertex_anthropic_fixes

Conversation

@akshaydeo
Copy link
Copy Markdown
Contributor

@akshaydeo akshaydeo commented Apr 26, 2026

Summary

Disables context-management beta header support on Vertex AI after live API errors confirmed it is unsupported. This prevents ClearToolUses/ClearThinking context editing fields from being forwarded to Vertex, which would cause 400 errors.

Changes

  • Removed ContextEditing: true from the Vertex provider feature support map, reflecting that the context-management beta is not supported on Vertex (confirmed via live API 400 error).
  • Added AnthropicContextManagementBetaHeaderPrefix constant to enable prefix-based filtering of the context-management beta header.
  • Updated filterVertexUnsupportedBetaHeaders in the HTTP transport to strip any context-management-* beta headers before forwarding requests to Vertex.
  • Added a call to StripUnsupportedFieldsFromRawBody in the Vertex provider's ChatCompletion path to remove unsupported fields (e.g., context editing edits) from the raw request body before sending.
  • Updated tests to reflect that AnthropicContextManagementBetaHeader is now in the unsupported set for Vertex rather than the supported set.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

go test ./core/providers/anthropic/...
go test ./core/providers/vertex/...
go test ./transports/bifrost-http/...

Send a request with a context-management beta header or context editing fields (e.g., ClearToolUses/ClearThinking) targeting a Vertex-backed model and confirm no 400 error is returned and the header/fields are stripped before forwarding.

Breaking changes

  • Yes
  • No

Related issues

References live API error confirming Vertex returns 400 for context-management beta header.

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Extended context-management support and beta-header controls for Anthropic, Bedrock, and Azure.
  • Bug Fixes

    • Corrected beta-header merge precedence and simplified passthrough header handling.
    • Providers now strip or preserve context-management fields according to capabilities; Vertex enforces stripping and fails early on unsupported payloads.
  • Tests

    • Added tests for beta-header overrides and raw-body stripping behavior.
  • Documentation

    • Minor changelog formatting updates.

Walkthrough

Adds Anthropic beta-header prefixes and a ContextManagement feature flag; reorders MergeBetaHeaders to take ctx first; changes raw-body stripping to gate the entire context_management object when unsupported; Vertex now strips unsupported context_management and fails early on strip errors; transport passthrough header parsing simplified and provider-aware beta filtering moved downstream; tests updated.

Changes

Cohort / File(s) Summary
Anthropic types & features
core/providers/anthropic/types.go
Added AnthropicContextManagementBetaHeaderPrefix = "context-management-", AnthropicCompactionBetaHeaderPrefix = "compact-", and ProviderFeatureSupport.ContextManagementField bool; enabled ContextManagementField for schemas.Anthropic, schemas.Bedrock, and schemas.Azure; removed ContextEditing: true from schemas.Vertex.
Anthropic utils & tests
core/providers/anthropic/utils.go, core/providers/anthropic/utils_test.go
Changed MergeBetaHeaders signature to (ctx context.Context, providerExtraHeaders map[string]string), switched comma-splitting to strings.SplitSeq, simplified unique-append logic; StripUnsupportedFieldsFromRawBody now deletes whole context_management when provider lacks ContextManagementField and performs per-edit filtering when supported; tests updated and new TestNetworkConfigBetaOverridesFlow added; vertex expectations adjusted.
Anthropic request builders & callers
core/providers/anthropic/request_builder.go, core/providers/anthropic/anthropic.go
Reordered calls to MergeBetaHeaders(ctx, extraHeaders) across Anthropic request paths so ctx-derived beta entries take precedence; existing beta filtering remains.
Azure & Bedrock Anthropic header usage
core/providers/azure/azure.go, core/providers/bedrock/bedrock.go
Swapped argument order to MergeBetaHeaders(ctx, extraHeaders) when constructing anthropic-beta for Azure and Bedrock request flows.
Vertex integration & stripping
core/providers/vertex/utils.go, core/providers/vertex/vertex.go
After building Anthropic-style request bodies, run anthropic.StripUnsupportedFieldsFromRawBody(..., schemas.Vertex, deployment) and return a wrapped BifrostOperationError on strip failure; use stripped JSON on success.
Transport passthrough & beta parsing removal
transports/bifrost-http/integrations/anthropic.go, transports/bifrost-http/integrations/anthropic_test.go
Removed filterVertexUnsupportedBetaHeaders and its dedicated tests; extractPassthroughHeaders now ignores provider and only forwards a static whitelist of safe headers (case-insensitive); comments updated to indicate provider-aware beta-header overrides happen downstream.
Config minor cleanup
transports/bifrost-http/lib/config.go
Replaced manual map population with maps.Copy(providersInConfigStore, config.Providers); renamed unused processProvider parameter to _.
Changelogs (docs only)
docs/changelogs/v1.4.23.mdx, docs/changelogs/v1.5.0-prerelease4.mdx
Reformatted NPX/Docker code blocks from multi-line to single-line fenced snippets and adjusted spacing; documentation-only formatting changes.
sequenceDiagram
    participant Client
    participant Bifrost as Bifrost HTTP Transport
    participant Adapter as Vertex Adapter
    participant AnthropicUtil as anthropic.utils
    participant VertexAI as Vertex API

    Client->>Bifrost: Send Anthropic-style request (headers + body)
    Bifrost->>Adapter: Forward request (passthrough safe headers only)
    Adapter->>Adapter: Build Anthropic request body (marshal/remap)
    Adapter->>AnthropicUtil: MergeBetaHeaders(ctx, providerExtra)
    Adapter->>AnthropicUtil: StripUnsupportedFieldsFromRawBody(rawBody, schemas.Vertex, deployment)
    alt strip succeeds
        AnthropicUtil-->>Adapter: cleanedRawBody
        Adapter->>VertexAI: Send request with cleaned body and filtered betas
    else strip fails
        AnthropicUtil-->>Adapter: error
        Adapter-->>Bifrost: Abort with wrapped BifrostOperationError
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hop through headers with a careful tap,
I nest the betas, trim the JSON's map.
Vertex snips what it cannot bear,
Anthropic keeps some edits there.
Tests twitch whiskers — tidy, snug, and apt.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.47% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and overly generic, using non-descriptive terms that do not convey the specific changes related to Vertex AI and the context-management beta header fix. Use a more specific title such as 'Disable context-management beta header on Vertex AI' or 'Fix Vertex AI 400 errors by disabling unsupported context-management beta header'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is complete and comprehensive, covering summary, changes, type of change, affected areas, testing instructions, breaking changes, and other required sections per the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 04-26-vertex_anthropic_fixes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@akshaydeo akshaydeo mentioned this pull request Apr 26, 2026
18 tasks
Copy link
Copy Markdown
Contributor Author

akshaydeo commented Apr 26, 2026

@akshaydeo akshaydeo marked this pull request as ready for review April 26, 2026 10:31
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: 1

🧹 Nitpick comments (1)
transports/bifrost-http/integrations/anthropic.go (1)

207-207: Keep the unsupported-beta comment exhaustive (or explicitly non-exhaustive).

Line 207 omits prefixes already filtered in this function (skills-, fast-mode-, redact-thinking- on Lines 237-239), which can cause maintenance drift.

Suggested comment tweak
-// Vertex AI doesn't support: structured-outputs, advanced-tool-use, prompt-caching-scope, mcp-client, context-management.
+// Vertex AI doesn't support: structured-outputs, advanced-tool-use, prompt-caching-scope,
+// mcp-client, skills, fast-mode, redact-thinking, context-management.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@transports/bifrost-http/integrations/anthropic.go` at line 207, Update the
"unsupported-beta" comment in transports/bifrost-http/integrations/anthropic.go
to either list all currently filtered prefixes or explicitly mark the list as
non-exhaustive; include the prefixes that are filtered later in this function
("skills-", "fast-mode-", "redact-thinking-") so the comment stays accurate with
the actual filtering logic (refer to the filtering code that checks those
prefixes) and avoid future maintenance drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/providers/vertex/vertex.go`:
- Around line 399-403: The streaming Anthropic branch in ChatCompletionStream is
not sanitizing the marshaled rawBody like the unary path does; update the
Anthropic streaming path to call
anthropic.StripUnsupportedFieldsFromRawBody(rawBody, schemas.Vertex,
request.Model) before sending or marshaling the payload (same as the unary chat
block), handle the returned rawBody and error (returning a wrapped fmt.Errorf on
error), and ensure you reference the same symbols used in the unary fix:
rawBody, anthropic.StripUnsupportedFieldsFromRawBody, schemas.Vertex,
request.Model, and the ChatCompletionStream Anthropic branch.

---

Nitpick comments:
In `@transports/bifrost-http/integrations/anthropic.go`:
- Line 207: Update the "unsupported-beta" comment in
transports/bifrost-http/integrations/anthropic.go to either list all currently
filtered prefixes or explicitly mark the list as non-exhaustive; include the
prefixes that are filtered later in this function ("skills-", "fast-mode-",
"redact-thinking-") so the comment stays accurate with the actual filtering
logic (refer to the filtering code that checks those prefixes) and avoid future
maintenance drift.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba59898f-fbb8-4f31-a5ac-12b00fe837b0

📥 Commits

Reviewing files that changed from the base of the PR and between cadd20e and 079bfdd.

📒 Files selected for processing (4)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go

Comment thread core/providers/vertex/vertex.go Outdated
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 079bfdd to 3610c41 Compare April 26, 2026 10:35
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.

🧹 Nitpick comments (1)
transports/bifrost-http/integrations/anthropic.go (1)

207-240: Consolidate Vertex beta-header blocking into a single source of truth.

This transport function hardcodes unsupported prefixes that are also governed in provider-level filtering, which increases drift risk across the stack. The new context-management-* addition is correct, but this is a good place to delegate to FilterBetaHeadersForProvider(..., schemas.Vertex) (or shared prefix config) and keep only parsing/joining logic here.

♻️ Suggested direction
- // transport-owned unsupported prefix checks...
- if strings.HasPrefix(beta, anthropic.AnthropicAdvancedToolUseBetaHeaderPrefix) || ...
-    strings.HasPrefix(beta, anthropic.AnthropicContextManagementBetaHeaderPrefix) {
-   continue
- }
- filteredBetas = append(filteredBetas, beta)
+ // Delegate support policy to provider-level filter to avoid duplicated lists.
+ parsedBetas = append(parsedBetas, beta)
...
+ filteredBetas = anthropic.FilterBetaHeadersForProvider(parsedBetas, schemas.Vertex)

As per coding guidelines **: always check the stack and review changes in light of the whole stack.

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

In `@transports/bifrost-http/integrations/anthropic.go` around lines 207 - 240,
The function filterVertexUnsupportedBetaHeaders currently hardcodes a list of
Anthropic beta-prefixes to drop; replace that provider-specific blocking logic
by delegating to the central filter (call FilterBetaHeadersForProvider or the
shared prefix config) for schemas.Vertex while keeping only the header lookup,
comma-splitting and recomposition logic in filterVertexUnsupportedBetaHeaders;
specifically, locate filterVertexUnsupportedBetaHeaders, remove the series of
strings.HasPrefix checks against anthropic.*BetaHeaderPrefix constants, and call
FilterBetaHeadersForProvider(headersToCheck, schemas.Vertex) (or the shared
prefix filter) to determine which beta tokens to exclude, then join remaining
tokens back into the same header key and return the modified headers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@transports/bifrost-http/integrations/anthropic.go`:
- Around line 207-240: The function filterVertexUnsupportedBetaHeaders currently
hardcodes a list of Anthropic beta-prefixes to drop; replace that
provider-specific blocking logic by delegating to the central filter (call
FilterBetaHeadersForProvider or the shared prefix config) for schemas.Vertex
while keeping only the header lookup, comma-splitting and recomposition logic in
filterVertexUnsupportedBetaHeaders; specifically, locate
filterVertexUnsupportedBetaHeaders, remove the series of strings.HasPrefix
checks against anthropic.*BetaHeaderPrefix constants, and call
FilterBetaHeadersForProvider(headersToCheck, schemas.Vertex) (or the shared
prefix filter) to determine which beta tokens to exclude, then join remaining
tokens back into the same header key and return the modified headers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 136f74fd-71a9-481f-9006-73a2e0114695

📥 Commits

Reviewing files that changed from the base of the PR and between 079bfdd and 3610c41.

📒 Files selected for processing (4)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/providers/anthropic/types.go

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 26, 2026

Confidence Score: 5/5

Safe to merge — the fix is well-scoped, well-tested, and all findings are P2 style issues.

No P0 or P1 findings. The two P2 comments are a documentation formatting regression and an unused constant/inconsistent literal usage — neither affects runtime behaviour.

docs/changelogs/v1.4.23.mdx and docs/changelogs/v1.5.0-prerelease4.mdx have collapsed code-fence blocks that will break rendered output.

Important Files Changed

Filename Overview
core/providers/anthropic/types.go Adds ContextManagementField feature flag and two new beta-header-prefix constants; removes ContextEditing from Vertex and adds ContextManagementField: true to Anthropic/Bedrock/Azure — correctly models provider capabilities.
core/providers/anthropic/utils.go Refactors StripUnsupportedFieldsFromRawBody to drop context_management entirely when ContextManagementField is false; fixes MergeBetaHeaders argument order; new prefix constants are declared but not used in the canonical maps (P2).
core/providers/vertex/vertex.go Adds StripUnsupportedFieldsFromRawBody call in both ChatCompletion and ChatCompletionStream paths, covering structured and raw-passthrough bodies; also fixes MergeBetaHeaders argument order.
core/providers/vertex/utils.go Adds StripUnsupportedFieldsFromRawBody call in the Responses API path for Vertex; correctly handles the build error before stripping.
transports/bifrost-http/integrations/anthropic.go Removes the now-redundant filterVertexUnsupportedBetaHeaders function and simplifies extractPassthroughHeaders; beta-header filtering correctly delegated to provider wire layers.
transports/bifrost-http/integrations/anthropic_test.go Test file deleted as it covered only the removed filterVertexUnsupportedBetaHeaders function; new coverage lives in utils_test.go.
core/providers/anthropic/utils_test.go Moves AnthropicContextManagementBetaHeader from supported to unsupported set for Vertex; adds thorough new tests for provider-aware beta-override flow and Vertex-specific body stripping.
docs/changelogs/v1.4.23.mdx Code fences collapsed onto single lines will break rendering; NPX and Docker install blocks need multi-line fence syntax.
docs/changelogs/v1.5.0-prerelease4.mdx Same collapsed code-fence issue as v1.4.23.mdx — install blocks will not render as formatted code.
transports/bifrost-http/lib/config.go Minor cleanup: manual map-copy loop replaced with maps.Copy; unused *Config param in processProvider blanked.
core/providers/anthropic/anthropic.go Three call-sites updated to flip MergeBetaHeaders argument order; no logic change.
core/providers/azure/azure.go Single MergeBetaHeaders call-site updated to match new argument order; no logic change.
core/providers/bedrock/bedrock.go Two MergeBetaHeaders call-sites updated to match new argument order; no logic change.

Reviews (10): Last reviewed commit: "vertex + anthropic fixes" | Re-trigger Greptile

@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 3610c41 to dab7e1d Compare April 26, 2026 11:02
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.

🧹 Nitpick comments (1)
transports/bifrost-http/integrations/anthropic.go (1)

207-207: Keep the unsupported-header comment synchronized with actual filters.

Line 207 lists unsupported betas but omits skills, fast-mode, and redact-thinking, which are also filtered below. Consider broadening or updating the comment to avoid drift.

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

In `@transports/bifrost-http/integrations/anthropic.go` at line 207, The inline
comment "Vertex AI doesn't support: structured-outputs, advanced-tool-use,
prompt-caching-scope, mcp-client, context-management." is out of sync with the
actual filter list below (which also filters "skills", "fast-mode", and
"redact-thinking"); update that comment to either enumerate the missing flags
("skills", "fast-mode", "redact-thinking") or broaden it (e.g., "Vertex AI
doesn't support: structured-outputs, advanced-tool-use, prompt-caching-scope,
mcp-client, context-management, skills, fast-mode, redact-thinking") so the
unsupported-header comment matches the filters in this file and won't drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@transports/bifrost-http/integrations/anthropic.go`:
- Line 207: The inline comment "Vertex AI doesn't support: structured-outputs,
advanced-tool-use, prompt-caching-scope, mcp-client, context-management." is out
of sync with the actual filter list below (which also filters "skills",
"fast-mode", and "redact-thinking"); update that comment to either enumerate the
missing flags ("skills", "fast-mode", "redact-thinking") or broaden it (e.g.,
"Vertex AI doesn't support: structured-outputs, advanced-tool-use,
prompt-caching-scope, mcp-client, context-management, skills, fast-mode,
redact-thinking") so the unsupported-header comment matches the filters in this
file and won't drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 241683f0-c3ef-4d03-8508-e4c19b59a6c0

📥 Commits

Reviewing files that changed from the base of the PR and between 3610c41 and dab7e1d.

📒 Files selected for processing (6)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/providers/anthropic/utils_test.go
  • core/providers/anthropic/types.go

@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from dab7e1d to 145de6d Compare April 26, 2026 11:53
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

🧹 Nitpick comments (2)
transports/bifrost-http/integrations/anthropic.go (1)

233-240: Prefer centralized beta filtering to prevent prefix drift.

This hardcoded HasPrefix chain can diverge from the provider-wide beta filtering logic as new prefixes are added (for example, additional families defined in core/providers/anthropic/types.go). Consider routing through a shared filter path (e.g., anthropic.FilterBetaHeadersForProvider) and then rebuilding the anthropic-beta header from the filtered tokens.

Based on learnings: In maximhq/bifrost’s Vertex anthropic-beta handling, filtering is intended to be centralized via anthropic.FilterBetaHeadersForProvider(...) to keep prefix-based behavior consistent.

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

In `@transports/bifrost-http/integrations/anthropic.go` around lines 233 - 240,
Replace the long chain of strings.HasPrefix checks for individual prefixes
(e.g., anthropic.AnthropicAdvancedToolUseBetaHeaderPrefix,
AnthropicStructuredOutputsBetaHeaderPrefix,
AnthropicPromptCachingScopeBetaHeaderPrefix, AnthropicMCPClientBetaHeaderPrefix,
AnthropicSkillsBetaHeaderPrefix, AnthropicFastModeBetaHeaderPrefix,
AnthropicRedactThinkingBetaHeaderPrefix,
AnthropicContextManagementBetaHeaderPrefix) with a call into the shared filter
function (anthropic.FilterBetaHeadersForProvider) to centralize prefix logic;
pass the list of beta tokens (the variable `beta` or the token slice you
currently iterate) into FilterBetaHeadersForProvider, use its returned filtered
tokens to rebuild the `anthropic-beta` header value, and remove the per-prefix
HasPrefix checks so provider-wide additions are handled consistently.
core/providers/vertex/vertex.go (1)

481-483: Preserve underlying strip errors instead of dropping the cause.

These branches currently create BifrostOperationError with a nil wrapped error, which loses root-cause detail in logs and tracing.

Suggested error-wrapping adjustment
-		if stripErr != nil {
-			return nil, providerUtils.NewBifrostOperationError(stripErr.Error(), nil)
-		}
+		if stripErr != nil {
+			return nil, providerUtils.NewBifrostOperationError("failed to strip unsupported fields", stripErr)
+		}

Also applies to: 770-772

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

In `@core/providers/vertex/vertex.go` around lines 481 - 483, The code constructs
a BifrostOperationError using
providerUtils.NewBifrostOperationError(stripErr.Error(), nil) which discards the
original error; change these calls to pass the underlying error as the wrapped
cause (e.g., providerUtils.NewBifrostOperationError(stripErr.Error(), stripErr))
so the original stripErr is preserved for logging/tracing; update the occurrence
shown around the if stripErr != nil block and the similar instance later in the
same file (the other NewBifrostOperationError call) to wrap the original error
instead of passing nil.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/providers/anthropic/utils.go`:
- Around line 456-496: Update the typed sanitizer to mirror the new JSON-path
short-circuit: inside stripUnsupportedAnthropicFields (the typed-path sanitizer)
check features.ContextManagementField and if false remove/ignore the entire
context_management payload (same as the JSON-field branch that calls
providerUtils.DeleteJSONField("context_management")); otherwise continue
applying per-edit gates (e.g., only keep edits when features.Compaction or
features.ContextEditing allow them) for context_management.edits so the typed
and raw sanitizers behave identically.

In `@transports/bifrost-http/integrations/anthropic.go`:
- Line 207: Update the inline comment that currently lists unsupported beta
families for Vertex AI to match the actual filter logic: include "skills",
"fast-mode", and "redact-thinking" in the comment so it reflects the families
being stripped by the filtering code that removes unsupported beta families for
the Anthropic/Vertex integration; ensure the comment near the Vertex AI note
mirrors the same list used in the stripping logic.

---

Nitpick comments:
In `@core/providers/vertex/vertex.go`:
- Around line 481-483: The code constructs a BifrostOperationError using
providerUtils.NewBifrostOperationError(stripErr.Error(), nil) which discards the
original error; change these calls to pass the underlying error as the wrapped
cause (e.g., providerUtils.NewBifrostOperationError(stripErr.Error(), stripErr))
so the original stripErr is preserved for logging/tracing; update the occurrence
shown around the if stripErr != nil block and the similar instance later in the
same file (the other NewBifrostOperationError call) to wrap the original error
instead of passing nil.

In `@transports/bifrost-http/integrations/anthropic.go`:
- Around line 233-240: Replace the long chain of strings.HasPrefix checks for
individual prefixes (e.g., anthropic.AnthropicAdvancedToolUseBetaHeaderPrefix,
AnthropicStructuredOutputsBetaHeaderPrefix,
AnthropicPromptCachingScopeBetaHeaderPrefix, AnthropicMCPClientBetaHeaderPrefix,
AnthropicSkillsBetaHeaderPrefix, AnthropicFastModeBetaHeaderPrefix,
AnthropicRedactThinkingBetaHeaderPrefix,
AnthropicContextManagementBetaHeaderPrefix) with a call into the shared filter
function (anthropic.FilterBetaHeadersForProvider) to centralize prefix logic;
pass the list of beta tokens (the variable `beta` or the token slice you
currently iterate) into FilterBetaHeadersForProvider, use its returned filtered
tokens to rebuild the `anthropic-beta` header value, and remove the per-prefix
HasPrefix checks so provider-wide additions are handled consistently.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d585cb8-385b-41b5-9d2d-53d5be0a7127

📥 Commits

Reviewing files that changed from the base of the PR and between dab7e1d and 145de6d.

📒 Files selected for processing (6)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
✅ Files skipped from review due to trivial changes (1)
  • transports/bifrost-http/lib/config.go

Comment thread core/providers/anthropic/utils.go
Comment thread transports/bifrost-http/integrations/anthropic.go Outdated
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 145de6d to 1de1e53 Compare April 26, 2026 13:20
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.

♻️ Duplicate comments (1)
transports/bifrost-http/integrations/anthropic.go (1)

207-207: ⚠️ Potential issue | 🟡 Minor

Comment still omits three filtered header families.

The comment at line 207 was updated to add context-management, but it still doesn't list skills, fast-mode, and redact-thinking which are filtered at lines 237-238. This discrepancy was flagged previously.

✏️ Suggested update
-// Vertex AI doesn't support: structured-outputs, advanced-tool-use, prompt-caching-scope, mcp-client, context-management.
+// Vertex AI doesn't support: structured-outputs, advanced-tool-use, prompt-caching-scope,
+// mcp-client, skills, fast-mode, redact-thinking, context-management.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@transports/bifrost-http/integrations/anthropic.go` at line 207, Update the
in-file comment that begins "Vertex AI doesn't support:" to list all filtered
header families; specifically add "skills", "fast-mode", and "redact-thinking"
alongside the existing items (structured-outputs, advanced-tool-use,
prompt-caching-scope, mcp-client, context-management) so the comment accurately
reflects the header filtering implemented (the code that filters header families
including "skills", "fast-mode", and "redact-thinking").
🧹 Nitpick comments (1)
core/providers/anthropic/utils_test.go (1)

1306-1315: Harden Anthropic keep-path assertions beyond top-level field existence.

At Line 1313 you only assert context_management exists. This can pass even if edits are emptied or a clear edit type is accidentally stripped. Consider asserting preserved edit count/types (and include clear_thinking too) to make this regression-proof.

♻️ Suggested test hardening
 t.Run("anthropic_keeps_context_management_per_edit_type", func(t *testing.T) {
-	// Anthropic supports context_management; compact edits are kept, clear edits are also kept.
-	input := []byte(`{"model":"claude-sonnet-4-6","context_management":{"edits":[{"type":"` + string(ContextManagementEditTypeCompact) + `"},{"type":"` + string(ContextManagementEditTypeClearToolUses) + `"}]}}`)
+	// Anthropic supports context_management; all edit types should be preserved.
+	input := []byte(`{"model":"claude-sonnet-4-6","context_management":{"edits":[{"type":"` + string(ContextManagementEditTypeCompact) + `"},{"type":"` + string(ContextManagementEditTypeClearToolUses) + `"},{"type":"` + string(ContextManagementEditTypeClearThinking) + `"}]}}`)
 	result, err := StripUnsupportedFieldsFromRawBody(input, schemas.Anthropic, "claude-sonnet-4-6")
 	if err != nil {
 		t.Fatalf("unexpected error: %v", err)
 	}
 	if !providerUtils.JSONFieldExists(result, "context_management") {
 		t.Errorf("expected context_management to be kept for Anthropic, got: %s", string(result))
 	}
+	edits := providerUtils.GetJSONField(result, "context_management.edits").Array()
+	if len(edits) != 3 {
+		t.Fatalf("expected 3 edits preserved for Anthropic, got %d: %s", len(edits), string(result))
+	}
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/providers/anthropic/utils_test.go` around lines 1306 - 1315, The test
currently only checks top-level existence of "context_management"; instead
update the test for anthopic_keeps_context_management_per_edit_type to parse the
result JSON from StripUnsupportedFieldsFromRawBody and assert that
context_management.edits contains the expected edits (including types
ContextManagementEditTypeCompact, ContextManagementEditTypeClearToolUses and
clear_thinking) and that the edits array length matches expected (i.e., none
were removed). Use providerUtils.JSONFieldExists only for initial presence, then
decode the edits array and assert element types/count to harden the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@transports/bifrost-http/integrations/anthropic.go`:
- Line 207: Update the in-file comment that begins "Vertex AI doesn't support:"
to list all filtered header families; specifically add "skills", "fast-mode",
and "redact-thinking" alongside the existing items (structured-outputs,
advanced-tool-use, prompt-caching-scope, mcp-client, context-management) so the
comment accurately reflects the header filtering implemented (the code that
filters header families including "skills", "fast-mode", and "redact-thinking").

---

Nitpick comments:
In `@core/providers/anthropic/utils_test.go`:
- Around line 1306-1315: The test currently only checks top-level existence of
"context_management"; instead update the test for
anthopic_keeps_context_management_per_edit_type to parse the result JSON from
StripUnsupportedFieldsFromRawBody and assert that context_management.edits
contains the expected edits (including types ContextManagementEditTypeCompact,
ContextManagementEditTypeClearToolUses and clear_thinking) and that the edits
array length matches expected (i.e., none were removed). Use
providerUtils.JSONFieldExists only for initial presence, then decode the edits
array and assert element types/count to harden the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c697db2-038a-4ae0-9c55-fb0be1c9b162

📥 Commits

Reviewing files that changed from the base of the PR and between 145de6d and 1de1e53.

📒 Files selected for processing (7)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/providers/anthropic/types.go

This was referenced Apr 26, 2026
@akshaydeo akshaydeo force-pushed the 04-26-adds_message_filter_flow_for_log_details_messages branch from cadd20e to ea715ea Compare April 27, 2026 08:23
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 1de1e53 to 650b3a2 Compare April 27, 2026 08:23
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: 1

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

Inline comments:
In `@core/providers/anthropic/utils.go`:
- Around line 481-483: The sanitization currently only drops
"context_management" when all edits are unsupported (len(dropIndices) ==
len(edits) && len(edits) > 0), which misses the case where edits is an empty
array; update the logic in the block around variables dropIndices, edits and
jsonBody (the branch that calls providerUtils.DeleteJSONField(jsonBody,
"context_management")) to also drop "context_management" when edits is present
but empty (len(edits) == 0) so behavior matches the typed sanitizer (len(kept)
== 0). Ensure the condition that invokes providerUtils.DeleteJSONField covers
both "all edits unsupported" and "edits is empty" cases so an empty
context_management object is removed consistently.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0708d6a9-21c2-4090-8732-2a264a92d066

📥 Commits

Reviewing files that changed from the base of the PR and between 1de1e53 and 650b3a2.

📒 Files selected for processing (7)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
✅ Files skipped from review due to trivial changes (1)
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/providers/vertex/utils.go
  • core/providers/anthropic/types.go

Comment thread core/providers/anthropic/utils.go Outdated
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 650b3a2 to db5d8b1 Compare April 27, 2026 08:41
@akshaydeo akshaydeo force-pushed the 04-26-adds_message_filter_flow_for_log_details_messages branch from ea715ea to a7a2deb Compare April 27, 2026 08:41
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.

♻️ Duplicate comments (1)
core/providers/anthropic/utils.go (1)

481-483: ⚠️ Potential issue | 🟡 Minor

Drop empty context_management.edits as well for parity.

At Line 481, the len(edits) > 0 guard keeps context_management when edits is an empty array, while the typed sanitizer drops it when no edits remain. This leaves raw/typed behavior inconsistent.

Suggested fix
-			if len(dropIndices) == len(edits) && len(edits) > 0 {
+			if len(dropIndices) == len(edits) {
 				// All edits unsupported — drop the whole context_management.
 				jsonBody, err = providerUtils.DeleteJSONField(jsonBody, "context_management")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/providers/anthropic/utils.go` around lines 481 - 483, The current branch
only deletes "context_management" when all edits were removed and edits was
non-empty; change the condition around the providerUtils.DeleteJSONField call
(the block referencing dropIndices and edits in
core/providers/anthropic/utils.go) so that if len(dropIndices) == len(edits) it
deletes the entire "context_management" field even when len(edits) == 0; in
practice remove the "&& len(edits) > 0" guard (or add an explicit check for
len(edits) == 0) so empty edits arrays are dropped to match the typed sanitizer
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@core/providers/anthropic/utils.go`:
- Around line 481-483: The current branch only deletes "context_management" when
all edits were removed and edits was non-empty; change the condition around the
providerUtils.DeleteJSONField call (the block referencing dropIndices and edits
in core/providers/anthropic/utils.go) so that if len(dropIndices) == len(edits)
it deletes the entire "context_management" field even when len(edits) == 0; in
practice remove the "&& len(edits) > 0" guard (or add an explicit check for
len(edits) == 0) so empty edits arrays are dropped to match the typed sanitizer
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99b5452f-94ba-4a3f-8e17-e70d946f6bd8

📥 Commits

Reviewing files that changed from the base of the PR and between 650b3a2 and db5d8b1.

📒 Files selected for processing (7)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
✅ Files skipped from review due to trivial changes (2)
  • transports/bifrost-http/lib/config.go
  • core/providers/anthropic/types.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • transports/bifrost-http/integrations/anthropic.go

@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from db5d8b1 to 792ecff Compare April 27, 2026 08:58
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 792ecff to 0e71c35 Compare April 27, 2026 09:08
@akshaydeo akshaydeo force-pushed the 04-26-adds_message_filter_flow_for_log_details_messages branch from a7a2deb to 43a8f68 Compare April 27, 2026 09:08
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: 1

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

Inline comments:
In `@transports/bifrost-http/integrations/anthropic.go`:
- Around line 239-240: extractPassthroughHeaders currently ignores provider and
does not use filterVertexUnsupportedBetaHeaders, allowing unsupported beta
headers like Anthrop icContextManagementBetaHeaderPrefix to be forwarded; update
extractPassthroughHeaders to call filterVertexUnsupportedBetaHeaders (passing
the provider) when processing passthrough beta headers so that any headers
filtered by filterVertexUnsupportedBetaHeaders are removed, and apply the same
change to the other similar passthrough extraction block referenced by the
second occurrence (the block around the alternate beta handling).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d5baead-222c-4b70-856a-e274f1a609c6

📥 Commits

Reviewing files that changed from the base of the PR and between db5d8b1 and 0e71c35.

📒 Files selected for processing (7)
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/lib/config.go
✅ Files skipped from review due to trivial changes (1)
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • core/providers/vertex/utils.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/anthropic/types.go

Comment thread transports/bifrost-http/integrations/anthropic.go Outdated
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 0e71c35 to 9516aff Compare April 27, 2026 11:24
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/providers/anthropic/request_builder.go (1)

312-318: ⚠️ Potential issue | 🟠 Major

Delete anthropic_beta when filtering strips everything.

This only sets the body field when betaHeaders is non-empty. In the raw-body path, a caller can already have anthropic_beta on the JSON payload; if filtering removes all entries, the stale field is left intact and Vertex still receives the unsupported beta header in-body. That means the exact 400 this PR is fixing can still happen for passthrough requests.

Suggested fix
 	if cfg.InjectBetaHeadersIntoBody {
-		if betaHeaders := FilterBetaHeadersForProvider(MergeBetaHeaders(ctx, cfg.ProviderExtraHeaders), cfg.Provider, cfg.BetaHeaderOverrides); len(betaHeaders) > 0 {
+		if betaHeaders := FilterBetaHeadersForProvider(MergeBetaHeaders(ctx, cfg.ProviderExtraHeaders), cfg.Provider, cfg.BetaHeaderOverrides); len(betaHeaders) > 0 {
 			jsonBody, err = providerUtils.SetJSONField(jsonBody, "anthropic_beta", betaHeaders)
 			if err != nil {
 				return nil, newErr(schemas.ErrProviderRequestMarshal, err, jsonBody)
 			}
+		} else {
+			jsonBody, err = providerUtils.DeleteJSONField(jsonBody, "anthropic_beta")
+			if err != nil {
+				return nil, newErr(schemas.ErrProviderRequestMarshal, err, jsonBody)
+			}
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/providers/anthropic/request_builder.go` around lines 312 - 318, When
cfg.InjectBetaHeadersIntoBody is true you currently only
SetJSONField("anthropic_beta", ...) when FilterBetaHeadersForProvider returns
non-empty, leaving any existing "anthropic_beta" in raw jsonBody when the filter
strips everything; fix by checking betaHeaders :=
FilterBetaHeadersForProvider(MergeBetaHeaders(ctx, cfg.ProviderExtraHeaders),
cfg.Provider, cfg.BetaHeaderOverrides) and if len(betaHeaders) == 0 remove the
"anthropic_beta" key from jsonBody (e.g. call
providerUtils.DeleteJSONField(jsonBody, "anthropic_beta") or, if that helper
doesn't exist, unmarshal to a map, delete the key, and re-marshal) otherwise
keep the current SetJSONField behavior and error handling around
providerUtils.SetJSONField.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/providers/anthropic/types.go`:
- Around line 119-121: The schemas for Vertex currently claim Compaction support
while ContextManagementField is false (which causes any ContextManagement edits,
including ContextManagementEditTypeCompact under
AnthropicMessageRequest.ContextManagement, to be dropped), so update the Vertex
capability entries in core/providers/anthropic/types.go to make the advertised
capability match actual forwarding: either set ContextManagementField = true for
schemas.Vertex (after confirming upstream support and ensuring
ContextManagementEditTypeCompact will be forwarded) or set Compaction = false
for schemas.Vertex (and the other occurrence around lines 157-168) so compaction
is not advertised; locate the Vertex entries by the symbols Compaction,
ContextManagementField, schemas.Vertex and apply the consistent change in both
places.

---

Outside diff comments:
In `@core/providers/anthropic/request_builder.go`:
- Around line 312-318: When cfg.InjectBetaHeadersIntoBody is true you currently
only SetJSONField("anthropic_beta", ...) when FilterBetaHeadersForProvider
returns non-empty, leaving any existing "anthropic_beta" in raw jsonBody when
the filter strips everything; fix by checking betaHeaders :=
FilterBetaHeadersForProvider(MergeBetaHeaders(ctx, cfg.ProviderExtraHeaders),
cfg.Provider, cfg.BetaHeaderOverrides) and if len(betaHeaders) == 0 remove the
"anthropic_beta" key from jsonBody (e.g. call
providerUtils.DeleteJSONField(jsonBody, "anthropic_beta") or, if that helper
doesn't exist, unmarshal to a map, delete the key, and re-marshal) otherwise
keep the current SetJSONField behavior and error handling around
providerUtils.SetJSONField.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a50e2dc4-237d-4606-864f-68843760998e

📥 Commits

Reviewing files that changed from the base of the PR and between 0e71c35 and 9516aff.

📒 Files selected for processing (14)
  • core/providers/anthropic/anthropic.go
  • core/providers/anthropic/request_builder.go
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/azure/azure.go
  • core/providers/bedrock/bedrock.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • docs/changelogs/v1.4.23.mdx
  • docs/changelogs/v1.5.0-prerelease4.mdx
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/integrations/anthropic_test.go
  • transports/bifrost-http/lib/config.go
💤 Files with no reviewable changes (1)
  • transports/bifrost-http/integrations/anthropic_test.go
✅ Files skipped from review due to trivial changes (3)
  • docs/changelogs/v1.5.0-prerelease4.mdx
  • docs/changelogs/v1.4.23.mdx
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • transports/bifrost-http/integrations/anthropic.go
  • core/providers/anthropic/utils_test.go
  • core/providers/anthropic/utils.go

Comment thread core/providers/anthropic/types.go
@akshaydeo akshaydeo force-pushed the 04-26-vertex_anthropic_fixes branch from 9516aff to 663292e Compare April 27, 2026 12:07
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.

♻️ Duplicate comments (1)
core/providers/anthropic/utils.go (1)

457-497: ⚠️ Potential issue | 🟠 Major

Mirror this ContextManagementField short-circuit in the typed sanitizer too.

This raw-path fix is still out of sync with stripUnsupportedAnthropicFields: the typed path only filters ContextManagement.Edits by edit type, so providers like Vertex can still serialize context_management for compact edits and hit the same 400 on non-raw requests. That leaves the stack with different behavior depending on whether the request came through raw-body passthrough.

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

In `@core/providers/anthropic/utils.go` around lines 457 - 497, The typed
sanitizer (stripUnsupportedAnthropicFields) must mirror the raw JSON
short-circuit for ContextManagement: if features.ContextManagementField is
false, remove the ContextManagement field entirely (e.g., via the typed model or
DeleteJSONField equivalent), otherwise filter ContextManagement.Edits by the
same edit-type whitelist (ContextManagementEditTypeCompact,
ContextManagementEditTypeClearToolUses, ContextManagementEditTypeClearThinking)
honoring features.Compaction and features.ContextEditing; if filtering removes
all edits, delete the whole ContextManagement field. Update
stripUnsupportedAnthropicFields to use the same logic and constants so providers
like Vertex won’t serialize unsupported context_management edits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@core/providers/anthropic/utils.go`:
- Around line 457-497: The typed sanitizer (stripUnsupportedAnthropicFields)
must mirror the raw JSON short-circuit for ContextManagement: if
features.ContextManagementField is false, remove the ContextManagement field
entirely (e.g., via the typed model or DeleteJSONField equivalent), otherwise
filter ContextManagement.Edits by the same edit-type whitelist
(ContextManagementEditTypeCompact, ContextManagementEditTypeClearToolUses,
ContextManagementEditTypeClearThinking) honoring features.Compaction and
features.ContextEditing; if filtering removes all edits, delete the whole
ContextManagement field. Update stripUnsupportedAnthropicFields to use the same
logic and constants so providers like Vertex won’t serialize unsupported
context_management edits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2cc7e37-f660-46f8-9dde-b8d9e0d15bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 9516aff and 663292e.

📒 Files selected for processing (14)
  • core/providers/anthropic/anthropic.go
  • core/providers/anthropic/request_builder.go
  • core/providers/anthropic/types.go
  • core/providers/anthropic/utils.go
  • core/providers/anthropic/utils_test.go
  • core/providers/azure/azure.go
  • core/providers/bedrock/bedrock.go
  • core/providers/vertex/utils.go
  • core/providers/vertex/vertex.go
  • docs/changelogs/v1.4.23.mdx
  • docs/changelogs/v1.5.0-prerelease4.mdx
  • transports/bifrost-http/integrations/anthropic.go
  • transports/bifrost-http/integrations/anthropic_test.go
  • transports/bifrost-http/lib/config.go
💤 Files with no reviewable changes (1)
  • transports/bifrost-http/integrations/anthropic_test.go
✅ Files skipped from review due to trivial changes (3)
  • docs/changelogs/v1.5.0-prerelease4.mdx
  • docs/changelogs/v1.4.23.mdx
  • transports/bifrost-http/lib/config.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/providers/anthropic/request_builder.go
  • transports/bifrost-http/integrations/anthropic.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 27, 2026
Copy link
Copy Markdown
Contributor Author

akshaydeo commented Apr 27, 2026

Merge activity

  • Apr 27, 8:08 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 27, 8:11 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo changed the base branch from 04-26-adds_message_filter_flow_for_log_details_messages to graphite-base/3055 April 27, 2026 20:10
@akshaydeo akshaydeo changed the base branch from graphite-base/3055 to main April 27, 2026 20:10
@akshaydeo akshaydeo dismissed coderabbitai[bot]’s stale review April 27, 2026 20:10

The base branch was changed.

@akshaydeo akshaydeo merged commit 8f6c0ec into main Apr 27, 2026
11 of 14 checks passed
@akshaydeo akshaydeo deleted the 04-26-vertex_anthropic_fixes branch April 27, 2026 20:11
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