Skip to content

Conversation

@lucas-althoff
Copy link

Summary

Prevents tool wrapping failures in composio_langchain when tool schemas contain parameter names that are not valid Python identifiers (e.g., @microsoft.graph.conflictBehavior). Instead of crashing, invalid parameters are silently skipped — preserving tool usability while logging a warning for visibility.

Changes

  • Modified get_signature_format_from_schema_params in python/composio/utils/shared.py:
    • Wrapped Parameter(...) constructor in try/except ValueError
    • Skips parameters with invalid names instead of crashing
    • Logs a warning to help users identify skipped parameters (optional — see note below)

⚠️ Note: For now, we skip silently to match current error-handling style. A follow-up PR can add logging or aliasing (e.g., @microsoft.graph.conflictBehavior_microsoft_graph_conflictBehavior).

Problem Solved

LangChain tool wrapping crashes when integrating with toolkits like one_drive, google_drive, or others that use JSON Schema parameter names containing @, $, or other invalid Python identifier characters.

This breaks agent workflows silently and prevents use of otherwise functional tools.

Example error before fix:

ValueError: '@microsoft.graph.conflictBehavior' is not a valid parameter name

Traceback (most recent call last):
\src\scripts\composio_cli.py", line 32, in
app_tools = composio.tools.get(user_id=os.environ["COMPOSIO_USER"],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
]composio\core\models\base.py", line 59, in trace_wrapper
raise e
\composio\core\models\base.py", line 50, in trace_wrapper
return method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\composio\core\models\tools.py", line 259, in get
return self._get(
^^^^^^^^^^
\composio\core\models\tools.py", line 182, in _get
return t.cast(AgenticProvider, self.provider).wrap_tools(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\composio_langchain\provider.py", line 140, in wrap_tools
return [self.wrap_tool(tool=tool, execute_tool=execute_tool) for tool in tools]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\composio_langchain\provider.py", line 110, in wrap_tool
parameters=get_signature_format_from_schema_params(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\composio\utils\shared.py", line 358, in get_signature_format_from_schema_params
parameter = Parameter(
^^^^^^^^^^
\uv\python\cpython-3.12.11-windows-x86_64-none\Lib\inspect.py", line 2782, in init
raise ValueError('{!r} is not a valid parameter name'.format(name))
ValueError: '$filter' is not a valid parameter name


## Breaking Change

None. This is a defensive fix — tools that previously crashed now load (with invalid params skipped). Tool functionality remains intact as long as skipped params are optional or have defaults.

## Migration

None required. Existing code will now work with previously failing toolkits.

## Files Changed

- `python/composio/utils/shared.py` — Add try/except around Parameter creation

@haxzie haxzie self-assigned this Oct 7, 2025
@haxzie haxzie added bug Something isn't working API/Integrations labels Oct 7, 2025
@haxzie
Copy link
Collaborator

haxzie commented Oct 7, 2025

Hey @lucas-althoff we are investigating this issue. Our best approach here would be to fix the tool itself. Parking this PR for now until we fix the tools. Thank you 🙌🏽

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

beep boop inactive for 60 days, closing in 48 hours

@github-actions github-actions bot added the stale label Dec 7, 2025
@github-actions
Copy link
Contributor

closed due to inactivity. feel free to reopen if still relevant.

@github-actions github-actions bot closed this Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API/Integrations bug Something isn't working stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants