Skip to content

fix(llm): omit parameters field for no-param tools in OpenAI strict mode#1682

Merged
bug-ops merged 1 commit intomainfrom
openai-tool-empty-params
Mar 13, 2026
Merged

fix(llm): omit parameters field for no-param tools in OpenAI strict mode#1682
bug-ops merged 1 commit intomainfrom
openai-tool-empty-params

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

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

Summary

  • Detects empty-parameter tool schemas ({"type": "object", "properties": {}}) in prepare_tool_params() and returns None, causing the parameters field to be omitted via #[serde(skip_serializing_if = "Option::is_none")]
  • Non-empty schemas are still inlined and normalized for strict mode before sending
  • Mirrors the Gemini fix from feat(gemini): omit empty properties object for no-parameter tools #1641 (is_empty_object_schema + Option<serde_json::Value>)

Test plan

  • prepare_tool_params_empty_object_returns_none — empty properties: {}None
  • prepare_tool_params_no_properties_key_returns_none — absent propertiesNone
  • prepare_tool_params_non_empty_normalizes_strict — non-empty schema gets additionalProperties: false + required
  • openai_tool_empty_params_omitted_in_serializationparameters: None not present in JSON output
  • All 5278 existing tests pass

Fixes #1673.

@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 13, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 20:21
Empty-parameter tools generated schema `{"type": "object", "properties": {}}` via
schemars, which OpenAI strict mode rejects with 400 Bad Request ("object schema
missing properties").

Apply the same fix used for Gemini (#1641): detect empty-parameter schemas in
`prepare_tool_params()` and return `None`, causing the `parameters` field to be
omitted entirely via `#[serde(skip_serializing_if = "Option::is_none")]`.

Non-empty schemas are still inlined (`inline_refs_openai`) and normalized
(`normalize_for_openai_strict`) before sending.

Fixes #1673.
@bug-ops bug-ops force-pushed the openai-tool-empty-params branch from f1d6974 to 4b90937 Compare March 13, 2026 20:25
@bug-ops bug-ops merged commit fb7d6a7 into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the openai-tool-empty-params branch March 13, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation 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.

bug(llm): OpenAI tool definitions with empty parameters rejected in strict mode

1 participant