feat(llm): pass strict through tool definitions for Codex parity#33392
Open
rekram1-node wants to merge 1 commit into
Open
feat(llm): pass strict through tool definitions for Codex parity#33392rekram1-node wants to merge 1 commit into
rekram1-node wants to merge 1 commit into
Conversation
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.
Summary
Codex CLI hardcodes
strict: falseon every function tool sent to the OpenAI Responses API (codex-rs/tools/src/responses_api.rs:131). This ensures MCP-sourced and dynamic schemas that don't satisfy OpenAI's structured-outputs constraints still register instead of being rejected.This PR adds first-class
strictsupport to the@opencode-ai/llmtool model and injectsstrict: falsefrom opencode for OpenAI Responses-family providers to match Codex behavior.Changes
@opencode-ai/llm(generic library — no policy decisions)schema/messages.ts: addstrict?: booleantoToolDefinitiontool.ts: acceptstrictonTool.make()(typed + dynamic configs), carry it throughtoDefinitions()onto theToolDefinitionprotocols/openai-responses.ts:lowerToolpassestool.strictthrough conditionally —...(tool.strict != null ? { strict: tool.strict } : {})— same pattern as the AI SDKopencode(owns the Codex-parity policy)session/llm/request.ts(AI SDK path): injectsstrict: falseon every tool whenmodel.api.npmis@ai-sdk/openai,@ai-sdk/azure, or@ai-sdk/amazon-bedrock/mantle— the same provider set already used for Responses item-ID stripping attransform.ts:466session/llm/native-runtime.ts(native path): passesstrict: falseviaNativeTool.make()whenmodel.api.npm === "@ai-sdk/openai"(the only provider the native gate supports)Why not hardcode in the llm package
The llm package is a generic library. Codex-parity policy ("always send
strict: false") belongs in opencode, not in the library. The library's job is to carrystrictfaithfully from tool construction to the wire, which is what this does.Verification
bun typecheckclean for bothpackages/llmandpackages/opencodebun test test/provider/openai-responses.test.ts— 51 passbun test test/provider/openai-responses-cache.recorded.test.ts— 1 passbun test test/session/llm-native.test.ts— 16 pass