fix(tools): respect function.strict = false in to_new_openai#2800
Closed
bahaaza wants to merge 1 commit intoolimorris:developfrom
Closed
fix(tools): respect function.strict = false in to_new_openai#2800bahaaza wants to merge 1 commit intoolimorris:developfrom
bahaaza wants to merge 1 commit intoolimorris:developfrom
Conversation
When a tool schema sets strict = false on the function key (e.g. mcphub's use_mcp_tool), to_new_openai previously ignored it because it only checked parameters.strict. This caused enforce_strictness to be applied even when the tool explicitly opted out, breaking tools with dynamic schemas like tool_input (object with no predefined properties). Now resolves the tool's strict preference by checking function.strict first, falling back to parameters.strict. Enforcement is skipped only when the resolved value is explicitly false.
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.
Description
When a tool schema sets
strict = falseon the["function"]key (e.g. mcphub'suse_mcp_tool),to_new_openaiignored it because it only checkedparameters.strict. This causedenforce_strictnessto be applied even when the tool explicitly opted out.For tools with dynamic schemas like
tool_input(an object with no predefinedpropertiesbutadditionalProperties = false), forcing strict mode made the schema reject all properties — the LLM would send emptytool_input: {}or the API would reject the schema entirely, resulting in silent tool failure.Root Cause
mcphub sets
strict = falseonschema["function"].strict, not onschema["function"].parameters.strict, so the opt-out was never seen.Fix
Resolve the tool's strict preference by checking
function.strictfirst, falling back toparameters.strict. Enforcement is skipped only when the resolved value is explicitlyfalse:function.strictparameters.strictstrict_modenilniltruetruetruefalsetruefalseAI Usage
CodeCompanion (Claude) was used to help trace the execution path and draft the fix. The core analysis, root cause identification, and fix logic were directed by me.
Related Issue(s)
Fixes silent tool failure when using mcphub.nvim with the OpenAI Responses adapter (
strict_mode = true).Screenshots
N/A — logic-only change, no UI impact.
Checklist
make allto ensure docs are generated, tests pass and StyLua has formatted the code