Skip to content

fix: extend extra_params passthrough to Anthropic, Bedrock, Gemini & Cohere#4555

Open
xeaser wants to merge 3 commits into
maximhq:mainfrom
xeaser:fix/extra-params-passthrough-all-integrations
Open

fix: extend extra_params passthrough to Anthropic, Bedrock, Gemini & Cohere#4555
xeaser wants to merge 3 commits into
maximhq:mainfrom
xeaser:fix/extra-params-passthrough-all-integrations

Conversation

@xeaser

@xeaser xeaser commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

extra_params passthrough (the x-bf-passthrough-extra-params: true header) only worked for OpenAI. The Anthropic, Bedrock, Gemini and Cohere request types had GetExtraParams but no SetExtraParams, so the router's setter check silently skipped them.

This adds a small shared ExtraParamsMixin (the ExtraParams field plus GetExtraParams/SetExtraParams) in core/providers/utils and embeds it across those four providers' request types, replacing the per-type field + getter boilerplate — the DRY option suggested in the discussion.

OpenAI is intentionally left as-is: its request types embed schemas.*Parameters, which already carry an ExtraParams field, so embedding the mixin there would be an ambiguous selector. It keeps its existing dual-write setters.

Also extended the integration router interface-compliance test to cover the four providers.

Refs: #1731

…ohere

Add a shared ExtraParamsMixin and embed it across these providers' request types so SetExtraParams exists for them too (was OpenAI-only). OpenAI keeps its own setters since it embeds schemas.*Parameters which already define ExtraParams.

Refs: maximhq#1731
@CLAassistant

CLAassistant commented Jun 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e05a29c-e23d-4617-9f75-1236f3f2e092

📥 Commits

Reviewing files that changed from the base of the PR and between 13cbb21 and 78c0d34.

📒 Files selected for processing (1)
  • transports/bifrost-http/integrations/router_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • transports/bifrost-http/integrations/router_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved how “extra” request parameters are carried through the system, standardizing behavior across supported AI providers so advanced options continue to work consistently.
  • Bug Fixes
    • Ensured extra-parameter handling remains correct when requests are constructed or transformed for different provider endpoints.
  • Tests
    • Added coverage to verify that all supported provider request types correctly accept and return settable extra parameters.

Walkthrough

Introduces a shared ExtraParamsMixin struct in core/providers/utils/extraparams.go with GetExtraParams and SetExtraParams methods. All provider request types across Anthropic, Bedrock, Cohere, and Gemini are updated to embed this mixin, removing per-struct ExtraParams field declarations and GetExtraParams method implementations. Call sites in invoke.go switch to post-construction field assignment, and a new integration test validates the interface across all providers.

Changes

ExtraParamsMixin Refactor

Layer / File(s) Summary
ExtraParamsMixin utility type
core/providers/utils/extraparams.go
Introduces ExtraParamsMixin with an ExtraParams map[string]interface{} field (json:"-") and exported GetExtraParams/SetExtraParams pointer-receiver methods.
Provider request struct embedding
core/providers/anthropic/types.go, core/providers/bedrock/types.go, core/providers/bedrock/models.go, core/providers/cohere/types.go, core/providers/cohere/models.go, core/providers/gemini/types.go
Embeds providerUtils.ExtraParamsMixin into all provider request structs (AnthropicTextRequest, AnthropicMessageRequest, all Bedrock/Cohere/Gemini request types), removing the per-struct ExtraParams field and GetExtraParams method declarations. Includes minor tag/spacing alignment in BedrockToolUse and BedrockGuardrailAssessment.
Call-site updates and test validation
core/providers/bedrock/invoke.go, core/providers/bedrock/bedrock_test.go, transports/bifrost-http/integrations/router_test.go
Removes BedrockInvokeRequest.GetExtraParams() and switches ToBedrockConverseRequest/ToBifrostTextCompletionRequest to post-construction ExtraParams assignment. Bedrock tests mirror this pattern. Adds TestRequestWithSettableExtraParams_AllProviderRequestTypes asserting all provider request types implement RequestWithSettableExtraParams.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • danpiths
  • akshaydeo

Poem

🐇 Hop hop, the mixin's here at last,
No more copy-paste from classes past!
One struct to rule the extra map,
Embedded neatly, filled the gap.
The rabbit cheers—less code to track! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is comprehensive but missing several template sections including Type of change, Affected areas, How to test, and Checklist items. Complete the PR description by filling in the remaining template sections: explicitly mark the Type of change (appears to be Refactor), Affected areas (Core and Transports), how to test the changes, and the final checklist items.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: extending extra_params passthrough support to four providers (Anthropic, Bedrock, Gemini, Cohere).
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 unit tests (beta)
  • Create PR with unit tests

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.12.2)

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


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot requested review from danpiths and roroghost17 June 19, 2026 08:27
@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is additive and fixes a silent functional gap with no regressions in the existing provider logic.

The mixin is a thin, correct abstraction that only adds SetExtraParams where it was missing. All 22 updated types are covered by the new interface-compliance test. Existing field access (.ExtraParams = ...) continues to work as a promoted field. The BedrockRerankRequest change turns a hardcoded nil return into a real working field, which is a net improvement. No pooled objects, no goroutine-safety concerns, and no new cross-module dependencies are introduced.

No files require special attention.

Important Files Changed

