@devries-cameron20 / composio-1 / commits / b20ca59d9
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(openai): keep optional parameters under strict mode instead of dropping them (#4257)

This PR: - builds on top of https://github.com/ComposioHQ/composio/pull/4209 by @AseemPrasad, keeping its recursive `toStrictJsonSchema()` and Python parity while changing the mechanism so strict mode stops deleting parameters - keeps every optional parameter under `strict: true`: properties become required and optional ones accept `null` (the emulation OpenAI documents), instead of dropping 42% of parameters across the 930-tool corpus; `type` arrays stay as they are, so nullable objects stay nullable - sends tools whose schema strict mode cannot express (objects with arbitrary keys, `allOf`, `prefixItems`, dangling `$ref`s, non-object roots) with `strict: false` and a warning naming the tool and path, instead of narrowing them to empty closed objects - adds `omitNullToolArguments()`: the strict providers drop a `null` argument only where the tool's own schema rejects it, so nullable fields keep an explicit `null` - keeps local `$ref`/`$defs` (recursion included) under strict mode instead of inlining them - brings the Python `OpenAIResponsesProvider(strict=True)` to parity: emits `strict`, calls the base initializer, mirrors the rewrite and null omission - makes Mastra and openai-agents use the same strict semantics (`OpenAIAgentsProvider({ strict: true })` previously had no effect) - pins the behavior with a shared `strict-cases.json` corpus (byte-identical TypeScript/Python copies) plus edge-case regression tests enumerated independently with a second model ## Context OpenAI's structured-outputs contract accepts `"type": ["string", "null"]` and rejects `type` next to `anyOf`. Validated against OpenAI's own `toStrictJsonSchema` converter over the 930 real tool schemas in `ts/packages/cli/test/__mocks__/tools.json`: the previous approach was accepted for 930/930 tools but only after removing 1,682 properties; this one emits strict schemas for 816 tools (all accepted, no property lost, idempotent) and downgrades the 114 tools that use free-form or map-style parameters. https://claude.ai/code/session_01TDrxCHn2hg51HmxVstSUgs

Alberto Schiabel committed Aug 27, 2026 at 16:05 UTC b20ca59d91a22b965f7a72389c598aadf32074a6

No changes.