Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(py): address cursorbot
jkomynod61cede63606
diff --git a/python/providers/gemini/composio_gemini/provider.py b/python/providers/gemini/composio_gemini/provider.pyindex 250777501..797346a5e 100644--- a/python/providers/gemini/composio_gemini/provider.py+++ b/python/providers/gemini/composio_gemini/provider.py@@ -5,6 +5,7 @@ Calling (AFC). The SDK can introspect the callable's signature to deriveFunctionDeclaration schemas and auto-execute tool calls in the chat loop."""+import copyimport types as pytypesimport typing as tfrom inspect import Parameter, Signature@@ -34,6 +35,8 @@ def _substitute_reserved_python_keywords(schema: t.Dict) -> t.Tuple[dict, dict]:if "properties" not in schema:return schema, {}+ schema = copy.deepcopy(schema)+keywords: t.Dict[str, str] = {}for p_name in list(schema["properties"]):if p_name not in _python_reserved:@@ -44,6 +47,12 @@ def _substitute_reserved_python_keywords(schema: t.Dict) -> t.Tuple[dict, dict]:schema["properties"][p_name_clean] = p_valkeywords[p_name_clean] = p_name+ if keywords and "required" in schema:+ reverse_map = {v: k for k, v in keywords.items()}+ schema["required"] = [+ reverse_map.get(name, name) for name in schema["required"]+ ]+return schema, keywordsdiff --git a/python/tests/test_gemini_provider.py b/python/tests/test_gemini_provider.pyindex 8b4774f6c..647988d03 100644--- a/python/tests/test_gemini_provider.py+++ b/python/tests/test_gemini_provider.py@@ -360,6 +360,62 @@ class TestWrapTool:assert call_args[0][1]["for"] == "test_value"assert call_args[0][1]["name"] == "hello"+ def test_wrap_same_tool_twice_does_not_corrupt_schema(self):+ """Wrapping the same Tool object twice must not corrupt the schema."""+ from composio_gemini import GeminiProvider++ provider = GeminiProvider()+ tool = create_mock_tool(+ "TOOL_RESERVED",+ "test",+ input_parameters={+ "type": "object",+ "properties": {+ "for": {"type": "string"},+ "name": {"type": "string"},+ },+ "required": ["for"],+ },+ )+ execute_tool = create_mock_execute_tool()++ func1 = provider.wrap_tool(tool, execute_tool)+ func2 = provider.wrap_tool(tool, execute_tool)++ # Both callables must have the cleaned parameter+ sig1 = inspect.signature(func1)+ sig2 = inspect.signature(func2)+ assert "for_rs" in sig1.parameters+ assert "for_rs" in sig2.parameters++ # Original tool schema must be unchanged+ assert "for" in tool.input_parameters["properties"]+ assert "for_rs" not in tool.input_parameters["properties"]++ def test_reserved_keyword_stays_required(self):+ """A reserved keyword listed in 'required' must remain required after renaming."""+ from composio_gemini import GeminiProvider++ provider = GeminiProvider()+ tool = create_mock_tool(+ "TOOL_REQUIRED_RESERVED",+ "test",+ input_parameters={+ "type": "object",+ "properties": {+ "for": {"type": "string"},+ "name": {"type": "string"},+ },+ "required": ["for", "name"],+ },+ )+ func = provider.wrap_tool(tool, create_mock_execute_tool())++ sig = inspect.signature(func)+ # Both params should be required (no default value)+ assert sig.parameters["for_rs"].default is inspect.Parameter.empty+ assert sig.parameters["name"].default is inspect.Parameter.empty+# ---------------------------------------------------------------------------# wrap_tools