@devries-cameron20 / composio Mirror · read-only / commits / d61cede63
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 22, 10:45 UTC

fix(py): address cursorbot

jkomyno committed Feb 6, 2026 at 09:41 UTC d61cede636060a97c3aa494b39fd6ea528be60ae
2 files changed +65
python/providers/gemini/composio_gemini/provider.py
+9
@@ -5,6 +5,7 @@ Calling (AFC). The SDK can introspect the callable's signature to derive
5 FunctionDeclaration schemas and auto-execute tool calls in the chat loop.
6 """
7
8 +import copy
9 import types as pytypes
10 import typing as t
11 from inspect import Parameter, Signature
@@ -34,6 +35,8 @@ def _substitute_reserved_python_keywords(schema: t.Dict) -> t.Tuple[dict, dict]:
35 if "properties" not in schema:
36 return schema, {}
37
38 + schema = copy.deepcopy(schema)
39 +
40 keywords: t.Dict[str, str] = {}
41 for p_name in list(schema["properties"]):
42 if p_name not in _python_reserved:
@@ -44,6 +47,12 @@ def _substitute_reserved_python_keywords(schema: t.Dict) -> t.Tuple[dict, dict]:
47 schema["properties"][p_name_clean] = p_val
48 keywords[p_name_clean] = p_name
49
50 + if keywords and "required" in schema:
51 + reverse_map = {v: k for k, v in keywords.items()}
52 + schema["required"] = [
53 + reverse_map.get(name, name) for name in schema["required"]
54 + ]
55 +
56 return schema, keywords
57
58
python/tests/test_gemini_provider.py
+56
@@ -360,6 +360,62 @@ class TestWrapTool:
360 assert call_args[0][1]["for"] == "test_value"
361 assert call_args[0][1]["name"] == "hello"
362
363 + def test_wrap_same_tool_twice_does_not_corrupt_schema(self):
364 + """Wrapping the same Tool object twice must not corrupt the schema."""
365 + from composio_gemini import GeminiProvider
366 +
367 + provider = GeminiProvider()
368 + tool = create_mock_tool(
369 + "TOOL_RESERVED",
370 + "test",
371 + input_parameters={
372 + "type": "object",
373 + "properties": {
374 + "for": {"type": "string"},
375 + "name": {"type": "string"},
376 + },
377 + "required": ["for"],
378 + },
379 + )
380 + execute_tool = create_mock_execute_tool()
381 +
382 + func1 = provider.wrap_tool(tool, execute_tool)
383 + func2 = provider.wrap_tool(tool, execute_tool)
384 +
385 + # Both callables must have the cleaned parameter
386 + sig1 = inspect.signature(func1)
387 + sig2 = inspect.signature(func2)
388 + assert "for_rs" in sig1.parameters
389 + assert "for_rs" in sig2.parameters
390 +
391 + # Original tool schema must be unchanged
392 + assert "for" in tool.input_parameters["properties"]
393 + assert "for_rs" not in tool.input_parameters["properties"]
394 +
395 + def test_reserved_keyword_stays_required(self):
396 + """A reserved keyword listed in 'required' must remain required after renaming."""
397 + from composio_gemini import GeminiProvider
398 +
399 + provider = GeminiProvider()
400 + tool = create_mock_tool(
401 + "TOOL_REQUIRED_RESERVED",
402 + "test",
403 + input_parameters={
404 + "type": "object",
405 + "properties": {
406 + "for": {"type": "string"},
407 + "name": {"type": "string"},
408 + },
409 + "required": ["for", "name"],
410 + },
411 + )
412 + func = provider.wrap_tool(tool, create_mock_execute_tool())
413 +
414 + sig = inspect.signature(func)
415 + # Both params should be required (no default value)
416 + assert sig.parameters["for_rs"].default is inspect.Parameter.empty
417 + assert sig.parameters["name"].default is inspect.Parameter.empty
418 +
419
420 # ---------------------------------------------------------------------------
421 # wrap_tools