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
feat(py): support type-safe generic get_tools() based on given provider (#2469)
Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
Alberto Schiabel committed
Feb 9, 2026 at 14:25 UTC
ff1e89b7c2e1b9d3a3ecc1421c8a54db3c4cfed0
53 files changed
+1677
-209
.claude/commands/changelog.md
+80
-45
@@ -1,68 +1,103 @@
1
-Check the changes between the current branch and next branch, and create a changelog file inside `/fern/pages/src/changelog` in the file format of `MM-DD-YY-<title>.md`.
1
+Check the changes between the current branch and next branch, and create a changelog file inside `/docs/content/changelog` in the file format of `MM-DD-YY-<title>.mdx`.
2
3
-## Changelog File Structure
3
+## File Naming
4
5
-### Required Sections
5
+```
6
+MM-DD-YY.mdx # e.g., 12-29-25.mdx
7
+MM-DD-YY-suffix.mdx # Multiple same day: 12-10-25-masking.mdx
8
+```
9
+
10
+## Template
11
7
-1. **Title** (H1): A clear, descriptive title of the change
8
-2. **Version Information**: Include SDK versions for both TypeScript and Python
9
-3. **Description**: Brief explanation of what changed and why
12
+```mdx
13
+---
14
+title: "Your Title Here"
15
+description: "Brief description of the change"
16
+date: "YYYY-MM-DD"
17
+---
18
11
-### Version Information Format
19
+Brief intro paragraph explaining what changed.
20
13
-```markdown
14
-## Version Information
21
+### SDK Versions
22
16
-### TypeScript/JavaScript
17
-- Package: `@composio/core` (and provider packages if applicable)
18
-- Version: `X.Y.Z`+
23
+| SDK | Version |
24
+|-----|---------|
25
+| Python | vX.Y.Z+ |
26
+| TypeScript | vX.Y.Z+ |
27
20
-### Python
21
-- Package: `composio` (and provider packages if applicable)
22
-- Version: `X.Y.Z`+
28
+### What Changed (if applicable)
29
+
30
+**Before:**
31
+```python
32
+old_code()
33
```
34
25
-Use `+` suffix to indicate "this version and later".
35
+**After:**
36
+```python
37
+new_code()
38
+```
39
27
-### Optional Sections (include as needed)
40
+### Breaking Changes (if applicable)
41
29
-- **What Changed**: Before/after comparison with code examples
30
-- **Why This Change?**: Explanation of the motivation
31
-- **New Features/Capabilities**: For feature additions
32
-- **Migration Guide**: For breaking changes
33
-- **Backward Compatibility**: Compatibility notes
34
-- **Impact Summary**: Table showing breaking changes and migration requirements
35
-- **How to Update**: Package manager commands for updating
42
+<Callout type="warn">
43
+**Breaking Change**
44
37
-### Alerts
45
+What breaks and why.
46
+</Callout>
47
39
-Use these MDX components for important notices:
40
-- `<Warning>` for breaking changes
41
-- `<Note>` for important information
48
+### What's New / Improvements / Bug Fixes
49
43
-### Code Examples
50
+- Change 1
51
+- Change 2
52
45
-Use `<CodeBlocks>` for side-by-side Python/TypeScript examples:
53
+### Backward Compatibility
54
47
-```markdown
48
-<CodeBlocks>
49
-```python title="Python SDK"
50
-# Python code
55
+Notes about backward compatibility.
56
```
57
53
-```typescript title="TypeScript SDK"
54
-// TypeScript code
55
-```
56
-</CodeBlocks>
58
+## Rules
59
+
60
+1. **Frontmatter required** - `title`, `description`, and `date` (YYYY-MM-DD format)
61
+2. **No `#` heading** - Title renders automatically from frontmatter
62
+3. **Use `###` for sections** - Content headings start at h3
63
+4. **No emojis** - No checkmarks, warning symbols, etc. in prose (okay in code comments)
64
+5. **TypeScript code blocks** - Add `// @noErrors` on first line to skip type checking
65
+
66
+## Change Types
67
+
68
+| Type | How to Format |
69
+|------|---------------|
70
+| Breaking Change | `<Callout type="warn">` + before/after code + migration guide |
71
+| New Feature | `### What's New` |
72
+| Improvement | `### Improvements` |
73
+| Bug Fix | `### Bug Fixes` or inline description |
74
+| Deprecation | `<Callout>` with timeline |
75
+
76
+## Code Examples
77
+
78
+For TypeScript code that shouldn't be type-checked:
79
+
80
+```typescript
81
+// @noErrors
82
+const result = await composio.tools.get(userId);
83
```
84
59
-## Examples
85
+For before/after comparisons, use labeled sections:
86
61
-- Bug fix: `01-21-26-initiate-active-status-filter.md`
62
-- Breaking change: `01-14-26-auth-config-patch-semantics.md`
63
-- New feature: `01-12-26-tool-router-improvements.md`
64
-- Simple change: `01-09-26.md`
87
+**Before:**
88
+```python
89
+old_code()
90
+```
91
+
92
+**After:**
93
+```python
94
+new_code()
95
+```
96
66
-## Instructions
67
-- Avoid using emojies in top level, it's okay within code samples only when necessary
97
+## Examples
98
99
+Reference these existing changelogs for style:
100
+- Bug fix: `01-21-26-initiate-active-status-filter.mdx`
101
+- Breaking change: `01-14-26-auth-config-patch-semantics.mdx`
102
+- New feature: `01-12-26-tool-router-improvements.mdx`
103
+- Simple change: `01-30-26-simplified-optional-schemas.mdx`
.github/workflows/py.check.yaml
+8
@@ -62,3 +62,11 @@ jobs:
62
run: |
63
cd python/
64
uv run nox -s chk
65
+
66
+ - name: Type inference tests
67
+ shell: bash
68
+ run: |
69
+ cd python/
70
+ uv run nox -s type_inference
71
+ env:
72
+ COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }}
docs/content/changelog/02-01-26-type-safe-get-tools-python.mdx
new
+134
@@ -0,0 +1,134 @@
1
+---
2
+title: "Type-Safe get_tools() for Python SDK"
3
+description: "The Python SDK now provides automatic type inference for tools.get() based on the provider"
4
+date: "2026-02-01"
5
+---
6
+
7
+The Python SDK's `Composio` class is now generic over the provider type. When you pass a provider to `Composio()`, the return type of `tools.get()` is automatically inferred based on that provider.
8
+
9
+### SDK Versions
10
+
11
+| SDK | Version |
12
+|-----|---------|
13
+| Python | v0.11.1+ |
14
+
15
+### What Changed
16
+
17
+**Before:** The return type of `tools.get()` was always untyped or required manual type annotations.
18
+
19
+**After:** Type checkers (mypy, Pyright) automatically infer the correct tool type from the provider you pass.
20
+
21
+**Before (untyped):**
22
+```python
23
+from composio import Composio
24
+from composio_anthropic import AnthropicProvider
25
+
26
+composio = Composio(provider=AnthropicProvider())
27
+tools = composio.tools.get(user_id="user_123", toolkits=["github"])
28
+# tools: Unknown type - no inference
29
+```
30
+
31
+**After (type-safe):**
32
+```python
33
+from composio import Composio
34
+from composio_anthropic import AnthropicProvider
35
+
36
+composio = Composio(provider=AnthropicProvider())
37
+tools = composio.tools.get(user_id="user_123", toolkits=["github"])
38
+# tools: list[ToolParam] - automatically inferred!
39
+```
40
+
41
+### Automatic Type Inference
42
+
43
+The `Composio` class now uses Python generics to provide type-safe return values:
44
+
45
+```python
46
+from composio import Composio
47
+from composio_openai import OpenAIProvider
48
+from composio_anthropic import AnthropicProvider
49
+
50
+# OpenAI provider -> list[ChatCompletionToolParam]
51
+composio_openai = Composio(provider=OpenAIProvider())
52
+openai_tools = composio_openai.tools.get(user_id="user", toolkits=["github"])
53
+
54
+# Anthropic provider -> list[ToolParam]
55
+composio_anthropic = Composio(provider=AnthropicProvider())
56
+anthropic_tools = composio_anthropic.tools.get(user_id="user", toolkits=["github"])
57
+
58
+# Default (no provider) -> list[ChatCompletionToolParam] (OpenAI)
59
+composio_default = Composio()
60
+default_tools = composio_default.tools.get(user_id="user", toolkits=["github"])
61
+```
62
+
63
+### Custom Provider Support
64
+
65
+Custom providers automatically get proper type inference without requiring any changes to the Composio SDK:
66
+
67
+```python
68
+import typing as t
69
+from typing import Sequence
70
+
71
+from composio import Composio
72
+from composio.client.types import Tool
73
+from composio.core.provider import NonAgenticProvider
74
+
75
+
76
+class MyCustomTool(t.TypedDict):
77
+ """Your custom tool format."""
78
+ name: str
79
+ description: str
80
+ parameters: dict
81
+
82
+
83
+MyCustomToolCollection = t.List[MyCustomTool]
84
+
85
+
86
+class MyCustomProvider(
87
+ NonAgenticProvider[MyCustomTool, MyCustomToolCollection],
88
+ name="my-custom"
89
+):
90
+ def wrap_tool(self, tool: Tool) -> MyCustomTool:
91
+ return MyCustomTool(
92
+ name=tool.slug,
93
+ description=tool.description or "",
94
+ parameters=tool.input_parameters or {},
95
+ )
96
+
97
+ def wrap_tools(self, tools: Sequence[Tool]) -> MyCustomToolCollection:
98
+ return [self.wrap_tool(tool) for tool in tools]
99
+
100
+
101
+# Type inference works automatically!
102
+composio = Composio(provider=MyCustomProvider())
103
+tools = composio.tools.get(user_id="user", toolkits=["github"])
104
+# tools: list[MyCustomTool] - correctly inferred
105
+```
106
+
107
+### Supported Providers
108
+
109
+Type inference is supported for all built-in providers:
110
+
111
+| Provider | Tool Type |
112
+|----------|-----------|
113
+| OpenAI | `ChatCompletionToolParam` |
114
+| OpenAI Responses | `dict[str, Any]` |
115
+| Anthropic | `ToolParam` |
116
+| Google (GenAI) | `FunctionDeclaration` |
117
+| Gemini | `FunctionDeclaration` |
118
+| Google ADK | `Tool` |
119
+| LangChain | `StructuredTool` |
120
+| LangGraph | `StructuredTool` |
121
+| LlamaIndex | `FunctionTool` |
122
+| CrewAI | `Tool` |
123
+| AutoGen | `FunctionTool` |
124
+| OpenAI Agents | `FunctionTool` |
125
+| Claude Agent SDK | `Tool` |
126
+
127
+### Backward Compatibility
128
+
129
+This change is fully backward compatible:
130
+
131
+- Existing code continues to work without modifications
132
+- Type inference is opt-in via static type checkers
133
+- No runtime behavior changes
134
+- No migration required
python/Makefile
+3
@@ -57,6 +57,9 @@ snt:
57
tst:
58
@nox -s tst
59
60
+type_inference:
61
+ @nox -s type_inference
62
+
63
bump: clean-build
64
@uv run python scripts/bump.py
65
python/composio/core/models/tool_router.py
+47
-19
@@ -18,7 +18,8 @@ import typing_extensions as te
18
from composio.client import HttpClient
19
from composio.core.models.base import Resource
20
from composio.core.models.connected_accounts import ConnectionRequest
21
-from composio.core.provider import TProvider
21
+from composio.core.provider import TTool, TToolCollection
22
+from composio.core.provider.base import BaseProvider
23
24
if t.TYPE_CHECKING:
25
from composio.core.models._modifiers import Modifiers
@@ -33,10 +34,21 @@ ToolkitsFn = t.Callable[
34
]
35
36
36
-class ToolsFn(t.Protocol):
37
- """Protocol for the tools function that returns provider-wrapped tools."""
37
+# Local type variable for ToolsFn protocol (covariant for return type)
38
+_TToolCollectionReturn = t.TypeVar("_TToolCollectionReturn", covariant=True)
39
39
- def __call__(self, modifiers: t.Optional["Modifiers"] = None) -> t.Any:
40
+
41
+class ToolsFn(t.Protocol[_TToolCollectionReturn]):
42
+ """Protocol for the tools function that returns provider-wrapped tools.
43
+
44
+ The return type is generic to support provider-specific tool collections.
45
+ For example, AnthropicProvider returns list[ToolParam], OpenAIProvider
46
+ returns list[ChatCompletionToolParam], etc.
47
+ """
48
+
49
+ def __call__(
50
+ self, modifiers: t.Optional["Modifiers"] = None
51
+ ) -> _TToolCollectionReturn:
52
"""Get provider-wrapped tools for execution with your AI framework."""
53
...
54
@@ -309,10 +321,14 @@ class ToolRouterSessionExperimental:
321
322
323
@dataclass
312
-class ToolRouterSession(t.Generic[TProvider]):
324
+class ToolRouterSession(t.Generic[TTool, TToolCollection]):
325
"""
326
Tool router session containing session information and helper functions.
327
328
+ Generic Parameters:
329
+ TTool: The individual tool type returned by the provider.
330
+ TToolCollection: The collection type returned by tools().
331
+
332
Attributes:
333
session_id: Unique session identifier
334
mcp: MCP server configuration
@@ -320,17 +336,21 @@ class ToolRouterSession(t.Generic[TProvider]):
336
authorize: Function to authorize a toolkit
337
toolkits: Function to get toolkit connection states
338
experimental: Optional experimental features data from the session response
339
+
340
+ Note:
341
+ The `tools` function returns a provider-specific tool collection.
342
+ The return type is inferred from the provider's generic parameters.
343
"""
344
345
session_id: str
346
mcp: ToolRouterMCPServerConfig
327
- tools: ToolsFn
347
+ tools: "ToolsFn[TToolCollection]"
348
authorize: AuthorizeFn
349
toolkits: ToolkitsFn
350
experimental: t.Optional[ToolRouterSessionExperimental] = None
351
352
333
-class ToolRouter(Resource, t.Generic[TProvider]):
353
+class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
354
"""
355
ToolRouter class for managing tool routing sessions.
356
@@ -361,7 +381,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
381
def __init__(
382
self,
383
client: HttpClient,
364
- provider: t.Optional[TProvider] = None,
384
+ provider: t.Optional["BaseProvider[TTool, TToolCollection]"] = None,
385
auto_upload_download_files: bool = True,
386
):
387
"""
@@ -602,7 +622,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
622
def _create_tools_fn(
623
self,
624
session_id: str,
605
- ) -> ToolsFn:
625
+ ) -> ToolsFn[TToolCollection]:
626
"""
627
Create a tools function that wraps tools for the provider.
628
@@ -625,7 +645,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
645
auto_upload_download_files=self._auto_upload_download_files,
646
)
647
628
- def tools_fn(modifiers: t.Optional[Modifiers] = None) -> t.Any:
648
+ def tools_fn(modifiers: t.Optional[Modifiers] = None) -> TToolCollection:
649
"""
650
Get provider-wrapped tools for execution with your AI framework.
651
@@ -702,15 +722,23 @@ class ToolRouter(Resource, t.Generic[TProvider]):
722
723
# Wrap tools with provider
724
if issubclass(type(self._provider), NonAgenticProvider):
705
- return t.cast(NonAgenticProvider, self._provider).wrap_tools(
706
- tools=router_tools
725
+ return t.cast(
726
+ TToolCollection,
727
+ t.cast(
728
+ NonAgenticProvider[TTool, TToolCollection], self._provider
729
+ ).wrap_tools(tools=router_tools),
730
)
731
709
- return t.cast(AgenticProvider, self._provider).wrap_tools(
710
- tools=router_tools,
711
- execute_tool=tools_model._wrap_execute_tool_for_tool_router(
712
- session_id=session_id,
713
- modifiers=modifiers,
732
+ return t.cast(
733
+ TToolCollection,
734
+ t.cast(
735
+ AgenticProvider[TTool, TToolCollection], self._provider
736
+ ).wrap_tools(
737
+ tools=router_tools,
738
+ execute_tool=tools_model._wrap_execute_tool_for_tool_router(
739
+ session_id=session_id,
740
+ modifiers=modifiers,
741
+ ),
742
),
743
)
744
@@ -775,7 +803,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
803
connected_accounts: t.Optional[t.Dict[str, str]] = None,
804
workbench: t.Optional[ToolRouterWorkbenchConfig] = None,
805
experimental: t.Optional[ToolRouterExperimentalConfig] = None,
778
- ) -> ToolRouterSession[TProvider]:
806
+ ) -> ToolRouterSession[TTool, TToolCollection]:
807
"""
808
Create a new tool router session for a user.
809
@@ -1071,7 +1099,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
1099
experimental=experimental_response,
1100
)
1101
1074
- def use(self, session_id: str) -> ToolRouterSession[TProvider]:
1102
+ def use(self, session_id: str) -> ToolRouterSession[TTool, TToolCollection]:
1103
"""
1104
Retrieve and use an existing tool router session.
1105
python/composio/core/models/tools.py
+47
-74
@@ -16,18 +16,14 @@ from composio.client.types import (
16
from composio.core.models._files import FileHelper
17
from composio.core.models.base import Resource
18
from composio.core.models.custom_tools import CustomTools
19
-from composio.core.provider import (
20
- TProvider,
21
-)
19
+from composio.core.provider import TTool, TToolCollection
20
from composio.core.provider.agentic import AgenticProvider, AgenticProviderExecuteFn
23
-from composio.core.provider.none_agentic import (
24
- NonAgenticProvider,
25
-)
21
+from composio.core.provider.base import BaseProvider, ExecuteToolFn
22
+from composio.core.provider.none_agentic import NonAgenticProvider
23
from composio.core.types import ToolkitVersionParam
24
from composio.exceptions import InvalidParams, NotFoundError, ToolVersionRequiredError
25
from composio.utils.pydantic import none_to_omit
26
from composio.utils.toolkit_version import get_toolkit_version
30
-from composio.core.provider.base import ExecuteToolFn
27
28
from ._modifiers import (
29
Modifiers,
@@ -45,20 +41,27 @@ class ToolExecutionResponse(te.TypedDict):
41
successful: bool
42
43
48
-class Tools(Resource, t.Generic[TProvider]):
44
+class Tools(Resource, t.Generic[TTool, TToolCollection]):
45
"""
46
Tools class definition
47
48
This class is used to manage tools in the Composio SDK.
49
It provides methods to list, get, and execute tools.
50
+
51
+ Generic Parameters:
52
+ TTool: The individual tool type returned by the provider (e.g., ChatCompletionToolParam for OpenAI).
53
+ TToolCollection: The collection type returned by get() (e.g., list[ChatCompletionToolParam]).
54
+
55
+ The return type of get() is automatically inferred from the provider's generic parameters.
56
+ This works for both built-in providers (OpenAI, Anthropic, etc.) and custom providers.
57
"""
58
56
- provider: TProvider
59
+ provider: BaseProvider[TTool, TToolCollection]
60
61
def __init__(
62
self,
63
client: HttpClient,
61
- provider: TProvider,
64
+ provider: BaseProvider[TTool, TToolCollection],
65
file_download_dir: t.Optional[str] = None,
66
toolkit_versions: t.Optional[ToolkitVersionParam] = None,
67
auto_upload_download_files: bool = True,
@@ -238,7 +241,7 @@ class Tools(Resource, t.Generic[TProvider]):
241
scopes: t.Optional[t.List[str]] = None,
242
modifiers: t.Optional[Modifiers] = None,
243
limit: t.Optional[int] = None,
241
- ):
244
+ ) -> TToolCollection:
245
"""Get a list of tools based on the provided filters."""
246
tools_list = self.get_raw_composio_tools(
247
tools=tools,
@@ -280,72 +283,24 @@ class Tools(Resource, t.Generic[TProvider]):
283
)
284
285
if issubclass(type(self.provider), NonAgenticProvider):
283
- return t.cast(NonAgenticProvider, self.provider).wrap_tools(
284
- tools=tools_list
286
+ return t.cast(
287
+ TToolCollection,
288
+ t.cast(
289
+ NonAgenticProvider[TTool, TToolCollection], self.provider
290
+ ).wrap_tools(tools=tools_list),
291
)
292
287
- return t.cast(AgenticProvider, self.provider).wrap_tools(
288
- tools=tools_list,
289
- execute_tool=self._wrap_execute_tool(
290
- user_id=user_id,
291
- modifiers=modifiers,
293
+ return t.cast(
294
+ TToolCollection,
295
+ t.cast(AgenticProvider[TTool, TToolCollection], self.provider).wrap_tools(
296
+ tools=tools_list,
297
+ execute_tool=self._wrap_execute_tool(
298
+ user_id=user_id,
299
+ modifiers=modifiers,
300
+ ),
301
),
302
)
303
295
- @t.overload
296
- def get(
297
- self,
298
- user_id: str,
299
- *,
300
- slug: str,
301
- modifiers: t.Optional[Modifiers] = None,
302
- ):
303
- """Get tool by slug"""
304
-
305
- @t.overload
306
- def get(
307
- self,
308
- user_id: str,
309
- *,
310
- tools: list[str],
311
- modifiers: t.Optional[Modifiers] = None,
312
- ):
313
- """Get tools by tool slugs"""
314
-
315
- @t.overload
316
- def get(
317
- self,
318
- user_id: str,
319
- *,
320
- toolkits: list[str],
321
- scopes: t.Optional[t.List[str]] = None,
322
- limit: t.Optional[int] = None,
323
- modifiers: t.Optional[Modifiers] = None,
324
- ):
325
- """Get tools by toolkit slugs (Only important tools are returned)"""
326
-
327
- @t.overload
328
- def get(
329
- self,
330
- user_id: str,
331
- *,
332
- search: str,
333
- modifiers: t.Optional[Modifiers] = None,
334
- ):
335
- """Search tool by search term"""
336
-
337
- @t.overload
338
- def get(
339
- self,
340
- user_id: str,
341
- *,
342
- toolkits: list[str],
343
- search: t.Optional[str] = None,
344
- limit: t.Optional[int] = None,
345
- modifiers: t.Optional[Modifiers] = None,
346
- ):
347
- """Get tool by search term and/or toolkit slugs and search term"""
348
-
304
def get(
305
self,
306
user_id: str,
@@ -357,8 +312,26 @@ class Tools(Resource, t.Generic[TProvider]):
312
scopes: t.Optional[t.List[str]] = None,
313
modifiers: t.Optional[Modifiers] = None,
314
limit: t.Optional[int] = None,
360
- ):
361
- """Get a tool or list of tools based on the provided arguments."""
315
+ ) -> TToolCollection:
316
+ """
317
+ Get a tool or list of tools based on the provided arguments.
318
+
319
+ The return type is automatically inferred based on the provider's generic parameters.
320
+ For example:
321
+ - OpenAIProvider -> list[ChatCompletionToolParam]
322
+ - AnthropicProvider -> list[ToolParam]
323
+ - CustomProvider[MyTool, list[MyTool]] -> list[MyTool]
324
+
325
+ :param user_id: The user ID to get tools for.
326
+ :param slug: Get a single tool by slug.
327
+ :param tools: Get tools by a list of tool slugs.
328
+ :param search: Search tools by search term.
329
+ :param toolkits: Get tools from specific toolkits.
330
+ :param scopes: Filter by scopes.
331
+ :param modifiers: Optional modifiers to apply.
332
+ :param limit: Limit the number of tools returned.
333
+ :return: Provider-specific tool collection (TToolCollection).
334
+ """
335
if slug is not None:
336
return self._get(user_id=user_id, tools=[slug], modifiers=modifiers)
337
return self._get(
python/composio/core/provider/__init__.py
+4
-4
@@ -1,12 +1,12 @@
1
-import typing as t
1
+from __future__ import annotations
2
3
from .agentic import AgenticProvider, AgenticProviderExecuteFn
4
+from .base import TTool, TToolCollection
5
from .none_agentic import NonAgenticProvider
6
6
-TProvider = t.TypeVar("TProvider", bound=AgenticProvider | NonAgenticProvider)
7
-
7
__all__ = [
9
- "TProvider",
8
+ "TTool",
9
+ "TToolCollection",
10
"AgenticProvider",
11
"NonAgenticProvider",
12
"AgenticProviderExecuteFn",
python/composio/core/provider/agentic.py
+3
-4
@@ -1,3 +1,5 @@
1
+from __future__ import annotations
2
+
3
import typing as t
4
5
from composio.client.types import Tool
@@ -20,15 +22,12 @@ class AgenticProviderExecuteFn(t.Protocol):
22
...
23
24
23
-class AgenticProvider(BaseProvider, t.Generic[TTool, TToolCollection]):
25
+class AgenticProvider(BaseProvider[TTool, TToolCollection]):
26
"""
27
Base class for all agentic providers. This class is not meant to be used
28
directly but rather to be extended by concrete provider implementations.
29
"""
30
29
- tool_type: t.Type[TTool]
30
- tool_collection_type: t.Type[TToolCollection]
31
-
31
def __init_subclass__(cls, name: str) -> None:
32
cls.name = name
33
python/composio/core/provider/base.py
+3
-3
@@ -13,8 +13,8 @@ import typing_extensions as te
13
if t.TYPE_CHECKING:
14
from composio.core.models.tools import Modifiers, ToolExecutionResponse
15
16
-TTool = t.TypeVar("TTool", covariant=True)
17
-TToolCollection = t.TypeVar("TToolCollection", covariant=True)
16
+TTool = t.TypeVar("TTool")
17
+TToolCollection = t.TypeVar("TToolCollection")
18
19
20
class ExecuteToolFn(t.Protocol):
@@ -69,5 +69,5 @@ class BaseProvider(t.Generic[TTool, TToolCollection]):
69
"skip_defaults", self.__schema_skip_defaults__
70
)
71
72
- def set_execute_tool_fn(self, execute_tool_fn: ExecuteToolFn):
72
+ def set_execute_tool_fn(self, execute_tool_fn: ExecuteToolFn) -> None:
73
self.execute_tool = execute_tool_fn
python/composio/core/provider/none_agentic.py
+1
-1
@@ -6,7 +6,7 @@ from composio.client.types import Tool
6
from composio.core.provider.base import BaseProvider, TTool, TToolCollection
7
8
9
-class NonAgenticProvider(BaseProvider, t.Generic[TTool, TToolCollection]):
9
+class NonAgenticProvider(BaseProvider[TTool, TToolCollection]):
10
"""
11
Base class for all non-agentic providers, such as `openai` This class is not
12
meant to be used directly, but rather to be extended by concrete implementations
python/composio/sdk.py
+56
-23
@@ -17,8 +17,13 @@ from composio.core.models import (
17
)
18
from composio.core.models.base import allow_tracking
19
from composio.core.models.mcp import MCP
20
-from composio.core.provider import TProvider
21
-from composio.core.provider._openai import OpenAIProvider
20
+from composio.core.provider import TTool, TToolCollection
21
+from composio.core.provider._openai import (
22
+ OpenAIProvider,
23
+ OpenAITool,
24
+ OpenAIToolCollection,
25
+)
26
+from composio.core.provider.base import BaseProvider
27
from composio.core.types import ToolkitVersionParam
28
from composio.utils.logging import WithLogger
29
from composio.utils.toolkit_version import get_toolkit_versions
@@ -38,36 +43,57 @@ class SDKConfig(te.TypedDict):
43
auto_upload_download_files: te.NotRequired[bool]
44
45
41
-# class ExperimentalNamespace:
42
-# """Namespace for experimental Composio features."""
46
+class Composio(t.Generic[TTool, TToolCollection], WithLogger):
47
+ """
48
+ Composio SDK for Python.
49
44
-# def __init__(self, tool_router: ToolRouter):
45
-# """
46
-# Initialize experimental namespace.
50
+ Generic parameters:
51
+ TTool: The individual tool type returned by the provider (e.g., ChatCompletionToolParam for OpenAI).
52
+ TToolCollection: The collection type returned by get_tools (e.g., list[ChatCompletionToolParam]).
53
48
-# :param tool_router: Experimental ToolRouter instance
49
-# """
50
-# self.tool_router = tool_router
54
+ The generic types are automatically inferred from the provider passed to __init__.
55
+ When no provider is passed, defaults to OpenAI types.
56
57
+ Examples:
58
+ # Implicit type inference - recommended
59
+ composio = Composio(provider=OpenAIProvider()) # Composio[OpenAITool, list[OpenAITool]]
60
+ composio = Composio(provider=AnthropicProvider()) # Composio[ToolParam, list[ToolParam]]
61
+ composio = Composio() # Composio[OpenAITool, list[OpenAITool]] (default)
62
53
-class Composio(t.Generic[TProvider], WithLogger):
54
- """
55
- Composio SDK for Python.
63
+ # Custom provider - types are inferred automatically
64
+ composio = Composio(provider=MyCustomProvider()) # Composio[MyTool, list[MyTool]]
65
"""
66
58
- tools: Tools[TProvider]
59
- tool_router: ToolRouter[TProvider]
60
- # experimental: ExperimentalNamespace
67
+ tools: "Tools[TTool, TToolCollection]"
68
+ tool_router: "ToolRouter[TTool, TToolCollection]"
69
+
70
+ @t.overload
71
+ def __init__(
72
+ self: "Composio[OpenAITool, OpenAIToolCollection]",
73
+ provider: None = None,
74
+ **kwargs: te.Unpack[SDKConfig],
75
+ ) -> None:
76
+ """Initialize with default OpenAI provider."""
77
+ ...
78
+
79
+ @t.overload
80
+ def __init__(
81
+ self,
82
+ provider: BaseProvider[TTool, TToolCollection],
83
+ **kwargs: te.Unpack[SDKConfig],
84
+ ) -> None:
85
+ """Initialize with an explicit provider. Types are inferred from the provider."""
86
+ ...
87
88
def __init__(
89
self,
64
- provider: TProvider = _DEFAULT_PROVIDER, # type: ignore
90
+ provider: t.Optional[BaseProvider[t.Any, t.Any]] = None,
91
**kwargs: te.Unpack[SDKConfig],
92
) -> None:
93
"""
94
Initialize the Composio SDK.
95
70
- :param provider: The provider to use for the SDK.
96
+ :param provider: The provider to use for the SDK. Defaults to OpenAIProvider.
97
:param environment: The environment to use for the SDK.
98
:param api_key: The API key to use for the SDK.
99
:param base_url: The base URL to use for the SDK.
@@ -84,22 +110,29 @@ class Composio(t.Generic[TProvider], WithLogger):
110
if not api_key:
111
raise exceptions.ApiKeyNotProvidedError()
112
113
+ # Use default provider if none provided
114
+ # Cast to BaseProvider[TTool, TToolCollection] for type consistency
115
+ actual_provider: BaseProvider[TTool, TToolCollection] = t.cast(
116
+ BaseProvider[TTool, TToolCollection],
117
+ provider if provider is not None else _DEFAULT_PROVIDER,
118
+ )
119
+
120
# Process toolkit versions with environment variable support
121
toolkit_versions = get_toolkit_versions(kwargs.get("toolkit_versions"))
122
123
allow_tracking.set(kwargs.get("allow_tracking", True))
124
self._client = HttpClient(
125
environment=kwargs.get("environment", "production"),
93
- provider=provider.name,
126
+ provider=actual_provider.name,
127
api_key=api_key,
128
base_url=kwargs.get("base_url"),
129
timeout=kwargs.get("timeout"),
130
max_retries=kwargs.get("max_retries", DEFAULT_MAX_RETRIES),
131
)
99
- self.provider = provider
132
+ self.provider = actual_provider
133
self.tools = Tools(
134
client=self._client,
102
- provider=self.provider,
135
+ provider=actual_provider,
136
file_download_dir=kwargs.get("file_download_dir"),
137
toolkit_versions=toolkit_versions,
138
auto_upload_download_files=kwargs.get("auto_upload_download_files", True),
@@ -114,12 +147,12 @@ class Composio(t.Generic[TProvider], WithLogger):
147
# initialize tool router methods
148
self.tool_router = ToolRouter(
149
client=self._client,
117
- provider=self.provider,
150
+ provider=actual_provider,
151
auto_upload_download_files=kwargs.get("auto_upload_download_files", True),
152
)
153
self.create = self.tool_router.create
154
self.use = self.tool_router.use
155
156
@property
124
- def client(self):
157
+ def client(self) -> HttpClient:
158
return self._client
python/config/mypy.ini
+44
-1
@@ -1,5 +1,8 @@
1
[mypy]
2
-exclude = ^(apps/composio/|utils/|\.nox/|.*/setup\.py|.*/build/|examples/|.*demo.*)
2
+; Exclude directories and files from type checking
3
+; - External provider type inference tests require those provider packages to be installed
4
+; The core test_type_inference.py and test_type_inference_custom_provider.py can be checked
5
+exclude = ^(apps/composio/|utils/|\.nox/|.*/setup\.py|.*/build/|examples/|.*demo.*|tests/test_type_inference_(?!custom_provider).*)
6
strict_optional=True
7
disable_error_code=var-annotated
8
@@ -33,4 +36,44 @@ ignore_missing_imports=true
36
ignore_missing_imports=true
37
38
[mypy-claude_agent_sdk.*]
39
+ignore_missing_imports=true
40
+
41
+[mypy-mcp.*]
42
+ignore_missing_imports=true
43
+
44
+[mypy-llama_index.*]
45
+ignore_missing_imports=true
46
+
47
+[mypy-agents.*]
48
+ignore_missing_imports=true
49
+
50
+; Composio provider packages (may not be installed)
51
+[mypy-composio_anthropic.*]
52
+ignore_missing_imports=true
53
+
54
+[mypy-composio_langchain.*]
55
+ignore_missing_imports=true
56
+
57
+[mypy-composio_langgraph.*]
58
+ignore_missing_imports=true
59
+
60
+[mypy-composio_llamaindex.*]
61
+ignore_missing_imports=true
62
+
63
+[mypy-composio_openai_agents.*]
64
+ignore_missing_imports=true
65
+
66
+[mypy-composio_crewai.*]
67
+ignore_missing_imports=true
68
+
69
+[mypy-composio_autogen.*]
70
+ignore_missing_imports=true
71
+
72
+[mypy-composio_google.*]
73
+ignore_missing_imports=true
74
+
75
+[mypy-composio_google_adk.*]
76
+ignore_missing_imports=true
77
+
78
+[mypy-composio_claude_agent_sdk.*]
79
ignore_missing_imports=true
\ No newline at end of file
python/noxfile.py
+50
@@ -66,3 +66,53 @@ def fix(session: Session):
66
"""Fix linter issues"""
67
session.install("ruff")
68
session.run(*ruff, "check", "--fix", *modules_for_ruff)
69
+
70
+
71
+@nox.session
72
+def type_inference(session: Session):
73
+ """Type check provider return type inference tests.
74
+
75
+ This session verifies that mypy correctly infers provider-specific return
76
+ types from `Composio.tools.get()` when using @overload signatures.
77
+
78
+ Unlike the `chk` session, this installs all provider packages so mypy can
79
+ resolve the provider types and verify the type inference works correctly.
80
+ """
81
+ # Install core SDK and mypy
82
+ session.install(".", "mypy==1.13.0", *type_stubs)
83
+
84
+ # Install all provider packages for type resolution
85
+ session.install(
86
+ "./providers/anthropic",
87
+ "./providers/autogen",
88
+ "./providers/claude_agent_sdk",
89
+ "./providers/crewai",
90
+ "./providers/gemini",
91
+ "./providers/google",
92
+ "./providers/google_adk",
93
+ "./providers/langchain",
94
+ "./providers/langgraph",
95
+ "./providers/llamaindex",
96
+ "./providers/openai",
97
+ "./providers/openai_agents",
98
+ )
99
+
100
+ # Run mypy on type inference test files
101
+ # Note: explicitly listed files are checked even if they match the exclude pattern in `mypy.ini`
102
+ session.run(
103
+ "mypy",
104
+ "--config-file",
105
+ "config/mypy.ini",
106
+ "tests/test_type_inference.py",
107
+ "tests/test_type_inference_anthropic.py",
108
+ "tests/test_type_inference_autogen.py",
109
+ "tests/test_type_inference_claude_agent_sdk.py",
110
+ "tests/test_type_inference_crewai.py",
111
+ "tests/test_type_inference_gemini.py",
112
+ "tests/test_type_inference_google.py",
113
+ "tests/test_type_inference_google_adk.py",
114
+ "tests/test_type_inference_langchain.py",
115
+ "tests/test_type_inference_langgraph.py",
116
+ "tests/test_type_inference_llamaindex.py",
117
+ "tests/test_type_inference_openai_agents.py",
118
+ )
python/providers/anthropic/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-anthropic"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your Anthropic LLMs."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
python/providers/anthropic/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_anthropic",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Anthropic LLMs.",
python/providers/autogen/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-autogen"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your autogen agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/autogen/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_autogen",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Autogen agent.",
python/providers/claude_agent_sdk/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-claude-agent-sdk"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with Claude Code Agents SDK."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
python/providers/claude_agent_sdk/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9
setup(
10
name="composio_claude_agent_sdk",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools for Claude Agent SDK",
python/providers/crewai/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-crewai"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your CrewAI agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/crewai/setup.py
+1
-1
@@ -6,7 +6,7 @@ from setuptools import setup
6
7
setup(
8
name="composio_crewai",
9
- version="0.11.0",
9
+ version="0.11.1",
10
author="Composio",
11
author_email="tech@composio.dev",
12
description="Use Composio to get an array of tools with your CrewAI agent.",
python/providers/gemini/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-gemini"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your Gemini agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/gemini/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_gemini",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Gemini agent.",
python/providers/google/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-google"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/google/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_google",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/google_adk/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-google-adk"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/google_adk/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_google_adk",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/langchain/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-langchain"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your Langchain agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/langchain/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_langchain",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Langchain agent.",
python/providers/langgraph/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-langgraph"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get array of tools with LangGraph Agent Workflows."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/langgraph/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_langgraph",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools with LangGraph Agent Workflows",
python/providers/llamaindex/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-llamaindex"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get array of tools with LlamaIndex Agent Workflows."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/llamaindex/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_llamaindex",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools with LlamaIndex Agent Workflows",
python/providers/openai/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-openai"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get an array of tools with your OpenAI Function Call."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/openai/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_openai",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your OpenAI Function Call.",
python/providers/openai_agents/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-openai-agents"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "Use Composio to get array of strongly typed tools for OpenAI Agents"
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/openai_agents/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9
setup(
10
name="composio_openai_agents",
11
- version="0.11.0",
11
+ version="0.11.1",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of strongly typed tools for OpenAI Agents",
python/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio"
3
-version = "0.11.0"
3
+version = "0.11.1"
4
description = "SDK for integrating Composio with your applications."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
python/pytest.ini
+1
-1
@@ -3,7 +3,7 @@ testpaths = tests
3
python_files = test_*.py
4
python_classes = Test*
5
python_functions = test_*
6
-addopts = -v --tb=short
6
+addopts = -v --tb=short --ignore-glob=tests/test_type_inference*.py
7
markers =
8
slow: marks tests as slow (deselect with '-m "not slow"')
9
integration: marks tests as integration tests
python/tests/test_type_inference.py
new
+116
@@ -0,0 +1,116 @@
1
+"""
2
+Type inference verification tests for the Composio SDK.
3
+
4
+This file verifies that type checkers (mypy) correctly infer
5
+provider-specific return types from `Composio.tools.get()`.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - openai (for type stubs)
15
+"""
16
+
17
+from typing import TYPE_CHECKING, Any
18
+
19
+from composio import Composio
20
+from composio.core.provider._openai import (
21
+ OpenAIProvider,
22
+ OpenAITool,
23
+ OpenAIToolCollection,
24
+)
25
+from composio.core.provider._openai_responses import (
26
+ OpenAIResponsesProvider,
27
+ ResponsesTool,
28
+ ResponsesToolCollection,
29
+)
30
+
31
+if TYPE_CHECKING:
32
+ from typing_extensions import assert_type
33
+
34
+ from openai.types.chat.chat_completion_tool_param import ChatCompletionToolParam
35
+
36
+
37
+def test_openai_provider_explicit() -> None:
38
+ """Verify OpenAI provider with explicit type returns list[ChatCompletionToolParam]."""
39
+ composio: Composio[OpenAITool, OpenAIToolCollection] = Composio(
40
+ provider=OpenAIProvider()
41
+ )
42
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
43
+
44
+ # Type checker should infer: list[ChatCompletionToolParam]
45
+ if TYPE_CHECKING:
46
+ assert_type(tools, list[ChatCompletionToolParam])
47
+
48
+
49
+def test_openai_provider_inferred() -> None:
50
+ """Verify OpenAI provider with inferred type returns list[ChatCompletionToolParam]."""
51
+ composio = Composio(provider=OpenAIProvider())
52
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
53
+
54
+ # Type checker should infer: list[ChatCompletionToolParam]
55
+ if TYPE_CHECKING:
56
+ assert_type(tools, list[ChatCompletionToolParam])
57
+
58
+
59
+def test_default_provider() -> None:
60
+ """Verify default provider (OpenAI) returns list[ChatCompletionToolParam]."""
61
+ # Default provider is OpenAIProvider
62
+ composio = Composio()
63
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
64
+
65
+ # Type checker should infer: list[ChatCompletionToolParam]
66
+ if TYPE_CHECKING:
67
+ assert_type(tools, list[ChatCompletionToolParam])
68
+
69
+
70
+def test_openai_provider_slug_parameter() -> None:
71
+ """Verify slug parameter returns same type."""
72
+ composio = Composio(provider=OpenAIProvider())
73
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
74
+
75
+ if TYPE_CHECKING:
76
+ assert_type(tools, list[ChatCompletionToolParam])
77
+
78
+
79
+def test_openai_provider_tools_parameter() -> None:
80
+ """Verify tools parameter returns same type."""
81
+ composio = Composio(provider=OpenAIProvider())
82
+ tools = composio.tools.get(user_id="test", tools=["GITHUB_CREATE_REPO"])
83
+
84
+ if TYPE_CHECKING:
85
+ assert_type(tools, list[ChatCompletionToolParam])
86
+
87
+
88
+def test_openai_provider_search_parameter() -> None:
89
+ """Verify search parameter returns same type."""
90
+ composio = Composio(provider=OpenAIProvider())
91
+ tools = composio.tools.get(user_id="test", search="github")
92
+
93
+ if TYPE_CHECKING:
94
+ assert_type(tools, list[ChatCompletionToolParam])
95
+
96
+
97
+def test_openai_responses_provider() -> None:
98
+ """Verify OpenAI Responses provider returns list[dict]."""
99
+ if TYPE_CHECKING:
100
+ composio = Composio(provider=OpenAIResponsesProvider())
101
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
102
+
103
+ # Type checker should infer: list[Dict[str, Any]]
104
+ # Note: ResponsesTool is typed as Dict[str, Any]
105
+ assert_type(tools, list[dict[str, Any]])
106
+
107
+
108
+def test_openai_responses_provider_explicit() -> None:
109
+ """Verify OpenAI Responses provider with explicit generic types."""
110
+ if TYPE_CHECKING:
111
+ composio: Composio[ResponsesTool, ResponsesToolCollection] = Composio(
112
+ provider=OpenAIResponsesProvider()
113
+ )
114
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
115
+
116
+ assert_type(tools, list[dict[str, Any]])
python/tests/test_type_inference_anthropic.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for Anthropic provider.
3
+
4
+This file verifies that type checkers correctly infer `list[ToolParam]`
5
+when using the Anthropic provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_anthropic.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-anthropic
15
+ - anthropic
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from anthropic.types.tool_param import ToolParam
26
+
27
+ from composio_anthropic import AnthropicProvider
28
+
29
+
30
+def test_anthropic_provider_toolkits() -> None:
31
+ """Verify Anthropic provider returns list[ToolParam] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[ToolParam, list[ToolParam]] = Composio(
34
+ provider=AnthropicProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[ToolParam]
39
+ assert_type(tools, list[ToolParam])
40
+
41
+
42
+def test_anthropic_provider_slug() -> None:
43
+ """Verify Anthropic provider returns list[ToolParam] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[ToolParam, list[ToolParam]] = Composio(
46
+ provider=AnthropicProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[ToolParam])
51
+
52
+
53
+def test_anthropic_provider_tools_list() -> None:
54
+ """Verify Anthropic provider returns list[ToolParam] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[ToolParam, list[ToolParam]] = Composio(
57
+ provider=AnthropicProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[ToolParam])
65
+
66
+
67
+def test_anthropic_provider_search() -> None:
68
+ """Verify Anthropic provider returns list[ToolParam] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[ToolParam, list[ToolParam]] = Composio(
71
+ provider=AnthropicProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[ToolParam])
76
+
77
+
78
+def test_anthropic_provider_inferred() -> None:
79
+ """Verify Anthropic provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=AnthropicProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[ToolParam] from provider type
85
+ assert_type(tools, list[ToolParam])
python/tests/test_type_inference_autogen.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for Autogen provider.
3
+
4
+This file verifies that type checkers correctly infer `list[FunctionTool]`
5
+when using the Autogen provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_autogen.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-autogen
15
+ - autogen-core
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from autogen_core.tools import FunctionTool
26
+
27
+ from composio_autogen import AutogenProvider
28
+
29
+
30
+def test_autogen_provider_toolkits() -> None:
31
+ """Verify Autogen provider returns list[FunctionTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
34
+ provider=AutogenProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[FunctionTool]
39
+ assert_type(tools, list[FunctionTool])
40
+
41
+
42
+def test_autogen_provider_slug() -> None:
43
+ """Verify Autogen provider returns list[FunctionTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
46
+ provider=AutogenProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[FunctionTool])
51
+
52
+
53
+def test_autogen_provider_tools_list() -> None:
54
+ """Verify Autogen provider returns list[FunctionTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
57
+ provider=AutogenProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[FunctionTool])
65
+
66
+
67
+def test_autogen_provider_search() -> None:
68
+ """Verify Autogen provider returns list[FunctionTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
71
+ provider=AutogenProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[FunctionTool])
76
+
77
+
78
+def test_autogen_provider_inferred() -> None:
79
+ """Verify Autogen provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=AutogenProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[FunctionTool] from provider type
85
+ assert_type(tools, list[FunctionTool])
python/tests/test_type_inference_claude_agent_sdk.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for Claude Agent SDK provider.
3
+
4
+This file verifies that type checkers correctly infer `list[SdkMcpTool]`
5
+when using the Claude Agent SDK provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_claude_agent_sdk.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-claude-agent-sdk
15
+ - claude-agent-sdk
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from claude_agent_sdk import SdkMcpTool
26
+
27
+ from composio_claude_agent_sdk import ClaudeAgentSDKProvider
28
+
29
+
30
+def test_claude_agent_sdk_provider_toolkits() -> None:
31
+ """Verify Claude Agent SDK provider returns list[SdkMcpTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[SdkMcpTool, list[SdkMcpTool]] = Composio(
34
+ provider=ClaudeAgentSDKProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[SdkMcpTool]
39
+ assert_type(tools, list[SdkMcpTool])
40
+
41
+
42
+def test_claude_agent_sdk_provider_slug() -> None:
43
+ """Verify Claude Agent SDK provider returns list[SdkMcpTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[SdkMcpTool, list[SdkMcpTool]] = Composio(
46
+ provider=ClaudeAgentSDKProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[SdkMcpTool])
51
+
52
+
53
+def test_claude_agent_sdk_provider_tools_list() -> None:
54
+ """Verify Claude Agent SDK provider returns list[SdkMcpTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[SdkMcpTool, list[SdkMcpTool]] = Composio(
57
+ provider=ClaudeAgentSDKProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[SdkMcpTool])
65
+
66
+
67
+def test_claude_agent_sdk_provider_search() -> None:
68
+ """Verify Claude Agent SDK provider returns list[SdkMcpTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[SdkMcpTool, list[SdkMcpTool]] = Composio(
71
+ provider=ClaudeAgentSDKProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[SdkMcpTool])
76
+
77
+
78
+def test_claude_agent_sdk_provider_inferred() -> None:
79
+ """Verify Claude Agent SDK provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=ClaudeAgentSDKProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[SdkMcpTool] from provider type
85
+ assert_type(tools, list[SdkMcpTool])
python/tests/test_type_inference_crewai.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for CrewAI provider.
3
+
4
+This file verifies that type checkers correctly infer `list[BaseTool]`
5
+when using the CrewAI provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_crewai.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-crewai
15
+ - crewai
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from crewai.tools import BaseTool
26
+
27
+ from composio_crewai import CrewAIProvider
28
+
29
+
30
+def test_crewai_provider_toolkits() -> None:
31
+ """Verify CrewAI provider returns list[BaseTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[BaseTool, list[BaseTool]] = Composio(
34
+ provider=CrewAIProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[BaseTool]
39
+ assert_type(tools, list[BaseTool])
40
+
41
+
42
+def test_crewai_provider_slug() -> None:
43
+ """Verify CrewAI provider returns list[BaseTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[BaseTool, list[BaseTool]] = Composio(
46
+ provider=CrewAIProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[BaseTool])
51
+
52
+
53
+def test_crewai_provider_tools_list() -> None:
54
+ """Verify CrewAI provider returns list[BaseTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[BaseTool, list[BaseTool]] = Composio(
57
+ provider=CrewAIProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[BaseTool])
65
+
66
+
67
+def test_crewai_provider_search() -> None:
68
+ """Verify CrewAI provider returns list[BaseTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[BaseTool, list[BaseTool]] = Composio(
71
+ provider=CrewAIProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[BaseTool])
76
+
77
+
78
+def test_crewai_provider_inferred() -> None:
79
+ """Verify CrewAI provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=CrewAIProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[BaseTool] from provider type
85
+ assert_type(tools, list[BaseTool])
python/tests/test_type_inference_custom_provider.py
new
+112
@@ -0,0 +1,112 @@
1
+"""
2
+Type inference verification for CUSTOM providers.
3
+
4
+This test proves the new generic approach works for user-defined providers.
5
+This is the KEY BENEFIT of the two-parameter generic approach over @overload:
6
+custom providers get proper type inference without requiring any changes
7
+to the Composio SDK.
8
+
9
+Run: mypy tests/test_type_inference_custom_provider.py
10
+
11
+Requirements:
12
+ - composio (core SDK)
13
+"""
14
+
15
+from typing import TYPE_CHECKING, Sequence
16
+import typing as t
17
+
18
+from composio import Composio
19
+from composio.client.types import Tool
20
+from composio.core.provider.none_agentic import NonAgenticProvider
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+# ============================================
26
+# Custom provider defined by a hypothetical user
27
+# ============================================
28
+
29
+
30
+class MyCustomTool(t.TypedDict):
31
+ """User's custom tool format."""
32
+
33
+ name: str
34
+ description: str
35
+ parameters: dict
36
+
37
+
38
+MyCustomToolCollection = t.List[MyCustomTool]
39
+
40
+
41
+class MyCustomProvider(
42
+ NonAgenticProvider[MyCustomTool, MyCustomToolCollection], name="my-custom"
43
+):
44
+ """User-defined custom provider."""
45
+
46
+ def wrap_tool(self, tool: Tool) -> MyCustomTool:
47
+ return MyCustomTool(
48
+ name=tool.slug,
49
+ description=tool.description or "",
50
+ parameters=tool.input_parameters or {},
51
+ )
52
+
53
+ def wrap_tools(self, tools: Sequence[Tool]) -> MyCustomToolCollection:
54
+ return [self.wrap_tool(tool) for tool in tools]
55
+
56
+
57
+# ============================================
58
+# Type inference tests
59
+# ============================================
60
+
61
+
62
+def test_custom_provider_type_inference() -> None:
63
+ """Custom provider correctly infers return type.
64
+
65
+ THIS IS THE KEY TEST: Custom providers get proper type inference
66
+ without requiring any changes to the Composio SDK.
67
+ """
68
+ composio = Composio(provider=MyCustomProvider())
69
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
70
+
71
+ if TYPE_CHECKING:
72
+ # The return type should be inferred as list[MyCustomTool]
73
+ assert_type(tools, list[MyCustomTool])
74
+
75
+
76
+def test_custom_provider_explicit_annotation() -> None:
77
+ """Custom provider works with explicit type annotation."""
78
+ composio: Composio[MyCustomTool, MyCustomToolCollection] = Composio(
79
+ provider=MyCustomProvider()
80
+ )
81
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
82
+
83
+ if TYPE_CHECKING:
84
+ assert_type(tools, list[MyCustomTool])
85
+
86
+
87
+def test_custom_provider_all_parameters() -> None:
88
+ """Custom provider type inference works with all get() parameters."""
89
+ composio = Composio(provider=MyCustomProvider())
90
+
91
+ # Test different parameter combinations
92
+ tools_by_toolkit = composio.tools.get(user_id="test", toolkits=["github"])
93
+ tools_by_slug = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
94
+ tools_by_search = composio.tools.get(user_id="test", search="repository")
95
+ tools_by_list = composio.tools.get(user_id="test", tools=["GITHUB_CREATE_REPO"])
96
+
97
+ if TYPE_CHECKING:
98
+ assert_type(tools_by_toolkit, list[MyCustomTool])
99
+ assert_type(tools_by_slug, list[MyCustomTool])
100
+ assert_type(tools_by_search, list[MyCustomTool])
101
+ assert_type(tools_by_list, list[MyCustomTool])
102
+
103
+
104
+def test_custom_provider_tools_attribute_type() -> None:
105
+ """Verify the tools attribute has correct type."""
106
+ from composio.core.models.tools import Tools
107
+
108
+ composio = Composio(provider=MyCustomProvider())
109
+
110
+ if TYPE_CHECKING:
111
+ # The tools attribute should be Tools[MyCustomTool, list[MyCustomTool]]
112
+ assert_type(composio.tools, Tools[MyCustomTool, list[MyCustomTool]])
python/tests/test_type_inference_gemini.py
new
+82
@@ -0,0 +1,82 @@
1
+"""
2
+Type inference verification tests for Gemini provider.
3
+
4
+This file verifies that type checkers correctly infer `list[Any]`
5
+when using the Gemini provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_gemini.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-gemini
15
+"""
16
+
17
+from typing import TYPE_CHECKING, Any, Callable
18
+
19
+from composio import Composio
20
+
21
+if TYPE_CHECKING:
22
+ from typing_extensions import assert_type
23
+
24
+ from composio_gemini import GeminiProvider
25
+
26
+
27
+def test_gemini_provider_toolkits() -> None:
28
+ """Verify Gemini provider returns list[Callable[..., Any]] for toolkits query."""
29
+ if TYPE_CHECKING:
30
+ composio: Composio[Callable[..., Any], list[Callable[..., Any]]] = Composio(
31
+ provider=GeminiProvider()
32
+ )
33
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
34
+
35
+ # Type checker should infer: list[Callable[..., Any]]
36
+ assert_type(tools, list[Callable[..., Any]])
37
+
38
+
39
+def test_gemini_provider_slug() -> None:
40
+ """Verify Gemini provider returns list[Callable[..., Any]] for slug query."""
41
+ if TYPE_CHECKING:
42
+ composio: Composio[Callable[..., Any], list[Callable[..., Any]]] = Composio(
43
+ provider=GeminiProvider()
44
+ )
45
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
46
+
47
+ assert_type(tools, list[Callable[..., Any]])
48
+
49
+
50
+def test_gemini_provider_tools_list() -> None:
51
+ """Verify Gemini provider returns list[Callable[..., Any]] for tools list query."""
52
+ if TYPE_CHECKING:
53
+ composio: Composio[Callable[..., Any], list[Callable[..., Any]]] = Composio(
54
+ provider=GeminiProvider()
55
+ )
56
+ tools = composio.tools.get(
57
+ user_id="test",
58
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
59
+ )
60
+
61
+ assert_type(tools, list[Callable[..., Any]])
62
+
63
+
64
+def test_gemini_provider_search() -> None:
65
+ """Verify Gemini provider returns list[Callable[..., Any]] for search query."""
66
+ if TYPE_CHECKING:
67
+ composio: Composio[Callable[..., Any], list[Callable[..., Any]]] = Composio(
68
+ provider=GeminiProvider()
69
+ )
70
+ tools = composio.tools.get(user_id="test", search="github repository")
71
+
72
+ assert_type(tools, list[Callable[..., Any]])
73
+
74
+
75
+def test_gemini_provider_inferred() -> None:
76
+ """Verify Gemini provider type is correctly inferred without explicit annotation."""
77
+ if TYPE_CHECKING:
78
+ composio = Composio(provider=GeminiProvider())
79
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
80
+
81
+ # Should infer list[Callable[..., Any]] from provider type
82
+ assert_type(tools, list[Callable[..., Any]])
python/tests/test_type_inference_google.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for Google (Vertex AI) provider.
3
+
4
+This file verifies that type checkers correctly infer `list[FunctionDeclaration]`
5
+when using the Google provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_google.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-google
15
+ - google-cloud-aiplatform
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from vertexai.generative_models import FunctionDeclaration
26
+
27
+ from composio_google import GoogleProvider
28
+
29
+
30
+def test_google_provider_toolkits() -> None:
31
+ """Verify Google provider returns list[FunctionDeclaration] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[FunctionDeclaration, list[FunctionDeclaration]] = Composio(
34
+ provider=GoogleProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[FunctionDeclaration]
39
+ assert_type(tools, list[FunctionDeclaration])
40
+
41
+
42
+def test_google_provider_slug() -> None:
43
+ """Verify Google provider returns list[FunctionDeclaration] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[FunctionDeclaration, list[FunctionDeclaration]] = Composio(
46
+ provider=GoogleProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[FunctionDeclaration])
51
+
52
+
53
+def test_google_provider_tools_list() -> None:
54
+ """Verify Google provider returns list[FunctionDeclaration] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[FunctionDeclaration, list[FunctionDeclaration]] = Composio(
57
+ provider=GoogleProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[FunctionDeclaration])
65
+
66
+
67
+def test_google_provider_search() -> None:
68
+ """Verify Google provider returns list[FunctionDeclaration] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[FunctionDeclaration, list[FunctionDeclaration]] = Composio(
71
+ provider=GoogleProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[FunctionDeclaration])
76
+
77
+
78
+def test_google_provider_inferred() -> None:
79
+ """Verify Google provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=GoogleProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[FunctionDeclaration] from provider type
85
+ assert_type(tools, list[FunctionDeclaration])
python/tests/test_type_inference_google_adk.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for Google ADK provider.
3
+
4
+This file verifies that type checkers correctly infer `list[FunctionTool]`
5
+when using the Google ADK provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_google_adk.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-google-adk
15
+ - google-adk
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from google.adk.tools import FunctionTool
26
+
27
+ from composio_google_adk import GoogleAdkProvider
28
+
29
+
30
+def test_google_adk_provider_toolkits() -> None:
31
+ """Verify Google ADK provider returns list[FunctionTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
34
+ provider=GoogleAdkProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[FunctionTool]
39
+ assert_type(tools, list[FunctionTool])
40
+
41
+
42
+def test_google_adk_provider_slug() -> None:
43
+ """Verify Google ADK provider returns list[FunctionTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
46
+ provider=GoogleAdkProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[FunctionTool])
51
+
52
+
53
+def test_google_adk_provider_tools_list() -> None:
54
+ """Verify Google ADK provider returns list[FunctionTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
57
+ provider=GoogleAdkProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[FunctionTool])
65
+
66
+
67
+def test_google_adk_provider_search() -> None:
68
+ """Verify Google ADK provider returns list[FunctionTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
71
+ provider=GoogleAdkProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[FunctionTool])
76
+
77
+
78
+def test_google_adk_provider_inferred() -> None:
79
+ """Verify Google ADK provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=GoogleAdkProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[FunctionTool] from provider type
85
+ assert_type(tools, list[FunctionTool])
python/tests/test_type_inference_langchain.py
new
+86
@@ -0,0 +1,86 @@
1
+"""
2
+Type inference verification tests for LangChain provider.
3
+
4
+This file verifies that type checkers correctly infer `list[StructuredTool]`
5
+when using the LangChain provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_langchain.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-langchain
15
+ - langchain-core
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from composio_langchain.provider import StructuredTool
26
+
27
+ from composio_langchain import LangchainProvider
28
+
29
+
30
+def test_langchain_provider_toolkits() -> None:
31
+ """Verify LangChain provider returns list[StructuredTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
34
+ provider=LangchainProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[StructuredTool]
39
+ assert_type(tools, list[StructuredTool])
40
+
41
+
42
+def test_langchain_provider_slug() -> None:
43
+ """Verify LangChain provider returns list[StructuredTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
46
+ provider=LangchainProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[StructuredTool])
51
+
52
+
53
+def test_langchain_provider_tools_list() -> None:
54
+ """Verify LangChain provider returns list[StructuredTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
57
+ provider=LangchainProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[StructuredTool])
65
+
66
+
67
+def test_langchain_provider_search() -> None:
68
+ """Verify LangChain provider returns list[StructuredTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
71
+ provider=LangchainProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[StructuredTool])
76
+
77
+
78
+def test_langchain_provider_inferred() -> None:
79
+ """Verify LangChain provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=LangchainProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[StructuredTool] from provider type
85
+ # Note: The provider's StructuredTool is a subclass of langchain_core's StructuredTool
86
+ assert_type(tools, list[StructuredTool])
python/tests/test_type_inference_langgraph.py
new
+86
@@ -0,0 +1,86 @@
1
+"""
2
+Type inference verification tests for LangGraph provider.
3
+
4
+This file verifies that type checkers correctly infer `list[StructuredTool]`
5
+when using the LangGraph provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_langgraph.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-langgraph
15
+ - langchain-core
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from composio_langgraph.provider import StructuredTool
26
+
27
+ from composio_langgraph import LanggraphProvider
28
+
29
+
30
+def test_langgraph_provider_toolkits() -> None:
31
+ """Verify LangGraph provider returns list[StructuredTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
34
+ provider=LanggraphProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[StructuredTool]
39
+ assert_type(tools, list[StructuredTool])
40
+
41
+
42
+def test_langgraph_provider_slug() -> None:
43
+ """Verify LangGraph provider returns list[StructuredTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
46
+ provider=LanggraphProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[StructuredTool])
51
+
52
+
53
+def test_langgraph_provider_tools_list() -> None:
54
+ """Verify LangGraph provider returns list[StructuredTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
57
+ provider=LanggraphProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[StructuredTool])
65
+
66
+
67
+def test_langgraph_provider_search() -> None:
68
+ """Verify LangGraph provider returns list[StructuredTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[StructuredTool, list[StructuredTool]] = Composio(
71
+ provider=LanggraphProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[StructuredTool])
76
+
77
+
78
+def test_langgraph_provider_inferred() -> None:
79
+ """Verify LangGraph provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=LanggraphProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[StructuredTool] from provider type
85
+ # Note: The provider's StructuredTool is a subclass of langchain_core's StructuredTool
86
+ assert_type(tools, list[StructuredTool])
python/tests/test_type_inference_llamaindex.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for LlamaIndex provider.
3
+
4
+This file verifies that type checkers correctly infer `list[FunctionTool]`
5
+when using the LlamaIndex provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_llamaindex.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-llamaindex
15
+ - llama-index-core
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from llama_index.core.tools import FunctionTool
26
+
27
+ from composio_llamaindex import LlamaIndexProvider
28
+
29
+
30
+def test_llamaindex_provider_toolkits() -> None:
31
+ """Verify LlamaIndex provider returns list[FunctionTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
34
+ provider=LlamaIndexProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[FunctionTool]
39
+ assert_type(tools, list[FunctionTool])
40
+
41
+
42
+def test_llamaindex_provider_slug() -> None:
43
+ """Verify LlamaIndex provider returns list[FunctionTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
46
+ provider=LlamaIndexProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[FunctionTool])
51
+
52
+
53
+def test_llamaindex_provider_tools_list() -> None:
54
+ """Verify LlamaIndex provider returns list[FunctionTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
57
+ provider=LlamaIndexProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[FunctionTool])
65
+
66
+
67
+def test_llamaindex_provider_search() -> None:
68
+ """Verify LlamaIndex provider returns list[FunctionTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
71
+ provider=LlamaIndexProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[FunctionTool])
76
+
77
+
78
+def test_llamaindex_provider_inferred() -> None:
79
+ """Verify LlamaIndex provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=LlamaIndexProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[FunctionTool] from provider type
85
+ assert_type(tools, list[FunctionTool])
python/tests/test_type_inference_openai_agents.py
new
+85
@@ -0,0 +1,85 @@
1
+"""
2
+Type inference verification tests for OpenAI Agents provider.
3
+
4
+This file verifies that type checkers correctly infer `list[FunctionTool]`
5
+when using the OpenAI Agents provider with Composio.
6
+
7
+**This file is NOT executed at runtime.** It is analyzed statically by type
8
+checkers to verify that type inference works correctly.
9
+
10
+Run: mypy tests/test_type_inference_openai_agents.py
11
+
12
+Requirements:
13
+ - composio (core SDK)
14
+ - composio-openai-agents
15
+ - openai-agents
16
+"""
17
+
18
+from typing import TYPE_CHECKING
19
+
20
+from composio import Composio
21
+
22
+if TYPE_CHECKING:
23
+ from typing_extensions import assert_type
24
+
25
+ from agents import FunctionTool
26
+
27
+ from composio_openai_agents import OpenAIAgentsProvider
28
+
29
+
30
+def test_openai_agents_provider_toolkits() -> None:
31
+ """Verify OpenAI Agents provider returns list[FunctionTool] for toolkits query."""
32
+ if TYPE_CHECKING:
33
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
34
+ provider=OpenAIAgentsProvider()
35
+ )
36
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
37
+
38
+ # Type checker should infer: list[FunctionTool]
39
+ assert_type(tools, list[FunctionTool])
40
+
41
+
42
+def test_openai_agents_provider_slug() -> None:
43
+ """Verify OpenAI Agents provider returns list[FunctionTool] for slug query."""
44
+ if TYPE_CHECKING:
45
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
46
+ provider=OpenAIAgentsProvider()
47
+ )
48
+ tools = composio.tools.get(user_id="test", slug="GITHUB_CREATE_REPO")
49
+
50
+ assert_type(tools, list[FunctionTool])
51
+
52
+
53
+def test_openai_agents_provider_tools_list() -> None:
54
+ """Verify OpenAI Agents provider returns list[FunctionTool] for tools list query."""
55
+ if TYPE_CHECKING:
56
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
57
+ provider=OpenAIAgentsProvider()
58
+ )
59
+ tools = composio.tools.get(
60
+ user_id="test",
61
+ tools=["GITHUB_CREATE_REPO", "GITHUB_GET_USER"],
62
+ )
63
+
64
+ assert_type(tools, list[FunctionTool])
65
+
66
+
67
+def test_openai_agents_provider_search() -> None:
68
+ """Verify OpenAI Agents provider returns list[FunctionTool] for search query."""
69
+ if TYPE_CHECKING:
70
+ composio: Composio[FunctionTool, list[FunctionTool]] = Composio(
71
+ provider=OpenAIAgentsProvider()
72
+ )
73
+ tools = composio.tools.get(user_id="test", search="github repository")
74
+
75
+ assert_type(tools, list[FunctionTool])
76
+
77
+
78
+def test_openai_agents_provider_inferred() -> None:
79
+ """Verify OpenAI Agents provider type is correctly inferred without explicit annotation."""
80
+ if TYPE_CHECKING:
81
+ composio = Composio(provider=OpenAIAgentsProvider())
82
+ tools = composio.tools.get(user_id="test", toolkits=["github"])
83
+
84
+ # Should infer list[FunctionTool] from provider type
85
+ assert_type(tools, list[FunctionTool])
uv.lock
+9
-9
@@ -477,7 +477,7 @@ wheels = [
477
478
[[package]]
479
name = "composio"
480
-version = "0.11.0"
480
+version = "0.11.1"
481
source = { virtual = "python" }
482
dependencies = [
483
{ name = "composio-client" },
@@ -534,7 +534,7 @@ dev = [
534
535
[[package]]
536
name = "composio-anthropic"
537
-version = "0.11.0"
537
+version = "0.11.1"
538
source = { virtual = "python/providers/anthropic" }
539
dependencies = [
540
{ name = "anthropic" },
@@ -566,7 +566,7 @@ wheels = [
566
567
[[package]]
568
name = "composio-crewai"
569
-version = "0.11.0"
569
+version = "0.11.1"
570
source = { virtual = "python/providers/crewai" }
571
dependencies = [
572
{ name = "composio" },
@@ -581,7 +581,7 @@ requires-dist = [
581
582
[[package]]
583
name = "composio-gemini"
584
-version = "0.11.0"
584
+version = "0.11.1"
585
source = { virtual = "python/providers/gemini" }
586
dependencies = [
587
{ name = "composio" },
@@ -596,7 +596,7 @@ requires-dist = [
596
597
[[package]]
598
name = "composio-google"
599
-version = "0.11.0"
599
+version = "0.11.1"
600
source = { virtual = "python/providers/google" }
601
dependencies = [
602
{ name = "composio" },
@@ -611,7 +611,7 @@ requires-dist = [
611
612
[[package]]
613
name = "composio-google-adk"
614
-version = "0.11.0"
614
+version = "0.11.1"
615
source = { virtual = "python/providers/google_adk" }
616
dependencies = [
617
{ name = "composio" },
@@ -626,7 +626,7 @@ requires-dist = [
626
627
[[package]]
628
name = "composio-langchain"
629
-version = "0.11.0"
629
+version = "0.11.1"
630
source = { virtual = "python/providers/langchain" }
631
dependencies = [
632
{ name = "composio" },
@@ -641,7 +641,7 @@ requires-dist = [
641
642
[[package]]
643
name = "composio-openai"
644
-version = "0.11.0"
644
+version = "0.11.1"
645
source = { virtual = "python/providers/openai" }
646
dependencies = [
647
{ name = "composio" },
@@ -656,7 +656,7 @@ requires-dist = [
656
657
[[package]]
658
name = "composio-openai-agents"
659
-version = "0.11.0"
659
+version = "0.11.1"
660
source = { virtual = "python/providers/openai_agents" }
661
dependencies = [
662
{ name = "composio" },