Skip to content

[fix]: Anthropic - include_server_side_tool_invocations now reaches the Gemini declaration-drop gate - #5935

Merged
akshaydeo merged 4 commits into
maximhq:devfrom
AdityaPainuli:fix/anthropic-server-tool-optin-5679
Aug 7, 2026
Merged

[fix]: Anthropic - include_server_side_tool_invocations now reaches the Gemini declaration-drop gate#5935
akshaydeo merged 4 commits into
maximhq:devfrom
AdityaPainuli:fix/anthropic-server-tool-optin-5679

Conversation

@AdityaPainuli

Copy link
Copy Markdown
Contributor

Summary

On anthropic/v1/messages, include_server_side_tool_invocations: true was silently ignored: the field is unregistered on the Anthropic schema, so it lands in ExtraParams as raw JSON, while the Gemini declaration-drop gate (added in #5576) reads the typed Params.IncludeServerSideToolInvocations. Combining a server-side tool with function tools on a Gemini-routed request therefore dropped the function declarations even with the opt-in set.

Changes

  • ToBifrostResponsesRequest lifts include_server_side_tool_invocations from ExtraParams onto the typed parameter, decoding the json.RawMessage capture (a plain type assertion never matches, which is why the flag was invisible)
  • Regression test unmarshals a raw Anthropic body carrying the flag and asserts the typed param is set after conversion; fails on current dev

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

cd core && go test ./providers/anthropic/ -run TestAnthropicIngressLiftsServerSideToolOptIn -v

Breaking changes

  • No

If yes, describe impact and migration instructions.

Related issues

Closes #5679

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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d35db3a9-53b7-4e0a-9232-697eab17ca9f

📥 Commits

Reviewing files that changed from the base of the PR and between 6006340 and 91a7cc4.

📒 Files selected for processing (1)
  • core/providers/anthropic/responses.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Anthropic requests now correctly preserve the server-side tool invocation setting when provided as a boolean or JSON value.
    • The setting remains available in typed requests sent through the Responses API, improving consistency for supported server-side tool workflows.
  • Tests

    • Added regression coverage to verify preservation of this setting during request conversion.

Walkthrough

The Anthropic Responses request converter promotes include_server_side_tool_invocations into the typed IncludeServerSideToolInvocations parameter. It supports boolean and JSON-encoded values and adds regression coverage.

Changes

Anthropic tool opt-in propagation

Layer / File(s) Summary
Promote and validate server-side tool opt-in
core/providers/anthropic/responses.go, core/providers/anthropic/responses_test.go
ToBifrostResponsesRequest reads boolean and JSON-encoded include_server_side_tool_invocations values from ExtraParams. The regression test verifies that true populates the typed parameter.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • maximhq/bifrost#5367: Modifies Anthropic Responses request conversion, including parameter mappings.
  • maximhq/bifrost#5576: Propagates the same typed server-side tool invocation parameter in Gemini request conversion.

Suggested reviewers: pratham-mishra04, sammaji

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements typed flag promotion and a conversion test, but lacks requested coverage for Gemini payloads, false or absent behavior, response handling, and replay. Add focused tests for absent and false values, Gemini tool and toolConfig payloads, streaming and non-streaming responses, and subsequent tool-result replay.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Anthropic flag fix and its effect on the Gemini declaration-drop gate.
Description check ✅ Passed The description explains the bug, implementation, test command, affected area, issue, security impact, breaking status, and checklist.
Out of Scope Changes check ✅ Passed The changes are limited to Anthropic conversion logic and its regression test, which directly support the linked mixed-tool opt-in fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

Comment thread core/providers/anthropic/responses.go Outdated
@coderabbitai
coderabbitai Bot requested review from akshaydeo and sammaji August 7, 2026 06:43

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

🧹 Nitpick comments (1)
core/providers/anthropic/responses_test.go (1)

403-425: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exercise the mixed-tool regression in this test.

Lines 405-409 contain no tools, so the test cannot detect whether Anthropic ingress preserves both a function tool and a server-side tool. Convert a request containing both tool types through ToGeminiResponsesRequest and assert functionDeclarations, googleSearch, and ToolConfig.IncludeServerSideToolInvocations.

Also add cases for explicit false, an absent field, and a direct bool in ExtraParams. These cases cover the converter branches and preserve the distinction between nil and false. The existing core/providers/gemini/gemini_test.go test covers the downstream builder, but it does not cover this Anthropic ingress boundary.

As per coding guidelines, Go behavior changes should have deterministic, table-driven coverage.

🤖 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 `@core/providers/anthropic/responses_test.go` around lines 403 - 425, Expand
TestAnthropicIngressLiftsServerSideToolOptIn into deterministic table-driven
coverage for mixed function and server-side tools, converting each case through
ToGeminiResponsesRequest and asserting functionDeclarations, googleSearch, and
ToolConfig.IncludeServerSideToolInvocations. Include explicit true, explicit
false, absent, and direct bool ExtraParams cases, preserving nil versus false
semantics and validating both tool types survive Anthropic ingress.

Source: Coding guidelines

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

Nitpick comments:
In `@core/providers/anthropic/responses_test.go`:
- Around line 403-425: Expand TestAnthropicIngressLiftsServerSideToolOptIn into
deterministic table-driven coverage for mixed function and server-side tools,
converting each case through ToGeminiResponsesRequest and asserting
functionDeclarations, googleSearch, and
ToolConfig.IncludeServerSideToolInvocations. Include explicit true, explicit
false, absent, and direct bool ExtraParams cases, preserving nil versus false
semantics and validating both tool types survive Anthropic ingress.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 798f344e-a83d-48ed-a353-6d1044364eac

📥 Commits

Reviewing files that changed from the base of the PR and between 55871ff and bd15ea5.

📒 Files selected for processing (2)
  • core/providers/anthropic/responses.go
  • core/providers/anthropic/responses_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@akshaydeo
akshaydeo merged commit b3189ef into maximhq:dev Aug 7, 2026
4 of 5 checks passed
akshaydeo added a commit that referenced this pull request Aug 7, 2026
…he Gemini declaration-drop gate (#5935)

* [fix]: anthropic - lift include_server_side_tool_invocations onto the typed param

* [fix]: anthropic - compare raw token directly for server-side tool opt-in

---------

Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
@akshaydeo akshaydeo mentioned this pull request Aug 7, 2026
18 tasks
atharvamhaske pushed a commit to atharvamhaske/bifrost that referenced this pull request Aug 13, 2026
…he Gemini declaration-drop gate (maximhq#5935)

* [fix]: anthropic - lift include_server_side_tool_invocations onto the typed param

* [fix]: anthropic - compare raw token directly for server-side tool opt-in

---------

Co-authored-by: Akshay Deo <akshay@akshaydeo.com>
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.

[Bug]: Anthropic Messages does not propagate Gemini mixed server/client tool opt-in

2 participants