Skip to content

Conversation

@TejasGhatte
Copy link
Collaborator

@TejasGhatte TejasGhatte commented Jan 2, 2026

Summary

Fix Gemini/Vertex tool handling to properly support multiple function declarations by appending them to a single Tool object rather than creating separate Tool objects for each function.

Changes

  • Modified convertResponsesToolsToGemini and convertBifrostToolsToGemini to append all function declarations to a single Tool object instead of creating multiple Tool objects
  • Updated Vertex test to correctly indicate that multiple tool calls are supported
  • Added the fix to both core and transports changelogs

Type of change

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

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (Next.js)
  • Docs

How to test

Test that multiple function declarations work correctly with Gemini and Vertex:

# Core/Transports
go version
go test ./core/providers/gemini/...
go test ./core/providers/vertex/...

Also test with actual API calls to ensure multiple function tools are properly handled in a single request.

Breaking changes

  • Yes
  • No

Related issues

Fixes issue with Gemini/Vertex providers not properly handling multiple function tools.

Security considerations

No security implications.

Checklist

  • 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
Copy link
Contributor

coderabbitai bot commented Jan 2, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Fixed tool conversion for Gemini/Vertex providers to properly aggregate all function declarations into a single Tool object.
    • Fixed empty string handling in Anthropic provider to prevent sending empty content blocks in chat requests.
  • Tests

    • Enabled multiple tool calls support in test configuration for improved coverage.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

The changes consolidate tool conversion logic in the Gemini and Vertex providers to build a single Tool object containing all FunctionDeclarations instead of creating multiple Tool instances. Test configuration was updated to enable multiple tool calls support, and changelog entries were added documenting the refactor.

Changes

Cohort / File(s) Summary
Tool Conversion Refactor
core/providers/gemini/responses.go, core/providers/gemini/utils.go
Both convertResponsesToolsToGemini and convertBifrostToolsToGemini now build a single gemini Tool object with all FunctionDeclarations appended to it, rather than creating multiple Tool instances. Returns non-empty slice only when declarations exist.
Test Configuration
core/providers/vertex/vertex_test.go
MultipleToolCalls flag toggled from false to true in Vertex test config, enabling multiple tool calls scenario testing.
Documentation
core/changelog.md, transports/changelog.md
Changelog entries reformatted and updated. Core changelog split single-line entry into two entries; transport changelog adds new entry documenting Gemini/Vertex tool conversion fix and restores existing Anthropic provider entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 One tool to hold them all!
No more scattered FunctionDeclarations—
Now consolidated, neat and small,
A single object celebrates their unions,
Tests stand taller, configs sing anew! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The linked issue #123 concerns File API support for providers; this PR addresses Gemini/Vertex tool conversion logic, which is unrelated to file API functionality. Verify the correct linked issues are associated with this PR. The current linked issue #123 (Files API Support) does not match the PR's objectives of fixing Gemini function declaration conversion.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: gemini function declaration conversion' directly and specifically describes the main change—fixing how Gemini handles function declaration conversion.
Description check ✅ Passed The description is comprehensive and follows the template structure with all major sections completed including summary, changes, type, affected areas, testing, and checklist items marked.
Out of Scope Changes check ✅ Passed All changes (Gemini/Vertex tool conversion, test configuration update, and changelog entries) are directly aligned with the stated PR objective of fixing function declaration handling.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 01-02-fix_gemini_function_declaration_conversion

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 411b394 and 6c89179.

📒 Files selected for processing (5)
  • core/changelog.md
  • core/providers/gemini/responses.go
  • core/providers/gemini/utils.go
  • core/providers/vertex/vertex_test.go
  • transports/changelog.md
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

always check the stack if there is one for the current PR. do not give localized reviews for the PR, always see all changes in the light of the whole stack of PRs (if there is a stack, if there is no stack you can continue to make localized suggestions/reviews)

Files:

  • core/providers/vertex/vertex_test.go
  • core/providers/gemini/responses.go
  • core/changelog.md
  • core/providers/gemini/utils.go
  • transports/changelog.md
🧠 Learnings (4)
📚 Learning: 2025-12-09T17:07:42.007Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/schemas/account.go:9-18
Timestamp: 2025-12-09T17:07:42.007Z
Learning: In core/schemas/account.go, the HuggingFaceKeyConfig field within the Key struct is currently unused and reserved for future Hugging Face inference endpoint deployments. Do not flag this field as missing from OpenAPI documentation or require its presence in the API spec until the feature is actively implemented and used. When the feature is added, update the OpenAPI docs accordingly; otherwise, treat this field as non-breaking and not part of the current API surface.

