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(core): fold OpenAPI `nullable` into the type in strict tool schemas (#4997)
## Summary Anthropic strict tool use rejects OpenAPI `nullable` on an object schema ("For 'object' type, property 'nullable' is not supported"), with a 400 for the whole request. `toStrictJsonSchema` passed the keyword through. That blocks https://github.com/ComposioHQ/composio/pull/4940, where Vercel strict mode now sends the strict schema as is instead of a Zod rendering that dropped `nullable`. Part of https://github.com/ComposioHQ/composio/issues/4911. Designated PR reviewer: [@jkomyno](mailto:alberto@composio.dev). ## Changes - **Strict rewrite (TypeScript and Python):** `nullable` is removed at every depth. A node with `nullable: true` is widened the way optional properties already are: `null` joins a lone `type` (`["object", "null"]`), a lone `anyOf` gains a null branch, and anything else (a typed `enum`, say) is wrapped in `anyOf: [node, {type: "null"}]`. This matches the Zod conversion, which accepts `null` for `nullable: true` whatever the other keywords say. The rewrite is reported as a new `nullable-converted` change. `nullable: false`, or a `true` that changes nothing, is reported as `unsupported-keyword-stripped`. - **Null check:** the shared null check treats `nullable: true` as accepting `null`. Without this, `omitNullToolArguments` would drop the `null` the model can now send for a required nullable property, and the call would fail validation. **Behavior change:** a `null` for an *optional* `nullable: true` property is now kept rather than treated as "omitted", which is what already happens when a property's `type` includes `null`. - **Shared corpus:** adds the case `openapi-nullable-folded`, covering an object, a string, a typed enum, an untyped node, `nullable: false`, and nullable array items, along with the argument behavior. The json-schema-to-zod v3 fingerprint snapshot only gains lines for the new case. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactor/Chore - [ ] Documentation - [ ] Breaking change ## How Has This Been Tested? - `@composio/core`: vitest (1926 passed) and `tsc --noEmit` - `@composio/json-schema-to-zod`: vitest (2305 passed, on zod 3.25, 4.1.13 and 4.5) - Python: `pytest tests/test_strict_schema*.py` (155 passed, shared corpus included), plus ruff and mypy - `validate:changesets` - Results over the 930-tool fixture (`ts/packages/cli/test/__mocks__/tools.json`): | | Before | After | |---|---|---| | Strict-compatible tools | 816 | 816 | | Tools with `nullable` in the strict output | 76 | 0 | | Failures in the OpenAI `openai/lib/transform` oracle | 0 | 0 | - Live strict requests for the 5 tools with `nullable` on an object: - OpenAI (gpt-5-mini): 200 for all 5. - Anthropic (claude-haiku-5-5): `GITHUB_CREATE_A_CODESPACE_FOR_THE_AUTHENTICATED_USER` now returns 200. The other 4 no longer fail on `nullable` but now fail on "For 'number'/'integer' type, properties maximum, minimum are not supported". See below. ## Checklist - [ ] I have read the Code of Conduct and this PR adheres to it - [ ] I have read and understand every line of this diff, including any LLM-generated code - [x] Any third-party docs links or promotional content follow the [third-party links policy](https://github.com/ComposioHQ/composio/blob/next/CONTRIBUTING.md#third-party-links-in-docs) - [x] I ran linters/tests locally and they passed - [x] I updated documentation as needed - [x] I added tests or explain why not applicable - [x] I added a changeset if this change affects published packages ## Additional context **Not covered here:** Anthropic strict mode also rejects numeric `minimum`/`maximum`, which 29 of the 816 strict-compatible tools carry. Before #4940 the Zod rendering kept those keywords too, so this failure is older and is not a #4940 regression. `toStrictJsonSchema` follows the OpenAI contract, which accepts them. Fixing it means a separate model-facing rewrite for Anthropic strict mode, for example moving the bounds into the description while the tool's own schema still validates the arguments. That belongs in its own change.