Filename Overview
core/providers/utils/extraparams.go New shared mixin type providing ExtraParams field plus Get/Set methods; clean and minimal implementation.
core/providers/anthropic/types.go AnthropicTextRequest and AnthropicMessageRequest swap direct ExtraParams field + GetExtraParams for ExtraParamsMixin embed; no logic changes.
core/providers/bedrock/types.go Twelve Bedrock request types updated to embed ExtraParamsMixin; BedrockInvokeRequest also moves to mixin, preserving all field accesses in invoke.go.
core/providers/bedrock/models.go BedrockRerankRequest now embeds ExtraParamsMixin; previously GetExtraParams returned nil unconditionally, meaning rerank extra_params passthrough never worked.
core/providers/bedrock/invoke.go ToBedrockConverseRequest and ToBifrostTextCompletionRequest migrate ExtraParams copy to post-literal assignment; GetExtraParams() is removed as it's promoted from the mixin.
transports/bifrost-http/integrations/router_test.go New TestRequestWithSettableExtraParams_AllProviderRequestTypes covers all 22 updated request types for interface-compliance.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/extra-param..." | Re-trigger Greptile

Comment thread transports/bifrost-http/integrations/router_test.go

@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)
transports/bifrost-http/integrations/router_test.go (1)

117-132: ⚡ Quick win

Expand interface-compliance coverage to all refactored request DTOs.

This test is named as “all provider request types,” but it currently omits some DTOs updated in this stack (for example: gemini.GeminiBatchEmbeddingRequest, gemini.GeminiImagenRequest, gemini.GeminiVideoGenerationRequest, and cohere.CohereCountTokensRequest). Adding them will keep this guard aligned with the full refactor surface and reduce silent regressions.

♻️ Suggested test-case additions
 	tests := []struct {
 		name string
 		req  interface{}
 	}{
 		{"AnthropicMessageRequest", &anthropic.AnthropicMessageRequest{}},
 		{"AnthropicTextRequest", &anthropic.AnthropicTextRequest{}},
 		{"BedrockConverseRequest", &bedrock.BedrockConverseRequest{}},
 		{"BedrockTextCompletionRequest", &bedrock.BedrockTextCompletionRequest{}},
 		{"BedrockTitanEmbeddingRequest", &bedrock.BedrockTitanEmbeddingRequest{}},
 		{"BedrockImageGenerationRequest", &bedrock.BedrockImageGenerationRequest{}},
 		{"GeminiGenerationRequest", &gemini.GeminiGenerationRequest{}},
+		{"GeminiBatchEmbeddingRequest", &gemini.GeminiBatchEmbeddingRequest{}},
 		{"GeminiEmbeddingRequest", &gemini.GeminiEmbeddingRequest{}},
+		{"GeminiImagenRequest", &gemini.GeminiImagenRequest{}},
+		{"GeminiVideoGenerationRequest", &gemini.GeminiVideoGenerationRequest{}},
 		{"CohereChatRequest", &cohere.CohereChatRequest{}},
+		{"CohereCountTokensRequest", &cohere.CohereCountTokensRequest{}},
 		{"CohereEmbeddingRequest", &cohere.CohereEmbeddingRequest{}},
 	}

As per coding guidelines, this recommendation is based on reviewing the full PR stack rather than only localized diffs.

🤖 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 `@transports/bifrost-http/integrations/router_test.go` around lines 117 - 132,
The tests slice in the
TestRequestWithSettableExtraParams_AllProviderRequestTypes function is
incomplete and omits several refactored request DTOs. Add the missing test cases
to the tests slice: gemini.GeminiBatchEmbeddingRequest,
gemini.GeminiImagenRequest, gemini.GeminiVideoGenerationRequest, and
cohere.CohereCountTokensRequest. Each should be added as a new entry in the
slice with appropriate name and request type pointer, following the same pattern
as the existing entries.

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 `@transports/bifrost-http/integrations/router_test.go`:
- Around line 117-132: The tests slice in the
TestRequestWithSettableExtraParams_AllProviderRequestTypes function is
incomplete and omits several refactored request DTOs. Add the missing test cases
to the tests slice: gemini.GeminiBatchEmbeddingRequest,
gemini.GeminiImagenRequest, gemini.GeminiVideoGenerationRequest, and
cohere.CohereCountTokensRequest. Each should be added as a new entry in the
slice with appropriate name and request type pointer, following the same pattern
as the existing entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cd10c98a-878f-44fa-9dc8-29bafd1b3f11

📥 Commits

Reviewing files that changed from the base of the PR and between 0a54d3a and 13cbb21.

📒 Files selected for processing (10)
  • core/providers/anthropic/types.go
  • core/providers/bedrock/bedrock_test.go
  • core/providers/bedrock/invoke.go
  • core/providers/bedrock/models.go
  • core/providers/bedrock/types.go
  • core/providers/cohere/models.go
  • core/providers/cohere/types.go
  • core/providers/gemini/types.go
  • core/providers/utils/extraparams.go
  • transports/bifrost-http/integrations/router_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 19, 2026
Extends the compliance table to the remaining Bedrock/Gemini/Cohere request types (rerank, invoke, image variation/edit, stability, batch embedding, imagen, video, count tokens) so all 22 migrated types are guarded, not just 10.
@coderabbitai coderabbitai Bot requested a review from akshaydeo June 19, 2026 09:35
@xeaser

xeaser commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@akshaydeo , I had earlier raised this in discussion for support of extra params. Raised PR addressing core providers.
Also I would like to be involved in contributing to the project.
Review when possible!

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