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, 15:45 UTC
core(py): add `auto_upload_download_files` boolean flag to `Composio()` (#2334)
Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
Alberto Schiabel committed
Jan 12, 2026 at 12:01 UTC
2f879e84863c794081610938be37c3c7eb047730
7 files changed
+573
-18
python/composio/core/models/_files.py
+33
-6
@@ -182,14 +182,18 @@ class FileHelper(WithLogger):
182
"title": schema.get("title"),
183
}
184
185
- def process_schema_recursively(self, schema: t.Dict) -> t.Dict:
185
+ def enhance_schema_descriptions(self, schema: t.Dict) -> t.Dict:
186
+ """Add type hints and required notes to parameter descriptions.
187
+
188
+ This method enhances parameter descriptions by adding:
189
+ - Type hints ("Please provide a value of type...")
190
+ - Required notes ("This parameter is required.")
191
+
192
+ This is separate from file processing and should always run
193
+ regardless of the auto_upload_download_files setting.
194
+ """
195
required = schema.get("required") or []
196
for _param, _schema in schema["properties"].items():
188
- if self._file_uploadable(schema=_schema):
189
- schema["properties"][_param] = self._process_file_uploadable(
190
- schema=_schema
191
- )
192
-
197
if _schema.get("type") in ["string", "integer", "number", "boolean"]:
198
ext = f"Please provide a value of type {_schema['type']}."
199
description = _schema.get("description", "").rstrip(".")
@@ -204,6 +208,29 @@ class FileHelper(WithLogger):
208
)
209
return schema
210
211
+ def process_file_uploadable_schema(self, schema: t.Dict) -> t.Dict:
212
+ """Process file_uploadable fields in schema.
213
+
214
+ This method converts file_uploadable fields to path format.
215
+ Should only be called when auto_upload_download_files is True.
216
+ """
217
+ for _param, _schema in schema["properties"].items():
218
+ if self._file_uploadable(schema=_schema):
219
+ schema["properties"][_param] = self._process_file_uploadable(
220
+ schema=_schema
221
+ )
222
+ return schema
223
+
224
+ def process_schema_recursively(self, schema: t.Dict) -> t.Dict:
225
+ """Process schema for both file handling and description enhancements.
226
+
227
+ This method is kept for backward compatibility. It calls both
228
+ process_file_uploadable_schema and enhance_schema_descriptions.
229
+ """
230
+ self.process_file_uploadable_schema(schema)
231
+ self.enhance_schema_descriptions(schema)
232
+ return schema
233
+
234
def _substitute_file_uploads_recursively(
235
self,
236
tool: Tool,
python/composio/core/models/tool_router.py
+15
-2
@@ -319,15 +319,18 @@ class ToolRouter(Resource, t.Generic[TProvider]):
319
self,
320
client: HttpClient,
321
provider: t.Optional[TProvider] = None,
322
+ auto_upload_download_files: bool = True,
323
):
324
"""
325
Initialize ToolRouter instance.
326
327
:param client: HTTP client for API calls
328
:param provider: Optional provider for tool wrapping
329
+ :param auto_upload_download_files: Whether to automatically upload and download files. Defaults to True.
330
"""
331
super().__init__(client)
332
self._provider = provider
333
+ self._auto_upload_download_files = auto_upload_download_files
334
335
def _create_mcp_server_config(
336
self,
@@ -578,6 +581,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
581
tools_model = ToolsModel(
582
client=self._client,
583
provider=self._provider,
584
+ auto_upload_download_files=self._auto_upload_download_files,
585
)
586
587
def tools_fn(modifiers: t.Optional[Modifiers] = None) -> t.Any:
@@ -652,14 +656,23 @@ class ToolRouter(Resource, t.Generic[TProvider]):
656
for tool in router_tools
657
]
658
655
- # Process file schemas
659
+ # Always enhance schema descriptions (type hints and required notes)
660
for tool in router_tools:
661
tool.input_parameters = (
658
- tools_model._file_helper.process_schema_recursively(
662
+ tools_model._file_helper.enhance_schema_descriptions(
663
schema=tool.input_parameters,
664
)
665
)
666
667
+ # Process file uploadable schemas
668
+ if self._auto_upload_download_files:
669
+ for tool in router_tools:
670
+ tool.input_parameters = (
671
+ tools_model._file_helper.process_file_uploadable_schema(
672
+ schema=tool.input_parameters,
673
+ )
674
+ )
675
+
676
# Wrap tools with provider
677
if issubclass(type(self._provider), NonAgenticProvider):
678
return t.cast(NonAgenticProvider, self._provider).wrap_tools(
python/composio/core/models/tools.py
+26
-9
@@ -61,6 +61,7 @@ class Tools(Resource, t.Generic[TProvider]):
61
provider: TProvider,
62
file_download_dir: t.Optional[str] = None,
63
toolkit_versions: t.Optional[ToolkitVersionParam] = None,
64
+ auto_upload_download_files: bool = True,
65
):
66
"""
67
Initialize the tools resource.
@@ -69,12 +70,14 @@ class Tools(Resource, t.Generic[TProvider]):
70
:param provider: The provider to use for the tools resource.
71
:param file_download_dir: Output directory for downloadable files
72
:param toolkit_versions: The versions of the toolkits to use. Defaults to 'latest' if not provided.
73
+ :param auto_upload_download_files: Whether to automatically upload and download files. Defaults to True.
74
"""
75
self._client = client
76
self._custom_tools = CustomTools(client)
77
self._tool_schemas: t.Dict[str, Tool] = {}
78
self._file_helper = FileHelper(client=self._client, outdir=file_download_dir)
79
self._toolkit_versions = toolkit_versions
80
+ self._auto_upload_download_files = auto_upload_download_files
81
82
self.custom_tool = self._custom_tools.register
83
self.provider = provider
@@ -192,11 +195,23 @@ class Tools(Resource, t.Generic[TProvider]):
195
self._tool_schemas.update(
196
{tool.slug: tool.model_copy(deep=True) for tool in tools_list}
197
)
198
+
199
+ # Always enhance schema descriptions (type hints and required notes)
200
+ # regardless of auto_upload_download_files setting
201
for tool in tools_list:
196
- tool.input_parameters = self._file_helper.process_schema_recursively(
202
+ tool.input_parameters = self._file_helper.enhance_schema_descriptions(
203
schema=tool.input_parameters,
204
)
205
206
+ # Only process file_uploadable schemas when auto_upload_download_files is True
207
+ if self._auto_upload_download_files:
208
+ for tool in tools_list:
209
+ tool.input_parameters = (
210
+ self._file_helper.process_file_uploadable_schema(
211
+ schema=tool.input_parameters,
212
+ )
213
+ )
214
+
215
if issubclass(type(self.provider), NonAgenticProvider):
216
return t.cast(NonAgenticProvider, self.provider).wrap_tools(
217
tools=tools_list
@@ -559,10 +574,11 @@ class Tools(Resource, t.Generic[TProvider]):
574
"dangerously_skip_version_check", dangerously_skip_version_check
575
)
576
562
- arguments = self._file_helper.substitute_file_uploads(
563
- tool=tool,
564
- request=arguments,
565
- )
577
+ if self._auto_upload_download_files:
578
+ arguments = self._file_helper.substitute_file_uploads(
579
+ tool=tool,
580
+ request=arguments,
581
+ )
582
response = (
583
self._execute_custom_tool(
584
slug=slug,
@@ -582,10 +598,11 @@ class Tools(Resource, t.Generic[TProvider]):
598
dangerously_skip_version_check=dangerously_skip_version_check,
599
)
600
)
585
- response = self._file_helper.substitute_file_downloads(
586
- tool=tool,
587
- response=response,
588
- )
601
+ if self._auto_upload_download_files:
602
+ response = self._file_helper.substitute_file_downloads(
603
+ tool=tool,
604
+ response=response,
605
+ )
606
if modifiers is not None:
607
response = apply_modifier_by_type(
608
modifiers=modifiers,
python/composio/sdk.py
+4
@@ -35,6 +35,7 @@ class SDKConfig(te.TypedDict):
35
allow_tracking: te.NotRequired[bool]
36
file_download_dir: te.NotRequired[str]
37
toolkit_versions: te.NotRequired[ToolkitVersionParam]
38
+ auto_upload_download_files: te.NotRequired[bool]
39
40
41
# class ExperimentalNamespace:
@@ -76,6 +77,7 @@ class Composio(t.Generic[TProvider], WithLogger):
77
- A dictionary mapping toolkit names to specific versions
78
- A string (e.g., 'latest', '20250906_01') to use the same version for all toolkits
79
- None or omitted to use 'latest' as default
80
+ :param auto_upload_download_files: Whether to automatically upload and download files. Defaults to True.
81
"""
82
WithLogger.__init__(self)
83
api_key = kwargs.get("api_key", os.environ.get("COMPOSIO_API_KEY"))
@@ -100,6 +102,7 @@ class Composio(t.Generic[TProvider], WithLogger):
102
provider=self.provider,
103
file_download_dir=kwargs.get("file_download_dir"),
104
toolkit_versions=toolkit_versions,
105
+ auto_upload_download_files=kwargs.get("auto_upload_download_files", True),
106
)
107
108
self.toolkits = Toolkits(client=self._client)
@@ -112,6 +115,7 @@ class Composio(t.Generic[TProvider], WithLogger):
115
self.tool_router = ToolRouter(
116
client=self._client,
117
provider=self.provider,
118
+ auto_upload_download_files=kwargs.get("auto_upload_download_files", True),
119
)
120
self.create = self.tool_router.create
121
self.use = self.tool_router.use
python/tests/test_auto_upload_download_files.py
new
+493
@@ -0,0 +1,493 @@
1
+"""Tests for auto_upload_download_files feature in Composio SDK.
2
+
3
+This module tests the auto_upload_download_files configuration option that controls
4
+automatic file upload and download behavior during tool execution.
5
+"""
6
+
7
+from unittest.mock import Mock, patch
8
+
9
+import pytest
10
+
11
+from composio.client.types import Tool, tool_list_response
12
+from composio.core.models.base import allow_tracking
13
+from composio.core.models.tools import Tools
14
+
15
+
16
+@pytest.fixture(autouse=True)
17
+def disable_telemetry():
18
+ """Disable telemetry for all tests to prevent thread issues."""
19
+ token = allow_tracking.set(False)
20
+ yield
21
+ allow_tracking.reset(token)
22
+
23
+
24
+@pytest.fixture
25
+def mock_client():
26
+ """Create a mock HTTP client."""
27
+ return Mock()
28
+
29
+
30
+@pytest.fixture
31
+def mock_provider():
32
+ """Create a mock provider."""
33
+ provider = Mock()
34
+ provider.name = "test_provider"
35
+ return provider
36
+
37
+
38
+def create_mock_tool(
39
+ slug: str,
40
+ toolkit_slug: str,
41
+ input_parameters: dict | None = None,
42
+ output_parameters: dict | None = None,
43
+) -> Tool:
44
+ """Create a mock tool for testing."""
45
+ return Tool(
46
+ name=f"Test {slug}",
47
+ slug=slug,
48
+ description="Test tool",
49
+ input_parameters=input_parameters or {"type": "object", "properties": {}},
50
+ output_parameters=output_parameters or {"type": "object", "properties": {}},
51
+ available_versions=["v1.0.0"],
52
+ version="v1.0.0",
53
+ scopes=[],
54
+ toolkit=tool_list_response.ItemToolkit(
55
+ name=toolkit_slug.title(), slug=toolkit_slug, logo=""
56
+ ),
57
+ deprecated=tool_list_response.ItemDeprecated(
58
+ available_versions=["v1.0.0"],
59
+ displayName=f"Test {slug}",
60
+ version="v1.0.0",
61
+ toolkit=tool_list_response.ItemDeprecatedToolkit(logo=""),
62
+ is_deprecated=False,
63
+ ),
64
+ is_deprecated=False,
65
+ no_auth=False,
66
+ tags=[],
67
+ )
68
+
69
+
70
+class TestAutoUploadDownloadFilesEnabled:
71
+ """Test cases when auto_upload_download_files is enabled."""
72
+
73
+ def test_get_processes_schema_for_file_uploadable(self, mock_client, mock_provider):
74
+ """Test that _get processes schema when auto_upload_download_files is True."""
75
+ tools = Tools(
76
+ client=mock_client,
77
+ provider=mock_provider,
78
+ auto_upload_download_files=True,
79
+ toolkit_versions={"test_toolkit": "20251201_01"},
80
+ )
81
+
82
+ # Create tool with file_uploadable field
83
+ mock_tool = create_mock_tool(
84
+ slug="TEST_TOOL",
85
+ toolkit_slug="test_toolkit",
86
+ input_parameters={
87
+ "type": "object",
88
+ "properties": {
89
+ "file": {
90
+ "type": "string",
91
+ "file_uploadable": True,
92
+ "description": "Upload a file",
93
+ },
94
+ "text": {"type": "string"},
95
+ },
96
+ },
97
+ )
98
+
99
+ # Mock client.tools.list
100
+ mock_client.tools.list.return_value = Mock(items=[mock_tool])
101
+
102
+ # Mock provider.wrap_tools
103
+ mock_provider.wrap_tools = Mock(return_value=[])
104
+
105
+ # Get tools
106
+ tools._get(user_id="test-user", tools=["TEST_TOOL"])
107
+
108
+ # Verify schema was processed (format: "path" added to file_uploadable field)
109
+ wrap_tools_call = mock_provider.wrap_tools.call_args
110
+ processed_tools = wrap_tools_call[1]["tools"]
111
+ file_param = processed_tools[0].input_parameters["properties"]["file"]
112
+
113
+ # Check that file_uploadable schema was converted to path format
114
+ assert file_param.get("format") == "path"
115
+ assert file_param.get("type") == "string"
116
+
117
+ def test_execute_calls_substitute_file_uploads(self, mock_client, mock_provider):
118
+ """Test that execute calls substitute_file_uploads when enabled."""
119
+ tools = Tools(
120
+ client=mock_client,
121
+ provider=mock_provider,
122
+ auto_upload_download_files=True,
123
+ toolkit_versions={"test_toolkit": "20251201_01"},
124
+ )
125
+
126
+ mock_tool = create_mock_tool(
127
+ slug="TEST_TOOL",
128
+ toolkit_slug="test_toolkit",
129
+ input_parameters={
130
+ "type": "object",
131
+ "properties": {
132
+ "file": {"type": "string", "file_uploadable": True},
133
+ },
134
+ },
135
+ output_parameters={
136
+ "type": "object",
137
+ "properties": {},
138
+ },
139
+ )
140
+
141
+ with patch.object(
142
+ tools, "get_raw_composio_tool_by_slug", return_value=mock_tool
143
+ ):
144
+ mock_execute_response = Mock()
145
+ mock_execute_response.model_dump.return_value = {
146
+ "data": {"result": "success"},
147
+ "error": None,
148
+ "successful": True,
149
+ }
150
+ mock_client.tools.execute.return_value = mock_execute_response
151
+
152
+ # Patch both substitute methods to verify substitute_file_uploads is called
153
+ with (
154
+ patch.object(
155
+ tools._file_helper, "substitute_file_uploads"
156
+ ) as mock_upload,
157
+ patch.object(
158
+ tools._file_helper, "substitute_file_downloads"
159
+ ) as mock_download,
160
+ ):
161
+ mock_upload.return_value = {"file": "processed_path"}
162
+ mock_download.return_value = {
163
+ "data": {"result": "success"},
164
+ "error": None,
165
+ "successful": True,
166
+ }
167
+
168
+ tools.execute(
169
+ slug="TEST_TOOL",
170
+ arguments={"file": "/path/to/file.txt"},
171
+ dangerously_skip_version_check=True,
172
+ )
173
+
174
+ mock_upload.assert_called_once()
175
+
176
+ def test_execute_calls_substitute_file_downloads(self, mock_client, mock_provider):
177
+ """Test that execute calls substitute_file_downloads when enabled."""
178
+ tools = Tools(
179
+ client=mock_client,
180
+ provider=mock_provider,
181
+ auto_upload_download_files=True,
182
+ toolkit_versions={"test_toolkit": "20251201_01"},
183
+ )
184
+
185
+ mock_tool = create_mock_tool(
186
+ slug="TEST_TOOL",
187
+ toolkit_slug="test_toolkit",
188
+ input_parameters={
189
+ "type": "object",
190
+ "properties": {},
191
+ },
192
+ output_parameters={
193
+ "type": "object",
194
+ "properties": {
195
+ "file": {"type": "object", "file_downloadable": True},
196
+ },
197
+ },
198
+ )
199
+
200
+ with patch.object(
201
+ tools, "get_raw_composio_tool_by_slug", return_value=mock_tool
202
+ ):
203
+ mock_execute_response = Mock()
204
+ mock_execute_response.model_dump.return_value = {
205
+ "data": {
206
+ "file": {
207
+ "name": "result.txt",
208
+ "mimetype": "text/plain",
209
+ "s3url": "https://s3.example.com/result.txt",
210
+ }
211
+ },
212
+ "error": None,
213
+ "successful": True,
214
+ }
215
+ mock_client.tools.execute.return_value = mock_execute_response
216
+
217
+ # Patch both substitute methods to verify substitute_file_downloads is called
218
+ with (
219
+ patch.object(
220
+ tools._file_helper, "substitute_file_uploads"
221
+ ) as mock_upload,
222
+ patch.object(
223
+ tools._file_helper, "substitute_file_downloads"
224
+ ) as mock_download,
225
+ ):
226
+ mock_upload.return_value = {}
227
+ mock_download.return_value = {
228
+ "data": {"file": "/downloaded/result.txt"},
229
+ "error": None,
230
+ "successful": True,
231
+ }
232
+
233
+ tools.execute(
234
+ slug="TEST_TOOL",
235
+ arguments={},
236
+ dangerously_skip_version_check=True,
237
+ )
238
+
239
+ mock_download.assert_called_once()
240
+
241
+
242
+class TestAutoUploadDownloadFilesDisabled:
243
+ """Test cases when auto_upload_download_files is disabled."""
244
+
245
+ def test_get_does_not_process_file_uploadable_when_disabled(
246
+ self, mock_client, mock_provider
247
+ ):
248
+ """Test that _get does not process file_uploadable fields when auto_upload_download_files is False."""
249
+ tools = Tools(
250
+ client=mock_client,
251
+ provider=mock_provider,
252
+ auto_upload_download_files=False,
253
+ toolkit_versions={"test_toolkit": "20251201_01"},
254
+ )
255
+
256
+ # Create tool with file_uploadable field
257
+ mock_tool = create_mock_tool(
258
+ slug="TEST_TOOL",
259
+ toolkit_slug="test_toolkit",
260
+ input_parameters={
261
+ "type": "object",
262
+ "properties": {
263
+ "file": {
264
+ "type": "string",
265
+ "file_uploadable": True,
266
+ "description": "Upload a file",
267
+ },
268
+ },
269
+ },
270
+ )
271
+
272
+ # Mock client.tools.list
273
+ mock_client.tools.list.return_value = Mock(items=[mock_tool])
274
+
275
+ # Mock provider.wrap_tools
276
+ mock_provider.wrap_tools = Mock(return_value=[])
277
+
278
+ # Get tools
279
+ tools._get(user_id="test-user", tools=["TEST_TOOL"])
280
+
281
+ # Verify file_uploadable schema was NOT processed (not converted to path format)
282
+ wrap_tools_call = mock_provider.wrap_tools.call_args
283
+ processed_tools = wrap_tools_call[1]["tools"]
284
+ file_param = processed_tools[0].input_parameters["properties"]["file"]
285
+
286
+ # Should NOT have format: "path" since auto_upload_download_files is False
287
+ assert file_param.get("format") is None
288
+ assert file_param.get("file_uploadable") is True
289
+
290
+ def test_get_still_enhances_descriptions_when_disabled(
291
+ self, mock_client, mock_provider
292
+ ):
293
+ """Test that _get still adds type hints and required notes when auto_upload_download_files is False.
294
+
295
+ The auto_upload_download_files flag should only control file upload/download behavior,
296
+ not the description enhancements (type hints and required notes).
297
+ """
298
+ tools = Tools(
299
+ client=mock_client,
300
+ provider=mock_provider,
301
+ auto_upload_download_files=False,
302
+ toolkit_versions={"test_toolkit": "20251201_01"},
303
+ )
304
+
305
+ # Create tool with various parameter types
306
+ mock_tool = create_mock_tool(
307
+ slug="TEST_TOOL",
308
+ toolkit_slug="test_toolkit",
309
+ input_parameters={
310
+ "type": "object",
311
+ "required": ["required_param"],
312
+ "properties": {
313
+ "text_param": {
314
+ "type": "string",
315
+ "description": "A text parameter",
316
+ },
317
+ "required_param": {
318
+ "type": "integer",
319
+ "description": "A required parameter",
320
+ },
321
+ },
322
+ },
323
+ )
324
+
325
+ # Mock client.tools.list
326
+ mock_client.tools.list.return_value = Mock(items=[mock_tool])
327
+
328
+ # Mock provider.wrap_tools
329
+ mock_provider.wrap_tools = Mock(return_value=[])
330
+
331
+ # Get tools
332
+ tools._get(user_id="test-user", tools=["TEST_TOOL"])
333
+
334
+ # Verify description enhancements were applied
335
+ wrap_tools_call = mock_provider.wrap_tools.call_args
336
+ processed_tools = wrap_tools_call[1]["tools"]
337
+ props = processed_tools[0].input_parameters["properties"]
338
+
339
+ # Type hints should be added
340
+ assert (
341
+ "Please provide a value of type string"
342
+ in props["text_param"]["description"]
343
+ )
344
+ assert (
345
+ "Please provide a value of type integer"
346
+ in props["required_param"]["description"]
347
+ )
348
+
349
+ # Required notes should be added
350
+ assert "This parameter is required" in props["required_param"]["description"]
351
+
352
+ def test_execute_skips_file_uploads_when_disabled(self, mock_client, mock_provider):
353
+ """Test that execute does not call substitute_file_uploads when disabled."""
354
+ tools = Tools(
355
+ client=mock_client,
356
+ provider=mock_provider,
357
+ auto_upload_download_files=False,
358
+ toolkit_versions={"test_toolkit": "20251201_01"},
359
+ )
360
+
361
+ mock_tool = create_mock_tool(
362
+ slug="TEST_TOOL",
363
+ toolkit_slug="test_toolkit",
364
+ input_parameters={
365
+ "type": "object",
366
+ "properties": {
367
+ "file": {"type": "string", "file_uploadable": True},
368
+ },
369
+ },
370
+ )
371
+
372
+ with patch.object(
373
+ tools, "get_raw_composio_tool_by_slug", return_value=mock_tool
374
+ ):
375
+ mock_execute_response = Mock()
376
+ mock_execute_response.model_dump.return_value = {
377
+ "data": {"result": "success"},
378
+ "error": None,
379
+ "successful": True,
380
+ }
381
+ mock_client.tools.execute.return_value = mock_execute_response
382
+
383
+ # Patch substitute_file_uploads to verify it's NOT called
384
+ with patch.object(
385
+ tools._file_helper, "substitute_file_uploads"
386
+ ) as mock_substitute:
387
+ tools.execute(
388
+ slug="TEST_TOOL",
389
+ arguments={"file": "/path/to/file.txt"},
390
+ dangerously_skip_version_check=True,
391
+ )
392
+
393
+ mock_substitute.assert_not_called()
394
+
395
+ def test_execute_skips_file_downloads_when_disabled(
396
+ self, mock_client, mock_provider
397
+ ):
398
+ """Test that execute does not call substitute_file_downloads when disabled."""
399
+ tools = Tools(
400
+ client=mock_client,
401
+ provider=mock_provider,
402
+ auto_upload_download_files=False,
403
+ toolkit_versions={"test_toolkit": "20251201_01"},
404
+ )
405
+
406
+ mock_tool = create_mock_tool(
407
+ slug="TEST_TOOL",
408
+ toolkit_slug="test_toolkit",
409
+ output_parameters={
410
+ "type": "object",
411
+ "properties": {
412
+ "file": {"type": "object", "file_downloadable": True},
413
+ },
414
+ },
415
+ )
416
+
417
+ with patch.object(
418
+ tools, "get_raw_composio_tool_by_slug", return_value=mock_tool
419
+ ):
420
+ mock_execute_response = Mock()
421
+ mock_execute_response.model_dump.return_value = {
422
+ "data": {
423
+ "file": {
424
+ "name": "result.txt",
425
+ "mimetype": "text/plain",
426
+ "s3url": "https://s3.example.com/result.txt",
427
+ }
428
+ },
429
+ "error": None,
430
+ "successful": True,
431
+ }
432
+ mock_client.tools.execute.return_value = mock_execute_response
433
+
434
+ # Patch substitute_file_downloads to verify it's NOT called
435
+ with patch.object(
436
+ tools._file_helper, "substitute_file_downloads"
437
+ ) as mock_substitute:
438
+ result = tools.execute(
439
+ slug="TEST_TOOL",
440
+ arguments={},
441
+ dangerously_skip_version_check=True,
442
+ )
443
+
444
+ mock_substitute.assert_not_called()
445
+
446
+ # Verify raw S3 URL is preserved in response
447
+ assert (
448
+ result["data"]["file"]["s3url"]
449
+ == "https://s3.example.com/result.txt"
450
+ )
451
+
452
+
453
+class TestAutoUploadDownloadFilesWithSDK:
454
+ """Test cases for auto_upload_download_files with SDK initialization."""
455
+
456
+ def test_sdk_passes_auto_upload_download_files_to_tools(self):
457
+ """Test that Composio SDK passes auto_upload_download_files to Tools."""
458
+ from composio.sdk import Composio
459
+
460
+ with patch("composio.sdk.HttpClient"):
461
+ # Test with default (True)
462
+ with patch.object(Tools, "__init__", return_value=None) as mock_init:
463
+ mock_provider = Mock()
464
+ mock_provider.name = "test"
465
+
466
+ Composio(
467
+ provider=mock_provider,
468
+ api_key="test-key",
469
+ )
470
+
471
+ # Should have passed auto_upload_download_files=True (default)
472
+ mock_init.assert_called()
473
+ call_kwargs = mock_init.call_args[1]
474
+ assert call_kwargs.get("auto_upload_download_files", True) is True
475
+
476
+ def test_sdk_passes_false_to_tools(self):
477
+ """Test that Composio SDK correctly passes auto_upload_download_files=False."""
478
+ from composio.sdk import Composio
479
+
480
+ with patch("composio.sdk.HttpClient"):
481
+ with patch.object(Tools, "__init__", return_value=None) as mock_init:
482
+ mock_provider = Mock()
483
+ mock_provider.name = "test"
484
+
485
+ Composio(
486
+ provider=mock_provider,
487
+ api_key="test-key",
488
+ auto_upload_download_files=False,
489
+ )
490
+
491
+ mock_init.assert_called()
492
+ call_kwargs = mock_init.call_args[1]
493
+ assert call_kwargs.get("auto_upload_download_files") is False
python/tests/test_sdk.py
+1
@@ -56,6 +56,7 @@ class TestComposioSDK:
56
"allow_tracking",
57
"file_download_dir",
58
"toolkit_versions",
59
+ "auto_upload_download_files",
60
}
61
assert set(SDKConfig.__annotations__.keys()) == expected_fields
62
python/tests/test_tool_router.py
+1
-1
@@ -762,7 +762,7 @@ class TestToolRouter:
762
763
# Verify Tools was instantiated
764
mock_tools_class.assert_called_once_with(
765
- client=mock_client, provider=mock_provider
765
+ client=mock_client, provider=mock_provider, auto_upload_download_files=True
766
)
767
768
# Verify get_raw_composio_tools was called