@devries-cameron20 / composio-1 / commits / 6dde98e5b
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.

fix(py): use `inspect.iscoroutinefunction` for custom tool async checks (#5289)

This PR: - closes https://github.com/ComposioHQ/composio/issues/5264 - replaces the two `asyncio.iscoroutinefunction` checks in `custom_tool.py` with `inspect.iscoroutinefunction`, so registering custom tools no longer emits a `DeprecationWarning` on Python 3.14+ - removes the now-unused `asyncio` import, which the repo's Ruff config flags - keeps async-tool rejection unchanged: both helpers agree on `async def`, bound async methods, `functools.partial`, `AsyncMock`, and `inspect.markcoroutinefunction` on Python 3.11, 3.12, and 3.15 - builds on the fix by @AbhishekOjha0789 (commit f17406e, kept with original authorship), who could not open the PR because PR creation is restricted to collaborators ## Verification - Python 3.15.1, `-W error::DeprecationWarning`, `tests/test_custom_tools.py` + `tests/test_tool_router.py`: 108 failures on `next`, all from this warning; 333 passed with the fix (isolated env, since the locked `pydantic-core` has no 3.15 wheel) - Locked Python 3.12 env: full `python/tests` suite 2487 passed, 215 skipped - `ruff check --config config/ruff.toml composio/ tests/`, `ruff format --check`, and `SDK_RELEASE_NOTE_BASE=origin/next pnpm validate:changesets` pass; mypy reports nothing in `custom_tool.py` --------- Co-authored-by: Abhishek Ojha <abhishekojha0789@gmail.com>

Alberto Schiabel committed Nov 9, 2026 at 23:30 UTC 6dde98e5b96beff05381da56d186d60ca7abb11d
4 files changed +9 -5
.changeset/custom-tool-coroutine-check.md new
+5
@@ -0,0 +1,5 @@
1 +---
2 +'@composio/python-sdk': patch
3 +---
4 +
5 +Stop emitting a `DeprecationWarning` on Python 3.14+ when registering custom tools. The async-function check now uses `inspect.iscoroutinefunction`, and async tools are still rejected as before.
docs/content/reference/sdk-reference/python/session.mdx
+1 -1
@@ -344,4 +344,4 @@ def delete() -> ToolRouterSessionDeleteResponse
344
345 ---
346
347 -[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tool_router_session.py#L322)
347 +[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tool_router_session.py#L316)
docs/content/reference/sdk-reference/python/tools.mdx
+1 -1
@@ -183,4 +183,4 @@ def proxy(endpoint: str, method: Literal['GET', 'POST', 'PUT', 'DELETE', 'PATCH'
183
184 ---
185
186 -[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tools.py#L331)
186 +[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tools.py#L308)
python/composio/core/models/custom_tool.py
+2 -3
@@ -40,7 +40,6 @@ Usage::
40
41 from __future__ import annotations
42
43 -import asyncio
43 import inspect
44 import sys
45 import typing as t
@@ -244,7 +243,7 @@ def _create_tool(
243 if not callable(execute):
244 raise ValidationError(f"{context}: execute must be a callable")
245
247 - if asyncio.iscoroutinefunction(execute):
246 + if inspect.iscoroutinefunction(execute):
247 raise ValidationError(
248 f"{context}: execute must be a synchronous function, not async. "
249 f"The Composio Python SDK is synchronous — use a regular "
@@ -373,7 +372,7 @@ def _infer_tool_from_function(
372 # (input: BaseModel, ctx) — with session context
373 # The first param MUST be annotated with a BaseModel subclass.
374 # Reject async before wrapping (wrapper would hide it from _create_tool)
376 - if asyncio.iscoroutinefunction(fn):
375 + if inspect.iscoroutinefunction(fn):
376 raise ValidationError(
377 f'experimental.tool: "{fn.__name__}" is async. '
378 f"The Composio Python SDK is synchronous — use a regular "