Skip to content

feat(gemini): omit parameters field for no-parameter tools#1674

Merged
bug-ops merged 3 commits intomainfrom
feat-gemini-omit-empty-propert
Mar 13, 2026
Merged

feat(gemini): omit parameters field for no-parameter tools#1674
bug-ops merged 3 commits intomainfrom
feat-gemini-omit-empty-propert

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 13, 2026

Summary

  • Change GeminiFunctionDeclaration.parameters to Option<serde_json::Value> with #[serde(skip_serializing_if = "Option::is_none")]
  • Add is_empty_object_schema() helper detecting empty-object schemas (empty or absent properties)
  • Update convert_tool_definitions to return None for no-parameter tools instead of {type: OBJECT, properties: {}}
  • Add 4 new tests: test_convert_tool_no_parameters, test_is_empty_object_schema

Closes #1641. Part of #1592.

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace --features full -- -D warnings passes
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins passes (5264 tests, +4 new)
  • New test test_convert_tool_no_parameters verifies parameters key absent in serialized JSON
  • New test test_is_empty_object_schema covers all 4 branches including missing properties key

When a tool has no parameters, convert_tool_definitions() previously
produced parameters: {type: OBJECT, properties: {}}. The Gemini API
accepts this but the spec allows omitting the field entirely.

Change GeminiFunctionDeclaration.parameters to Option<serde_json::Value>
with skip_serializing_if = "Option::is_none". Add is_empty_object_schema()
helper that detects empty-object schemas (absent or empty properties key).
Update convert_tool_definitions to return None for no-param tools.

Closes #1641. Part of #1592.
@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes enhancement New feature or request size/M Medium PR (51-200 lines) labels Mar 13, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 19:23
@bug-ops bug-ops merged commit 57c529f into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the feat-gemini-omit-empty-propert branch March 13, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(gemini): omit empty properties object for no-parameter tools

1 participant