Skip to content

feat(llm): pass strict through tool definitions for Codex parity#33392

Open
rekram1-node wants to merge 1 commit into
devfrom
strict-tools-parity
Open

feat(llm): pass strict through tool definitions for Codex parity#33392
rekram1-node wants to merge 1 commit into
devfrom
strict-tools-parity

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

Codex CLI hardcodes strict: false on 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 strict support to the @opencode-ai/llm tool model and injects strict: false from opencode for OpenAI Responses-family providers to match Codex behavior.

Changes

@opencode-ai/llm (generic library — no policy decisions)

  • schema/messages.ts: add strict?: boolean to ToolDefinition
  • tool.ts: accept strict on Tool.make() (typed + dynamic configs), carry it through toDefinitions() onto the ToolDefinition
  • protocols/openai-responses.ts: lowerTool passes tool.strict through conditionally — ...(tool.strict != null ? { strict: tool.strict } : {}) — same pattern as the AI SDK

opencode (owns the Codex-parity policy)

  • session/llm/request.ts (AI SDK path): injects strict: false on every tool when model.api.npm is @ai-sdk/openai, @ai-sdk/azure, or @ai-sdk/amazon-bedrock/mantle — the same provider set already used for Responses item-ID stripping at transform.ts:466
  • session/llm/native-runtime.ts (native path): passes strict: false via NativeTool.make() when model.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 carry strict faithfully from tool construction to the wire, which is what this does.

Verification

  • bun typecheck clean for both packages/llm and packages/opencode
  • bun test test/provider/openai-responses.test.ts — 51 pass
  • bun test test/provider/openai-responses-cache.recorded.test.ts — 1 pass
  • bun test test/session/llm-native.test.ts — 16 pass

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

Successfully merging this pull request may close these issues.

1 participant