@devries-cameron20 / composio Mirror · read-only / commits / cf6343b30
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 08:30 UTC

docs(vercel): state that strict mode does not turn on schema enforcement (#5028)

## Summary The docs for `VercelProvider({ strict: true })` imply that it turns on strict structured outputs. It doesn't. The option rewrites each tool's input schema into the form OpenAI strict mode accepts, but the provider never sets the AI SDK's per-tool `strict` flag. Both `@ai-sdk/openai` and `@ai-sdk/anthropic` send the vendor's `strict` only when that flag is set, so with this option on, nothing is enforced. This PR fixes the docs only. It changes no behavior and has no changeset. - `ts/packages/providers/vercel/README.md` and `docs/content/docs/providers/vercel.mdx`: - Replace "Some models reject tool schemas that contain optional parameters" with what the option does. - Add a paragraph: - The option doesn't set the per-tool flag. - It does change local validation: tool-call arguments are checked against the rewritten schema, so a call that leaves out an optional parameter instead of sending `null` fails, and the `null`s are dropped before the tool runs. - If users set it themselves, they should do so only with OpenAI models, and only on tools that didn't log the fallback warning. - They should not set it for Anthropic models. - `ts/packages/providers/vercel/src/index.ts`: add an `@param options.strict` to the constructor JSDoc. ## Why not set the flag in the provider I tested this live against Anthropic (claude-haiku-5-5) and OpenAI with AI SDK 7, using `@ai-sdk/anthropic` 4.0.84 and `@ai-sdk/openai` 4.0.75. I took the tool schemas from the 930-tool fixture in `ts/packages/cli/test/__mocks__/tools.json`. - **Today, without the flag:** the strict-rewritten `GOOGLEDRIVE_CREATE_DRIVE` gets a 200 from both vendors. - **With `strict: true` set on the tool:** OpenAI returns 200. Anthropic returns 400 because of `minimum`/`maximum`. - **Anthropic strict mode limits the whole request, not just each tool.** Across all strict tools in a request: - More than 16 parameters with union types (type arrays or `anyOf`) → 400, "Schemas contains too many parameters with union types". - More than 24 optional parameters → 400. - Recursive `$defs` → 400, "Circular reference detected". - **Anthropic strict mode also rejects these keywords:** - Numbers: `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`. - Arrays: `maxItems`, `uniqueItems`, `minItems` other than 0 or 1. - Objects: `minProperties`, `maxProperties`. - `enum` values that are objects, a type array combined with `enum`, and regexes with lookahead. - **It accepts:** `minLength`, `maxLength`, a simple `pattern`, `format: uri` and `email`, `contentEncoding`, and the annotations `title`, `default` and `examples`. - **The strict rewrite makes every optional parameter a union with `null`.** - Across the 816 tools the rewrite can express, that averages 1.7 union parameters per tool (median 0, p90 4, max 41). 6 tools go over 16 on their own. - The first ten Google Drive tools total 23 union parameters. - So a request with about ten typical Composio tools would hit Anthropic's limit. If the provider set the flag, Anthropic requests that work today would start failing. Moving `minimum`/`maximum` into descriptions wouldn't fix the union and optional limits. Doing it while the flag is off would only take hints away from the model. OpenAI users who want enforcement can set the flag themselves; the new docs say when that is safe. ## Test plan - [x] Prettier check on the README and `index.ts`. `vercel.mdx` already fails the check on `next`, and this PR leaves its formatting unchanged. - [x] Live AI SDK 7 probe of OpenAI and Anthropic, with and without the per-tool `strict` flag (results above).

Alberto Schiabel committed Oct 22, 2026 at 01:17 UTC cf6343b308d02349ed49a9bbe58d3831e993e4be
3 files changed +12 -2
docs/content/docs/providers/vercel.mdx
+3 -1
@@ -57,7 +57,7 @@ console.log(text);
57
58 ## Provider specifics
59
60 -**Strict mode.** Some models reject tool schemas that contain optional parameters. Pass `strict: true` to the provider to normalize each tool's input schema for OpenAI structured outputs before it reaches the AI SDK: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
60 +**Strict mode.** Pass `strict: true` to the provider to rewrite each tool's input schema into the form OpenAI strict mode (structured outputs) accepts before it reaches the AI SDK: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
61
62 ```typescript
63 // @noErrors
@@ -67,6 +67,8 @@ import { VercelProvider } from "@composio/vercel";
67 const composio = new Composio({ provider: new VercelProvider({ strict: true }) });
68 ```
69
70 +The option does not set the AI SDK's per-tool `strict` flag, so the model provider does not enforce the schema. It does change what the provider accepts locally: tool-call arguments are validated against the rewritten schema, so a call that leaves out an optional parameter instead of sending `null` fails validation, and those `null`s are dropped before the tool runs, as described above. If you set that flag yourself, use it only with OpenAI models and only on tools that did not log the warning above, since OpenAI rejects a tool that kept its original schema. Don't set it for Anthropic models: Anthropic strict mode allows at most 16 parameters with union types and 24 optional parameters across all strict tools in a request, and the rewrite turns every optional parameter into a union, so a request with about ten Composio tools is rejected. Anthropic strict mode also rejects recursive definitions and keywords such as `minimum` and `maximum` that some Composio tools use.
71 +
72 <Callout type="info">
73 The provider sends each Composio tool's JSON Schema to the model as is, so keywords such as `format`, `contentEncoding`, and `contentMediaType` reach it, and validates tool-call arguments with a Zod schema built from the same JSON Schema. It also normalizes tool arguments, so it still works when a model emits tool input as a JSON string rather than an object.
74 </Callout>
ts/packages/providers/vercel/README.md
+3 -1
@@ -45,12 +45,14 @@ For multi-turn conversations, store `session.sessionId` and reuse it with `compo
45
46 ## Strict mode
47
48 -Some models reject tool schemas that contain optional parameters. Pass `strict: true` to normalize each tool's input schema for OpenAI structured outputs before it reaches the AI SDK: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
48 +Pass `strict: true` to rewrite each tool's input schema into the form OpenAI strict mode (structured outputs) accepts before it reaches the AI SDK: every object lists all of its properties in `required` and is closed, and optional properties stay available but accept `null`. A `null` is dropped before the tool runs unless the tool's own schema accepts `null` for that parameter, so nullable fields still receive an explicit `null`. Tools whose schema cannot be expressed in strict mode, such as objects that accept arbitrary keys, `allOf`, `prefixItems`, or unresolved `$ref`s, keep their original schema and log a warning:
49
50 ```typescript
51 const composio = new Composio({ provider: new VercelProvider({ strict: true }) });
52 ```
53
54 +The option does not set the AI SDK's per-tool `strict` flag, so the model provider does not enforce the schema. It does change what the provider accepts locally: tool-call arguments are validated against the rewritten schema, so a call that leaves out an optional parameter instead of sending `null` fails validation, and those `null`s are dropped before the tool runs, as described above. If you set that flag yourself, use it only with OpenAI models and only on tools that did not log the warning above, since OpenAI rejects a tool that kept its original schema. Don't set it for Anthropic models: Anthropic strict mode allows at most 16 parameters with union types and 24 optional parameters across all strict tools in a request, and the rewrite turns every optional parameter into a union, so a request with about ten Composio tools is rejected. Anthropic strict mode also rejects recursive definitions and keywords such as `minimum` and `maximum` that some Composio tools use.
55 +
56 ## Tool schemas
57
58 The provider passes each tool's JSON Schema to the AI SDK with `jsonSchema()`, so the model sees it as is, including keywords such as `format`, `contentEncoding`, and `contentMediaType`. Internal `$ref`s are inlined first. Tool-call arguments are validated with a Zod schema built from the same JSON Schema. In strict mode the model sees the strict rewrite instead, which drops string formats strict structured outputs reject.
ts/packages/providers/vercel/src/index.ts
+6
@@ -73,6 +73,12 @@ export class VercelProvider extends BaseAgenticProvider<
73 * // Use the provider to wrap tools for Vercel AI SDK
74 * const vercelTools = provider.wrapTools(composioTools, composio.tools.execute);
75 * ```
76 + *
77 + * @param options.strict - Rewrites each tool's input schema into the form
78 + * OpenAI strict mode accepts, and validates tool-call arguments against it.
79 + * It does not set the AI SDK's per-tool `strict` flag, so the model provider
80 + * does not enforce the schema. Anthropic strict mode rejects requests with
81 + * typical sets of rewritten tools; see the README.
82 */
83 constructor({ strict = false }: { strict?: boolean } = {}) {
84 super();