Applied to files:

  • core/providers/vertex/vertex_test.go
  • core/providers/gemini/responses.go
  • core/providers/gemini/utils.go
📚 Learning: 2025-12-29T11:54:55.836Z
Learnt from: akshaydeo
Repo: maximhq/bifrost PR: 1153
File: framework/configstore/rdb.go:2221-2246
Timestamp: 2025-12-29T11:54:55.836Z
Learning: In Go reviews, do not flag range-over-int patterns like for i := range n as compile-time errors, assuming Go 1.22+ semantics. Only flag actual range-capable values (slices, arrays, maps, channels, strings) and other compile-time issues. This applies to all Go files across the repository.

Applied to files:

  • core/providers/vertex/vertex_test.go
  • core/providers/gemini/responses.go
  • core/providers/gemini/utils.go
📚 Learning: 2025-12-15T10:16:21.909Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/providers/huggingface/huggingface_test.go:12-63
Timestamp: 2025-12-15T10:16:21.909Z
Learning: In provider tests under core/providers/<provider>/*_test.go, do not require or flag the use of defer for Shutdown(); instead call client.Shutdown() at the end of each test function. This pattern appears consistent across all provider tests. Apply this rule only within this path; for other tests or resources, defer may still be appropriate.

Applied to files:

  • core/providers/vertex/vertex_test.go
📚 Learning: 2025-12-19T09:26:54.961Z
Learnt from: qwerty-dvorak
Repo: maximhq/bifrost PR: 1006
File: core/providers/utils/utils.go:1050-1051
Timestamp: 2025-12-19T09:26:54.961Z
Learning: Update streaming end-marker handling so HuggingFace is treated as a non-[DONE] provider for backends that do not emit a DONE marker (e.g., meta llama on novita). In core/providers/utils/utils.go, adjust ProviderSendsDoneMarker() (or related logic) to detect providers that may not emit DONE and avoid relying on DONE as the sole end signal. Add tests to cover both DONE-emitting and non-DONE backends, with clear documentation in code comments explaining the rationale and any fallback behavior.

Applied to files:

  • core/providers/vertex/vertex_test.go
  • core/providers/gemini/responses.go
  • core/providers/gemini/utils.go
🧬 Code graph analysis (2)
core/providers/gemini/responses.go (2)
core/providers/gemini/types.go (1)
  • Tool (605-632)
ui/lib/types/logs.ts (1)
  • Tool (159-163)
core/providers/gemini/utils.go (1)
core/providers/gemini/types.go (1)
  • Tool (605-632)
🔇 Additional comments (5)
core/providers/vertex/vertex_test.go (1)

39-39: LGTM! Test configuration updated to exercise multiple tool calls.

Enabling MultipleToolCalls appropriately tests the updated tool conversion logic that now aggregates all function declarations into a single Tool object.

core/changelog.md (1)

1-2: LGTM! Changelog entries appropriately document the fixes.

Both entries clearly describe the fixes applied in this release.

transports/changelog.md (1)

2-3: LGTM! Changelog entries appropriately document the fixes.

The entries clearly describe the Anthropic empty string handling and the Gemini/Vertex tool conversion fix.

core/providers/gemini/utils.go (1)

459-484: Consistent tool aggregation logic.

The function now consolidates all FunctionDeclarations into a single geminiTool, matching the pattern applied in convertResponsesToolsToGemini (core/providers/gemini/responses.go:2078-2111). This consistency ensures both conversion paths produce the same Tool structure.

core/providers/gemini/responses.go (1)

2078-2111: Correct aggregation of function declarations into a single Tool object.

The updated logic consolidates all FunctionDeclarations into a single geminiTool instead of creating multiple Tool instances. This aligns with the Tool struct definition, which shows FunctionDeclarations as a slice that can hold multiple declarations per Tool, and is confirmed by the test suite and the Gemini API's expected structure.


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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

🧪 Test Suite Available

This PR can be tested by a repository admin.

Run tests for PR #1218

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TejasGhatte TejasGhatte marked this pull request as ready for review January 2, 2026 14:07
Copy link
Contributor

akshaydeo commented Jan 2, 2026

Merge activity

  • Jan 2, 2:28 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 2, 2:28 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo merged commit f189c73 into main Jan 2, 2026
11 checks passed
@akshaydeo akshaydeo deleted the 01-02-fix_gemini_function_declaration_conversion branch January 2, 2026 14:28
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.

3 participants