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

feat(py): remove legacy custom tools (#3508)

This PR is **part 1 of 3** splitting https://github.com/ComposioHQ/composio/pull/3505 to make the removal of the old 2025 custom tools easier to review. It carries the **Python** slice. - removes the legacy `composio.tools.custom_tool` registry path: `core.models.custom_tools`, `ExecuteRequestFn`, the old fallback execution wiring, the security tests, and the example - preserves the 2026 tool-router APIs: `composio.experimental.tool()`, `composio.experimental.Toolkit`, inline custom-tool execution, preload/attach/use flows, and `session.custom_tools()` - bumps the Python workspace and all provider packages `0.13.1` → `0.14.0` ## Notes - This slice is a byte-identical subset of #3505 — the three split branches recombine to that PR's exact tree. See #3505 for the original local verification logs (`uv run --frozen nox -s chk`, targeted pytest); CI re-runs per PR.

Alberto Schiabel committed Jun 5, 2026 at 10:53 UTC 2758287c87fbec3fc3ce4ddb5263e88f8b367e32
34 files changed +53 -854
python/composio/core/models/custom_tools.py deleted
-284
@@ -1,284 +0,0 @@
1 -"""Custom Tools module.
2 -
3 -Security model — SEC-365 / CWE-639 (cross-tenant credential access)
4 --------------------------------------------------------------------
5 -
6 -Custom tools execute against the caller's OAuth credentials, looked up by
7 -``user_id``. The LLM supplies the *request* arguments for a tool call; the
8 -SDK supplies the ``user_id``. These two inputs MUST stay structurally
9 -separate — if they ever collapse into one ``**kwargs`` dict, an LLM (or a
10 -prompt-injection input) can set ``user_id`` and have us load another
11 -tenant's tokens.
12 -
13 -The trust boundary is ``CustomTools.execute(slug, request, user_id)``:
14 -
15 - * ``request`` is treated as untrusted and is filtered through an
16 - *allowlist* of fields declared on the tool's Pydantic ``request_model``,
17 - so today's ``user_id`` smuggling — and any future identity-bearing key
18 - that might be added to the auth path (``tenant_id``, ``org_id``, …) —
19 - is dropped before it can reach credential lookup.
20 - * ``user_id`` is forwarded to ``CustomTool.invoke_trusted(user_id, request_kwargs)``
21 - as a structurally separate parameter.
22 -
23 -``CustomTool.__call__`` (the public ``tool(**kwargs)`` shorthand) raises
24 -``TypeError`` if ``user_id`` appears in ``kwargs`` — refusing the smuggled
25 -key loudly rather than silently using a fallback that could collide with a
26 -real tenant.
27 -"""
28 -
29 -import functools
30 -import inspect
31 -import typing as t
32 -
33 -from pydantic import BaseModel
34 -
35 -from composio.client import HttpClient, NotGiven
36 -from composio.client.types import (
37 - Tool,
38 - tool_list_response,
39 - tool_proxy_params,
40 - tool_proxy_response,
41 -)
42 -from composio.exceptions import (
43 - NotFoundError,
44 -)
45 -
46 -
47 -class ExecuteRequestFn(t.Protocol):
48 - def __call__(
49 - self,
50 - endpoint: str,
51 - method: t.Literal["GET", "POST", "PUT", "DELETE", "PATCH"],
52 - body: t.Dict | NotGiven = HttpClient.not_given,
53 - connected_account_id: str | NotGiven = HttpClient.not_given,
54 - parameters: (
55 - t.Iterable[tool_proxy_params.Parameter] | NotGiven
56 - ) = HttpClient.not_given,
57 - ) -> tool_proxy_response.ToolProxyResponse: ...
58 -
59 -
60 -class CustomToolProtocol(t.Protocol):
61 - def __call__(self, request: t.Any) -> t.Any: ...
62 -
63 -
64 -class CustomToolWithProxyProtocol(t.Protocol):
65 - def __call__(
66 - self,
67 - request: t.Any,
68 - execute_request: ExecuteRequestFn,
69 - auth_credentials: t.Dict,
70 - ) -> t.Any: ...
71 -
72 -
73 -CustomToolFn = t.Union[
74 - CustomToolProtocol,
75 - CustomToolWithProxyProtocol,
76 -]
77 -
78 -
79 -class CustomTool:
80 - request_model: t.Type[BaseModel]
81 -
82 - def __init__(
83 - self,
84 - f: t.Callable[..., t.Any],
85 - client: HttpClient,
86 - toolkit: t.Optional[str] = None,
87 - ):
88 - """
89 - Initialize the custom tool.
90 -
91 - :param f: The function to wrap.
92 - :param client: The client to use for the custom tool.
93 - :param toolkit: The toolkit to use for the custom tool.
94 - """
95 - self.f = t.cast(CustomToolFn, f)
96 - self.name, self.slug = f.__name__, f.__name__.upper()
97 - self.description = t.cast(str, f.__doc__)
98 - self.toolkit = toolkit
99 - self.client = client
100 - if self.toolkit is not None:
101 - self.name = f"{self.toolkit.lower()}_{self.name}"
102 - self.slug = f"{self.toolkit.upper()}_{self.slug}"
103 - self.info = self.__parse_info()
104 -
105 - def __parse_info(self) -> Tool:
106 - """Parse the parameters of the custom tool."""
107 - if self.description is None:
108 - raise ValueError(f"Description is required on tool {self.name}")
109 -
110 - self.request_model = inspect.signature(self.f).parameters["request"].annotation
111 - return Tool(
112 - name=self.name,
113 - description=self.description,
114 - input_parameters=self.request_model.model_json_schema(),
115 - output_parameters={},
116 - available_versions=[],
117 - version="1.0.0",
118 - scopes=[],
119 - slug=self.slug,
120 - toolkit=tool_list_response.ItemToolkit(
121 - logo="",
122 - name=self.toolkit or "custom",
123 - slug=(self.toolkit or "custom").upper(),
124 - ),
125 - deprecated=tool_list_response.ItemDeprecated(
126 - available_versions=[],
127 - displayName=self.name,
128 - version="1.0.0",
129 - toolkit=tool_list_response.ItemDeprecatedToolkit(logo=str()),
130 - is_deprecated=False,
131 - ),
132 - is_deprecated=False,
133 - no_auth=False,
134 - tags=[],
135 - )
136 -
137 - def __get_auth_credentials(self, user_id: str) -> dict:
138 - """Get the auth config for the custom tool."""
139 - if self.toolkit is None:
140 - raise ValueError("Toolkit is required for custom tools")
141 -
142 - connected_accounts = self.client.connected_accounts.list(
143 - toolkit_slugs=[self.toolkit],
144 - user_ids=[user_id],
145 - )
146 -
147 - if len(connected_accounts.items) == 0:
148 - raise ValueError(
149 - f"No connected accounts found for toolkit {self.toolkit} and user {user_id}"
150 - )
151 -
152 - account, *_ = sorted(
153 - connected_accounts.items,
154 - key=lambda x: x.created_at,
155 - reverse=True,
156 - )
157 - return account.state.val.model_dump()
158 -
159 - def __call__(self, **kwargs: t.Any) -> t.Any:
160 - """Call the custom tool with the default ``user_id``.
161 -
162 - Refuses ``user_id`` in ``kwargs`` with ``TypeError`` rather than
163 - silently dropping it — see the module docstring for why. Use
164 - ``CustomTools.execute(slug, request, user_id=...)`` (the trusted
165 - entry point) when you need a non-default ``user_id``.
166 - """
167 - if "user_id" in kwargs:
168 - raise TypeError(
169 - "CustomTool.__call__ does not accept user_id; "
170 - "use CustomTools.execute(slug, request, user_id=...) instead."
171 - )
172 - return self.invoke_trusted(user_id="default", request_kwargs=kwargs)
173 -
174 - def invoke_trusted(
175 - self,
176 - user_id: str,
177 - request_kwargs: t.Dict[str, t.Any],
178 - ) -> t.Any:
179 - """Trusted entry point used by ``CustomTools.execute``.
180 -
181 - ``user_id`` is taken as a structurally separate parameter, so an
182 - LLM-controlled ``user_id`` key sitting inside ``request_kwargs``
183 - cannot override it (the request model's default ``extra='ignore'``
184 - means any such key is also dropped during validation).
185 - """
186 - request = self.request_model.model_validate(request_kwargs)
187 - if self.toolkit is None:
188 - return t.cast(CustomToolProtocol, self.f)(request=request)
189 -
190 - return t.cast(CustomToolWithProxyProtocol, self.f)(
191 - request=request,
192 - execute_request=t.cast(ExecuteRequestFn, self.client.tools.proxy),
193 - auth_credentials=self.__get_auth_credentials(user_id),
194 - )
195 -
196 -
197 -def _allowed_request_field_names(request_model: t.Type[BaseModel]) -> t.Set[str]:
198 - """Names accepted by ``request_model`` (canonical name + alias)."""
199 - allowed: t.Set[str] = set()
200 - for field_name, field_info in request_model.model_fields.items():
201 - allowed.add(field_name)
202 - if field_info.alias is not None:
203 - allowed.add(field_info.alias)
204 - return allowed
205 -
206 -
207 -class CustomTools:
208 - """CustomTools class
209 -
210 - Used to manage custom tools created by users."""
211 -
212 - def __init__(self, client: HttpClient):
213 - self.client = client
214 - self.custom_tools_registry: dict[str, CustomTool] = {}
215 -
216 - def __getitem__(self, slug: str) -> CustomTool:
217 - """Get a custom tool by its slug."""
218 - return self.custom_tools_registry[slug]
219 -
220 - def get(self, slug: str) -> t.Optional[CustomTool]:
221 - """Get a custom tool by its slug."""
222 - try:
223 - return self.custom_tools_registry[slug]
224 - except KeyError:
225 - return None
226 -
227 - @t.overload
228 - def register(self, f: CustomToolProtocol) -> CustomTool: ...
229 -
230 - @t.overload
231 - def register(
232 - self, *, toolkit: t.Optional[str] = None
233 - ) -> t.Callable[[CustomToolWithProxyProtocol], CustomTool]: ...
234 -
235 - def register(
236 - self,
237 - f: t.Optional[CustomToolProtocol] = None,
238 - *,
239 - toolkit: t.Optional[str] = None,
240 - ) -> t.Union[
241 - CustomTool,
242 - t.Callable[[CustomToolProtocol], CustomTool],
243 - t.Callable[[CustomToolWithProxyProtocol], CustomTool],
244 - ]:
245 - """Register a custom tool."""
246 - if f is not None:
247 - return self._wrap_tool(f, toolkit)
248 - return functools.partial(self._wrap_tool, toolkit=toolkit)
249 -
250 - def _wrap_tool(
251 - self,
252 - f: CustomToolFn,
253 - toolkit: t.Optional[str] = None,
254 - ) -> CustomTool:
255 - """Wrap a tool function."""
256 - tool = CustomTool(f=f, client=self.client, toolkit=toolkit)
257 - self.custom_tools_registry[tool.slug] = tool
258 - return tool
259 -
260 - def execute(
261 - self,
262 - slug: str,
263 - request: t.Dict,
264 - user_id: t.Optional[str] = None,
265 - ) -> t.Any:
266 - """Execute a custom tool — the trust boundary for LLM-supplied args.
267 -
268 - ``request`` is filtered through an allowlist of fields declared on
269 - the tool's Pydantic ``request_model`` (canonical names + aliases).
270 - Anything else — including the historical ``user_id`` smuggling
271 - vector and any future identity-bearing keys — is dropped before
272 - the call reaches credential lookup. ``user_id`` is forwarded as a
273 - structurally separate parameter; see the module docstring for the
274 - full security model.
275 - """
276 - custom_tool = self.get(slug)
277 - if custom_tool is None:
278 - raise NotFoundError(f"Custom tool with slug {slug} not found")
279 - allowed = _allowed_request_field_names(custom_tool.request_model)
280 - sanitized_request = {k: v for k, v in request.items() if k in allowed}
281 - return custom_tool.invoke_trusted(
282 - user_id=user_id or "default",
283 - request_kwargs=sanitized_request,
284 - )
python/composio/core/models/tools.py
+19 -85
@@ -18,7 +18,6 @@ from composio.client.types import (
18 from composio.core.models._files import FileHelper
19 from composio.core.models.base import Resource
20 from composio.core.models.custom_tool_types import InlineCustomToolsWirePayload
21 -from composio.core.models.custom_tools import CustomTools
21 from composio.core.models.inline_custom_tools_payload import (
22 inline_custom_tools_execute_experimental,
23 )
@@ -28,7 +27,7 @@ from composio.core.provider.base import ExecuteToolFn
27 from composio.core.provider.base import BaseProvider
28 from composio.core.provider.none_agentic import NonAgenticProvider
29 from composio.core.types import ToolkitVersionParam
31 -from composio.exceptions import InvalidParams, NotFoundError, ToolVersionRequiredError
30 +from composio.exceptions import InvalidParams, ToolVersionRequiredError
31 from composio.utils.pydantic import none_to_omit
32 from composio.utils.toolkit_version import get_toolkit_version
33 from composio.utils.upload_dir_allowlist import resolve_effective_upload_allowlist
@@ -144,7 +143,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
143 )
144
145 self._client = client
147 - self._custom_tools = CustomTools(client)
146 self._tool_schemas: t.Dict[str, Tool] = {}
147 self._file_helper = FileHelper(
148 client=self._client,
@@ -155,7 +153,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
153 )
154 self._toolkit_versions = toolkit_versions
155
158 - self.custom_tool = self._custom_tools.register
156 self.provider = provider
157
158 self.provider.set_execute_tool_fn(
@@ -169,33 +166,17 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
166 ),
167 )
168
172 - def _filter_custom_tools(
173 - self, tools: t.List[str]
174 - ) -> t.Tuple[t.List[str], t.List[Tool]]:
175 - """Filter out custom tools from the list of tools."""
176 - _tools = []
177 - _custom_tools = []
178 - for tool in tools:
179 - try:
180 - _custom_tools.append(self._custom_tools[tool].info)
181 - except KeyError:
182 - _tools.append(tool)
183 - return _tools, _custom_tools
184 -
169 def get_raw_composio_tool_by_slug(self, slug: str) -> Tool:
170 """
171 Returns schema for the given tool slug.
172 """
189 - try:
190 - return t.cast(Tool, self._custom_tools[slug])
191 - except KeyError:
192 - return t.cast(
193 - Tool,
194 - self._client.tools.retrieve(
195 - tool_slug=slug,
196 - toolkit_versions=none_to_omit(self._toolkit_versions),
197 - ),
198 - )
173 + return t.cast(
174 + Tool,
175 + self._client.tools.retrieve(
176 + tool_slug=slug,
177 + toolkit_versions=none_to_omit(self._toolkit_versions),
178 + ),
179 + )
180
181 def get_raw_composio_tools(
182 self,
@@ -215,8 +196,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
196
197 tools_list = []
198 if tools is not None:
218 - tools, custom_tools = self._filter_custom_tools(tools=tools)
219 - tools_list.extend(custom_tools)
199 if len(tools):
200 tools_list.extend(
201 self._client.tools.list(
@@ -488,11 +467,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
467 :return: Tool execution response
468 """
469 tool = self._tool_schemas.get(slug)
491 - if tool is None:
492 - custom_tool = self._custom_tools.get(slug=slug)
493 - if custom_tool is not None:
494 - tool = custom_tool.info
495 - self._tool_schemas[slug] = tool
470
471 if tool is None:
472 tool = t.cast(
@@ -572,31 +546,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
546
547 return t.cast(AgenticProviderExecuteFn, execute_tool_fn)
548
575 - def _execute_custom_tool(
576 - self,
577 - slug: str,
578 - arguments: t.Dict,
579 - user_id: t.Optional[str] = None,
580 - ) -> ToolExecutionResponse:
581 - """Execute a custom tool"""
582 - # TODO: Better error handling, pydantic validation eg...
583 - try:
584 - return {
585 - "data": self._custom_tools.execute(
586 - slug=slug,
587 - request=arguments,
588 - user_id=user_id,
589 - ),
590 - "error": None,
591 - "successful": True,
592 - }
593 - except NotFoundError:
594 - return {
595 - "data": {},
596 - "error": f"Tool with slug {slug} not found",
597 - "successful": False,
598 - }
599 -
549 def _execute_tool(
550 self,
551 slug: str,
@@ -669,9 +618,7 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
618 """
619 Execute a tool with the provided parameters.
620
672 - This method calls the Composio API or a custom tool handler to execute
673 - the tool and returns the response. It automatically determines whether
674 - to use a custom tool or a Composio API tool based on the slug.
621 + This method calls the Composio API to execute the tool and returns the response.
622
623 :param slug: The slug of the tool to execute.
624 :param arguments: The arguments to pass to the tool.
@@ -687,11 +634,6 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
634 """
635
636 tool = self._tool_schemas.get(slug)
690 - if tool is None:
691 - custom_tool = self._custom_tools.get(slug=slug)
692 - if custom_tool is not None:
693 - tool = custom_tool.info
694 - self._tool_schemas[slug] = tool
637
638 if tool is None:
639 tool = t.cast(
@@ -760,24 +702,16 @@ class Tools(Resource, t.Generic[TTool, TToolCollection]):
702 dangerously_skip_version_check = processed_params.get(
703 "dangerously_skip_version_check", dangerously_skip_version_check
704 )
763 - response = (
764 - self._execute_custom_tool(
765 - slug=slug,
766 - arguments=arguments,
767 - user_id=user_id,
768 - )
769 - if self._custom_tools.get(slug) is not None
770 - else self._execute_tool(
771 - slug=slug,
772 - arguments=arguments,
773 - connected_account_id=connected_account_id,
774 - custom_auth_params=custom_auth_params,
775 - custom_connection_data=custom_connection_data,
776 - user_id=user_id,
777 - text=text,
778 - version=version,
779 - dangerously_skip_version_check=dangerously_skip_version_check,
780 - )
705 + response = self._execute_tool(
706 + slug=slug,
707 + arguments=arguments,
708 + connected_account_id=connected_account_id,
709 + custom_auth_params=custom_auth_params,
710 + custom_connection_data=custom_connection_data,
711 + user_id=user_id,
712 + text=text,
713 + version=version,
714 + dangerously_skip_version_check=dangerously_skip_version_check,
715 )
716 if self._auto_upload_download_files:
717 response = self._file_helper.substitute_file_downloads(
python/composio/types.py
-2
@@ -1,6 +1,5 @@
1 from composio.client.types import Tool
2 from composio.core.models.connected_accounts import auth_scheme
3 -from composio.core.models.custom_tools import ExecuteRequestFn
3 from composio.core.models.tools import (
4 Modifiers,
5 ToolExecuteParams,
@@ -22,7 +21,6 @@ __all__ = [
21 "TToolCollection",
22 "ToolExecuteParams",
23 "ToolExecutionResponse",
25 - "ExecuteRequestFn",
24 "TriggerEvent",
25 "Modifiers",
26 "auth_scheme",
python/examples/custom_tools.py deleted
-83
@@ -1,83 +0,0 @@
1 -import requests
2 -from pydantic import BaseModel, Field
3 -
4 -from composio import Composio
5 -from composio.types import ExecuteRequestFn
6 -
7 -composio = Composio()
8 -
9 -
10 -class AddTwoNumbersInput(BaseModel):
11 - a: int = Field(
12 - ...,
13 - description="The first number to add",
14 - )
15 - b: int = Field(
16 - ...,
17 - description="The second number to add",
18 - )
19 -
20 -
21 -@composio.tools.custom_tool
22 -def add_two_numbers(request: AddTwoNumbersInput) -> int:
23 - """Add two numbers."""
24 - return request.a + request.b
25 -
26 -
27 -class GetIssueInfoInput(BaseModel):
28 - issue_number: int = Field(
29 - ...,
30 - description="The number of the issue to get information about",
31 - )
32 -
33 -
34 -@composio.tools.custom_tool(toolkit="github")
35 -def get_issue_info(
36 - request: GetIssueInfoInput,
37 - execute_request: ExecuteRequestFn,
38 - auth_credentials: dict,
39 -) -> dict:
40 - """Get information about a GitHub issue."""
41 - response = execute_request(
42 - endpoint=f"/repos/composiohq/composio/issues/{request.issue_number}",
43 - method="GET",
44 - parameters=[
45 - {
46 - "name": "Accept",
47 - "value": "application/vnd.github.v3+json",
48 - "type": "header",
49 - },
50 - {
51 - "name": "Authorization",
52 - "value": f"Bearer {auth_credentials['access_token']}",
53 - "type": "header",
54 - },
55 - ],
56 - )
57 - return {"data": response.data}
58 -
59 -
60 -@composio.tools.custom_tool(toolkit="github")
61 -def get_issue_info_direct(
62 - request: GetIssueInfoInput,
63 - execute_request: ExecuteRequestFn,
64 - auth_credentials: dict,
65 -) -> dict:
66 - """Get information about a GitHub issue."""
67 - response = requests.get(
68 - f"https://api.github.com/repos/composiohq/composio/issues/{request.issue_number}",
69 - headers={
70 - "Accept": "application/vnd.github.v3+json",
71 - "Authorization": f"Bearer {auth_credentials['access_token']}",
72 - },
73 - )
74 - return {"data": response.json()}
75 -
76 -
77 -response = composio.tools.execute(
78 - user_id="default",
79 - slug=get_issue_info.slug,
80 - arguments={"issue_number": 1},
81 -)
82 -
83 -print(response)
python/providers/anthropic/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-anthropic"
3 -version = "0.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
9 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
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.13.1",
11 + version="0.14.0",
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.13.1"
3 +version = "0.14.0"
4 description = "SDK for integrating Composio with your applications."
5 readme = "README.md"
6 requires-python = ">=3.10,<4"
python/tests/test_custom_tools_security.py deleted
-274
@@ -1,274 +0,0 @@
1 -"""Security tests for the legacy ``CustomTool`` / ``CustomTools`` API.
2 -
3 -Regression tests for SEC-365 (CWE-639, cross-tenant credential access).
4 -
5 -Before the fix, ``CustomTool.__call__`` extracted ``user_id`` from the same
6 -``**kwargs`` dict that carried LLM-supplied tool arguments, and
7 -``CustomTools.execute`` happily forwarded that LLM-controlled dict via
8 -``custom_tool(**request, user_id=user_id)``. An LLM (or prompt-injection
9 -input) could therefore set ``user_id`` to another tenant's identifier and
10 -have ``CustomTool.__get_auth_credentials`` look up that victim's OAuth
11 -tokens.
12 -
13 -After the fix:
14 - * ``CustomTools.execute`` filters the LLM-supplied ``request`` through
15 - an *allowlist* of fields declared on the tool's Pydantic
16 - ``request_model`` — ``user_id`` and any other unexpected key are
17 - dropped before they can influence credential lookup or reach the
18 - tool's execute function.
19 - * ``CustomTool.invoke_trusted`` is the structurally separate trusted
20 - entry point; ``user_id`` cannot be smuggled inside ``request_kwargs``.
21 - * ``CustomTool.__call__`` raises ``TypeError`` if ``user_id`` appears
22 - in ``kwargs`` rather than silently using a fallback.
23 -"""
24 -
25 -from unittest.mock import MagicMock
26 -
27 -import pytest
28 -from pydantic import BaseModel, Field
29 -
30 -from composio.core.models.custom_tools import CustomTool, CustomTools
31 -from composio.exceptions import NotFoundError
32 -
33 -
34 -class _IssueInput(BaseModel):
35 - issue_number: int = Field(description="GitHub issue number")
36 -
37 -
38 -@pytest.fixture
39 -def mock_http_client() -> MagicMock:
40 - """Mock HttpClient that returns a single connected account on lookup."""
41 - state = MagicMock()
42 - state.val.model_dump.return_value = {"access_token": "trusted-token"}
43 -
44 - account = MagicMock()
45 - account.created_at = "2026-01-01T00:00:00Z"
46 - account.state = state
47 -
48 - response = MagicMock()
49 - response.items = [account]
50 -
51 - client = MagicMock()
52 - client.connected_accounts.list.return_value = response
53 - client.tools.proxy = MagicMock()
54 - return client
55 -
56 -
57 -@pytest.fixture
58 -def github_tool(mock_http_client: MagicMock) -> CustomTool:
59 - """A registered ``github`` custom tool whose handler echoes the auth token."""
60 -
61 - def github_tool(request: _IssueInput, execute_request, auth_credentials):
62 - """Fetch issue info."""
63 - return {
64 - "issue_number": request.issue_number,
65 - "token": auth_credentials["access_token"],
66 - }
67 -
68 - return CustomTool(f=github_tool, client=mock_http_client, toolkit="github")
69 -
70 -
71 -@pytest.fixture
72 -def custom_tools(mock_http_client: MagicMock, github_tool: CustomTool) -> CustomTools:
73 - """A ``CustomTools`` registry pre-loaded with ``github_tool``."""
74 - tools = CustomTools(client=mock_http_client)
75 - tools.custom_tools_registry[github_tool.slug] = github_tool
76 - return tools
77 -
78 -
79 -def test_execute_strips_user_id_from_llm_request(
80 - mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
81 -) -> None:
82 - """``CustomTools.execute`` MUST drop ``user_id`` from the request dict."""
83 - result = custom_tools.execute(
84 - slug=github_tool.slug,
85 - request={"issue_number": 1, "user_id": "victim-user"},
86 - user_id="trusted-user",
87 - )
88 -
89 - assert result == {"issue_number": 1, "token": "trusted-token"}
90 - mock_http_client.connected_accounts.list.assert_called_once_with(
91 - toolkit_slugs=["github"],
92 - user_ids=["trusted-user"],
93 - )
94 -
95 -
96 -def test_execute_strips_unexpected_fields_via_allowlist(
97 - mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
98 -) -> None:
99 - """The allowlist is durable: any non-declared key is dropped, not just user_id.
100 -
101 - Pins the allowlist behaviour so a future identity-bearing key in the
102 - auth path (``tenant_id``, ``org_id``, ``connected_account_id``, …)
103 - cannot re-introduce CWE-639 by being smuggled through ``request``.
104 - """
105 - captured: dict = {}
106 -
107 - def echo_tool(request: _IssueInput, execute_request, auth_credentials):
108 - """Echo back the validated request."""
109 - captured["fields"] = request.model_dump()
110 - return {"ok": True}
111 -
112 - tools = CustomTools(client=mock_http_client)
113 - tool = CustomTool(f=echo_tool, client=mock_http_client, toolkit="github")
114 - tools.custom_tools_registry[tool.slug] = tool
115 -
116 - tools.execute(
117 - slug=tool.slug,
118 - request={
119 - "issue_number": 1,
120 - "user_id": "victim-user",
121 - "tenant_id": "evil-tenant",
122 - "connected_account_id": "ca_evil",
123 - "extra_garbage": "xyz",
124 - },
125 - user_id="trusted-user",
126 - )
127 -
128 - assert captured["fields"] == {"issue_number": 1}
129 - mock_http_client.connected_accounts.list.assert_called_once_with(
130 - toolkit_slugs=["github"],
131 - user_ids=["trusted-user"],
132 - )
133 -
134 -
135 -def test_execute_keeps_aliases_declared_on_request_model(
136 - mock_http_client: MagicMock,
137 -) -> None:
138 - """Aliases declared on the request model are honoured by the allowlist."""
139 -
140 - class _AliasedInput(BaseModel):
141 - issue_number: int = Field(alias="issueNumber")
142 -
143 - captured: dict = {}
144 -
145 - def aliased_tool(request: _AliasedInput, execute_request, auth_credentials):
146 - """Echo back the validated request."""
147 - captured["fields"] = request.model_dump()
148 - return {"ok": True}
149 -
150 - tools = CustomTools(client=mock_http_client)
151 - tool = CustomTool(f=aliased_tool, client=mock_http_client, toolkit="github")
152 - tools.custom_tools_registry[tool.slug] = tool
153 -
154 - tools.execute(
155 - slug=tool.slug,
156 - request={"issueNumber": 5, "user_id": "victim"},
157 - user_id="trusted-user",
158 - )
159 -
160 - assert captured["fields"] == {"issue_number": 5}
161 -
162 -
163 -def test_execute_falls_back_to_default_when_user_id_missing(
164 - mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
165 -) -> None:
166 - """If no trusted ``user_id`` is provided, ``execute`` MUST use ``"default"``.
167 -
168 - Specifically, ``execute`` MUST NOT silently use the LLM-supplied
169 - ``user_id`` from ``request`` as a fallback — that would re-introduce
170 - SEC-365 under a different code path.
171 - """
172 - custom_tools.execute(
173 - slug=github_tool.slug,
174 - request={"issue_number": 1, "user_id": "victim-user"},
175 - user_id=None,
176 - )
177 -
178 - mock_http_client.connected_accounts.list.assert_called_once_with(
179 - toolkit_slugs=["github"],
180 - user_ids=["default"],
181 - )
182 -
183 -
184 -def test_execute_does_not_mutate_caller_request_dict(
185 - custom_tools: CustomTools, github_tool: CustomTool
186 -) -> None:
187 - """Sanitization MUST NOT mutate the caller's ``request`` dict in place."""
188 - request_dict = {"issue_number": 1, "user_id": "victim-user"}
189 - custom_tools.execute(
190 - slug=github_tool.slug,
191 - request=request_dict,
192 - user_id="trusted-user",
193 - )
194 -
195 - assert request_dict == {"issue_number": 1, "user_id": "victim-user"}
196 -
197 -
198 -def test_call_raises_typeerror_when_user_id_smuggled_in_kwargs(
199 - github_tool: CustomTool,
200 -) -> None:
201 - """``CustomTool.__call__`` MUST refuse a ``user_id`` kwarg loudly.
202 -
203 - Silent fallbacks expand blast radius: a tool that quietly transacts
204 - against ``"default"`` could end up using a real tenant who happens to
205 - be registered under that id. Failing fast also surfaces prompt-injection
206 - attempts instead of swallowing them.
207 - """
208 - smuggled_kwargs = {"issue_number": 1, "user_id": "victim-user"}
209 -
210 - with pytest.raises(TypeError, match="user_id"):
211 - github_tool(**smuggled_kwargs)
212 -
213 -
214 -def test_invoke_trusted_uses_explicit_user_id_over_smuggled_one(
215 - mock_http_client: MagicMock, github_tool: CustomTool
216 -) -> None:
217 - """``invoke_trusted``'s explicit ``user_id`` MUST win over a smuggled key.
218 -
219 - The auth-path argument is structurally separate from ``request_kwargs``,
220 - so an LLM-controlled ``user_id`` inside ``request_kwargs`` cannot
221 - override the trusted parameter. This pins the docstring contract.
222 - """
223 - github_tool.invoke_trusted(
224 - user_id="trusted-user",
225 - request_kwargs={"issue_number": 7, "user_id": "victim-user"},
226 - )
227 -
228 - mock_http_client.connected_accounts.list.assert_called_once_with(
229 - toolkit_slugs=["github"],
230 - user_ids=["trusted-user"],
231 - )
232 -
233 -
234 -def test_execute_unknown_slug_raises(custom_tools: CustomTools) -> None:
235 - """Sanity check: unknown slugs still surface ``NotFoundError``."""
236 - with pytest.raises(NotFoundError):
237 - custom_tools.execute(
238 - slug="DOES_NOT_EXIST",
239 - request={"foo": "bar"},
240 - user_id="trusted-user",
241 - )
242 -
243 -
244 -def test_tools_execute_e2e_strips_user_id_through_full_stack(
245 - mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
246 -) -> None:
247 - """End-to-end check through ``Tools.execute`` (the public SDK entry point).
248 -
249 - ``Tools._execute_tool`` routes custom-tool calls into
250 - ``CustomTools.execute``. The modifier-hook block can also overwrite
251 - ``arguments`` and ``user_id`` from a ``processed_params`` dict, so we
252 - pin that the sanitization still applies after that path.
253 - """
254 - from composio.core.models.tools import Tools
255 -
256 - provider = MagicMock()
257 - provider.name = "test"
258 -
259 - tools = Tools(client=mock_http_client, provider=provider)
260 - tools._custom_tools = custom_tools
261 -
262 - response = tools.execute(
263 - slug=github_tool.slug,
264 - arguments={"issue_number": 1, "user_id": "victim-user"},
265 - user_id="trusted-user",
266 - )
267 -
268 - assert response["successful"] is True
269 - assert response["data"]["issue_number"] == 1
270 - assert response["data"]["token"] == "trusted-token"
271 - mock_http_client.connected_accounts.list.assert_called_once_with(
272 - toolkit_slugs=["github"],
273 - user_ids=["trusted-user"],
274 - )
python/tests/test_imports.py
-2
@@ -38,7 +38,6 @@ def test_import_all_public_exports():
38 def test_import_types():
39 """Test importing types from different modules."""
40 from composio.types import (
41 - ExecuteRequestFn,
41 Modifiers,
42 Tool,
43 ToolExecuteParams,
@@ -58,7 +57,6 @@ def test_import_types():
57 assert TToolCollection is not None
58 assert ToolExecuteParams is not None
59 assert ToolExecutionResponse is not None
61 - assert ExecuteRequestFn is not None
60 assert TriggerEvent is not None
61 assert Modifiers is not None
62 assert auth_scheme is not None
python/tests/test_provider.py
-37
@@ -836,43 +836,6 @@ class TestLangchainReservedKeywords:
836 class TestProviderEdgeCases:
837 """Test edge cases and error handling for providers."""
838
839 - def test_execute_tool_with_custom_tool(self):
840 - """Test that execute_tool works with custom tools."""
841 - mock_client = Mock()
842 - from composio.core.provider._openai import OpenAIProvider
843 -
844 - provider = OpenAIProvider()
845 -
846 - tools = Tools(
847 - client=mock_client,
848 - provider=provider,
849 - toolkit_versions={"custom": "12012025_00"},
850 - )
851 -
852 - custom_tool = create_mock_tool("CUSTOM_TOOL", "custom", "12012025_00")
853 -
854 - mock_custom_tool = Mock()
855 - mock_custom_tool.info = custom_tool
856 -
857 - def mock_get(slug):
858 - return mock_custom_tool if slug == "CUSTOM_TOOL" else None
859 -
860 - tools._custom_tools.get = Mock(side_effect=mock_get)
861 -
862 - def mock_execute(slug, request, user_id):
863 - return {"custom_result": "success", "slug": slug}
864 -
865 - tools._custom_tools.execute = Mock(side_effect=mock_execute)
866 -
867 - result = provider.execute_tool(
868 - slug="CUSTOM_TOOL",
869 - arguments={"param": "value"},
870 - user_id="test-user",
871 - )
872 -
873 - assert result["successful"] is True
874 - assert result["data"]["custom_result"] == "success"
875 -
839 def test_execute_tool_with_none_parameters(self):
840 """Test that execute_tool works when optional parameters are None."""
841 mock_client = Mock()
python/tests/test_tool_execution.py
-53
@@ -715,59 +715,6 @@ class TestToolExecution:
715 assert call_args.kwargs["user_id"] == "user-123"
716 assert call_args.kwargs["text"] == "Additional context"
717
718 - def test_execute_custom_tool(self):
719 - """Test that execute works with custom tools."""
720 - # Mock client and provider
721 - mock_client = Mock()
722 - mock_provider = Mock()
723 - mock_provider.name = "test_provider"
724 -
725 - # Create Tools instance
726 - tools = Tools(
727 - client=mock_client,
728 - provider=mock_provider,
729 - toolkit_versions={"custom": "20251201_01"},
730 - )
731 -
732 - # Create a mock custom tool with proper structure
733 - custom_tool_info = self.create_mock_tool("CUSTOM_TOOL", "custom")
734 - custom_tool_info.input_parameters = {"type": "object", "properties": {}}
735 -
736 - # Mock the custom tool registry
737 - mock_custom_tool = Mock()
738 - mock_custom_tool.info = custom_tool_info
739 - tools._custom_tools.custom_tools_registry = {"CUSTOM_TOOL": mock_custom_tool}
740 -
741 - # Mock the get method to return the tool
742 - def mock_get(slug):
743 - return mock_custom_tool if slug == "CUSTOM_TOOL" else None
744 -
745 - tools._custom_tools.get = Mock(side_effect=mock_get)
746 -
747 - # Mock the execute method of custom tool
748 - def mock_execute(slug, request, user_id):
749 - return {"custom_result": "success"}
750 -
751 - tools._custom_tools.execute = Mock(side_effect=mock_execute)
752 -
753 - # Execute the custom tool
754 - result = tools.execute(
755 - slug="CUSTOM_TOOL",
756 - arguments={"param": "value"},
757 - user_id="user-123",
758 - )
759 -
760 - # Verify execution succeeded
761 - assert result["successful"] is True
762 - assert result["data"]["custom_result"] == "success"
763 -
764 - # Verify custom tool execute was called
765 - tools._custom_tools.execute.assert_called_once_with(
766 - slug="CUSTOM_TOOL",
767 - request={"param": "value"},
768 - user_id="user-123",
769 - )
770 -
718 def test_execute_with_modifiers_before_execute(self):
719 """Test that execute applies before_execute modifiers correctly."""
720 from composio.core.models._modifiers import before_execute
uv.lock
+9 -9
@@ -592,7 +592,7 @@ wheels = [
592
593 [[package]]
594 name = "composio"
595 -version = "0.13.1"
595 +version = "0.14.0"
596 source = { editable = "python" }
597 dependencies = [
598 { name = "composio-client" },
@@ -649,7 +649,7 @@ dev = [
649
650 [[package]]
651 name = "composio-anthropic"
652 -version = "0.13.1"
652 +version = "0.14.0"
653 source = { editable = "python/providers/anthropic" }
654 dependencies = [
655 { name = "anthropic" },
@@ -681,7 +681,7 @@ wheels = [
681
682 [[package]]
683 name = "composio-crewai"
684 -version = "0.13.1"
684 +version = "0.14.0"
685 source = { editable = "python/providers/crewai" }
686 dependencies = [
687 { name = "composio" },
@@ -696,7 +696,7 @@ requires-dist = [
696
697 [[package]]
698 name = "composio-gemini"
699 -version = "0.13.1"
699 +version = "0.14.0"
700 source = { virtual = "python/providers/gemini" }
701 dependencies = [
702 { name = "composio" },
@@ -711,7 +711,7 @@ requires-dist = [
711
712 [[package]]
713 name = "composio-google"
714 -version = "0.13.1"
714 +version = "0.14.0"
715 source = { editable = "python/providers/google" }
716 dependencies = [
717 { name = "composio" },
@@ -726,7 +726,7 @@ requires-dist = [
726
727 [[package]]
728 name = "composio-google-adk"
729 -version = "0.13.1"
729 +version = "0.14.0"
730 source = { editable = "python/providers/google_adk" }
731 dependencies = [
732 { name = "composio" },
@@ -741,7 +741,7 @@ requires-dist = [
741
742 [[package]]
743 name = "composio-langchain"
744 -version = "0.13.1"
744 +version = "0.14.0"
745 source = { editable = "python/providers/langchain" }
746 dependencies = [
747 { name = "composio" },
@@ -756,7 +756,7 @@ requires-dist = [
756
757 [[package]]
758 name = "composio-openai"
759 -version = "0.13.1"
759 +version = "0.14.0"
760 source = { editable = "python/providers/openai" }
761 dependencies = [
762 { name = "composio" },
@@ -771,7 +771,7 @@ requires-dist = [
771
772 [[package]]
773 name = "composio-openai-agents"
774 -version = "0.13.1"
774 +version = "0.14.0"
775 source = { editable = "python/providers/openai_agents" }
776 dependencies = [
777 { name = "composio" },