From e8a5cc5ee387164b911959e3f3f349c08757ea10 Mon Sep 17 00:00:00 2001 From: cthomas Date: Wed, 11 Jun 2025 16:24:37 -0700 Subject: [PATCH] fix: composio tools with array args (#2762) --- letta/functions/schema_generator.py | 7 +++++-- tests/test_tool_schema_parsing.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/letta/functions/schema_generator.py b/letta/functions/schema_generator.py index c846aa9d..7242e314 100644 --- a/letta/functions/schema_generator.py +++ b/letta/functions/schema_generator.py @@ -547,8 +547,11 @@ def generate_tool_schema_for_composio( property_schema["enum"] = field_props["enum"] # Handle array item types - if field_props["type"] == "array" and "items" in field_props: - property_schema["items"] = field_props["items"] + if field_props["type"] == "array": + if "items" in field_props: + property_schema["items"] = field_props["items"] + elif "anyOf" in field_props: + property_schema["items"] = [t for t in field_props["anyOf"] if "items" in t][0]["items"] # Add the property to the schema properties_json[field_name] = property_schema diff --git a/tests/test_tool_schema_parsing.py b/tests/test_tool_schema_parsing.py index 89b2ed73..9d63c09f 100644 --- a/tests/test_tool_schema_parsing.py +++ b/tests/test_tool_schema_parsing.py @@ -289,8 +289,8 @@ def test_composio_tool_schema_generation(openai_model: str, structured_output: b action_names = [ "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", # Simple "CAL_GET_AVAILABLE_SLOTS_INFO", # has an array arg, needs to be converted properly - "SALESFORCE_RETRIEVE_LEAD_BY_ID", - # has an array arg, needs to be converted properly + "SALESFORCE_RETRIEVE_LEAD_BY_ID", # has an array arg, needs to be converted properly + "FIRECRAWL_SEARCH", # has an optional array arg, needs to be converted properly ] # Create a pool of processes