Repository navigation
fix(prompt): keep requiredProperties of nested objects in OpenAI-compatible tool schema - #2256
Open
Aditya Nikam (adityaanikam) wants to merge 1 commit into
Conversation
…atible tool schema OpenAICompatibleToolDescriptorSchemaGenerator wrote only the top-level required list. The ToolParameterType.Object branch never wrote requiredProperties, so every property of a nested object became optional in the schema sent to the model. Write required after properties when requiredProperties is not empty, so objects without required properties produce the same schema as before. closes JetBrains#2255
Copilot started reviewing on behalf of
Aditya Nikam (adityaanikam)
September 26, 2026 19:43
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified that would block approval.
Review effort: Lite
Findings: None
What changed in this PR
Fixes OpenAI-compatible tool schemas so nested object properties retain their required fields.
Changes:
- Emit nested
requiredarrays for object parameter types. - Add regression coverage for nested objects in lists and update expected output.
| File | Description |
|---|---|
| prompt/prompt-executor/prompt-executor-clients/prompt-executor-openai-client-base/src/commonTest/kotlin/ai/koog/prompt/executor/clients/openai/base/OpenAICompatibleToolDescriptorConverterTest.kt | Updated as part of this pull request. |
| prompt/prompt-executor/prompt-executor-clients/prompt-executor-openai-client-base/src/commonMain/kotlin/ai/koog/prompt/executor/clients/openai/base/OpenAICompatibleToolDescriptorSchemaGenerator.kt | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenAICompatibleToolDescriptorSchemaGenerator wrote only the top-level required list. The ToolParameterType.Object branch of fillJsonSchema never wrote requiredProperties, so every property of a nested object, for example the items of a list of objects, became optional in the schema sent to the model. OllamaToolDescriptorSchemaGenerator already writes it.
The Object branch now writes required after properties when requiredProperties is not empty, so objects without required properties produce the same schema as before.
Tests: added testNestedObjectInListKeepsRequiredProperties, which reproduces the issue, and updated the expected JSON of object_with_properties_and_additionalProperties, which had a note saying the converter does not emit required inside a nested object. Both fail on the unmodified generator and pass with the change.
Verification: ran jvmTest for prompt-executor-openai-client-base, and for the clients that inherit this generator (openai, openrouter, deepseek, mistralai, dashscope). All pass. I could not run the full build locally because the module also has an Android target and I have no Android SDK, so I am relying on CI for that.
closes #2255