Skip to content

[FEATURE] Configurable additionalProperties in JSON Schema #364

@par4m

Description

@par4m

Background

Some LLM APIs, such as Gemini, do not support the additionalProperties constraint in JSON schemas and return errors if it is present. Currently, we work around this by stripping all additional fields after schema generation using a helper in gemini.rs.

To address this more cleanly, introduce a supports_additional_properties: bool field in the ToJsonSchemaOptions struct.

Tasks

  • Add a supports_additional_properties: bool field to ToJsonSchemaOptions.
  • Update schema generation logic to only include additionalProperties if this field is true.
  • Update all code that constructs ToJsonSchemaOptions to set this field appropriately (e.g., false for Gemini, true for OpenAI).
  • Remove the remove_additional_properties function from gemini.rs and any related post-processing.
    Context

This addition will make it easier to support new LLMs with different schema requirements and reduce the risk of runtime errors due to schema incompatibility.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions