fix: deduplicate required arrays in tool schemas to comply with JSON Schema 2020-12#3025
Conversation
…Schema 2020-12 Some tool schemas returned by the API contain duplicate entries in their `required` arrays, violating JSON Schema 2020-12 §6.5.3. This causes strict validators (e.g. Anthropic Claude API) to reject the entire tool batch, breaking inference for all users with affected toolkits connected. Add recursive deduplication of `required` arrays in both TypeScript and Python SDKs at the central schema processing layer, so all providers benefit without per-provider changes. Fixes ComposioHQ#2933
|
@saakshigupta2002 is attempting to deploy a commit to the Composio Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| tool.input_parameters = deduplicate_required_fields( | ||
| tool.input_parameters, | ||
| ) | ||
|
|
There was a problem hiding this comment.
Python tool router path missing required field deduplication
Medium Severity
The deduplication fix is applied to get_raw_composio_tools and get_raw_composio_tool_by_slug but not to get_raw_tool_router_meta_tools, which is a third tool retrieval path used by ToolRouterSession.tools(). The TypeScript SDK correctly handles this path because getRawToolRouterMetaTools calls transformToolCases, which applies deduplicateRequiredFields. Tools fetched through the Python tool router session will still carry duplicate required entries and trigger the same Anthropic API rejection this PR aims to fix.
Additional Locations (1)
|
This should ideally be fixed from the tool/api level not SDK level. Thanks for the PR, closing this for now. |


Summary
Some tool schemas returned by the Composio API contain duplicate entries in their
requiredarrays, which violates JSON Schema 2020-12 §6.5.3. When these schemas are sent to strict JSON Schema validators — most notably the Anthropic Claude API — the entire tool batch is rejected with:This breaks inference for all users who have affected toolkits connected, not just calls to the specific offending tools. Known affected tools include
GITHUB_UPDATE_A_REPOSITORY_VARIABLEandINTERCOM_ATTACH_A_CONTACT_TO_A_COMPANY, though any tool with merged schema variants (viaallOf,anyOf,oneOf) could be affected.This PR adds recursive deduplication of
requiredarrays in both the TypeScript and Python SDKs at the central schema processing layer, ensuring all downstream providers (OpenAI, Anthropic, Vercel, LangChain, etc.) automatically receive compliant schemas without any per-provider changes.Fixes #2933
Changes
deduplicateRequiredFields()utility ints/packages/core/src/utils/jsonSchema.tsthat recursively traverses schemas (including nestedproperties,items,allOf,anyOf,oneOf) and deduplicates anyrequiredarrays using[...new Set()]transformToolCases()ints/packages/core/src/models/Tools.tsso schemas are sanitized immediately when received from the API, before any provider processes themdeduplicate_required_fields()utility inpython/composio/utils/shared.pyusinglist(dict.fromkeys())to preserve insertion order while removing duplicatesget_raw_composio_tools()andget_raw_composio_tool_by_slug()inpython/composio/core/models/tools.pyto cover all tool retrieval pathsallOf/anyOf/oneOf), arrayitems, immutability of original input, edge cases (null/undefined), and order preservationType of change
How Has This Been Tested?
TypeScript SDK:
Python SDK:
Test scenarios include:
requiredarraysrequiredfieldpropertiesallOf,anyOf, andoneOfcombinersitemsschema deduplicationChecklist
Additional context
Root cause: The duplicate
requiredentries likely originate from the backend API's schema generation pipeline, possibly when merging schema variants. This SDK-side fix acts as a defensive layer, ensuring compliance regardless of what the API returns.Performance impact: Negligible — the deduplication is a lightweight
O(n)operation usingSet(TS) /dict.fromkeys(Python), applied once per tool schema during retrieval.Backward compatibility: Fully backward compatible. Schemas without duplicates pass through unchanged. The fix only removes redundant entries that violate the spec.