Skip to content

[FEATURE] Configurable additionalProperties in JSON Schema #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
par4m opened this issue Apr 21, 2025 · 1 comment
Open

[FEATURE] Configurable additionalProperties in JSON Schema #364

par4m opened this issue Apr 21, 2025 · 1 comment

Comments

@par4m
Copy link
Contributor

par4m commented Apr 21, 2025

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.

@par4m par4m changed the title [FEATURE] Configurable additionalProperties in JSON Schema via ToJsonSchemaOptions [FEATURE] Configurable additionalProperties in JSON Schema Apr 21, 2025
@par4m
Copy link
Contributor Author

par4m commented Apr 21, 2025

I'll work on this after #360 is merged.

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

No branches or pull requests

1 participant