Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(python): preserve backward compat for remote session.execute()
Remote path returns the SessionExecuteResponse client model as-is (supports attribute access like result.data, result.log_id). Only local custom tool path returns a dict. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dhawal Upadhyay committed
Mar 24, 2026 at 14:22 UTC
35d0af43e1b2210634599c56e8b1f315c70e8675
2 files changed
+8
-13
python/composio/core/models/tool_router_session.py
+5
-9
@@ -478,8 +478,9 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
478
full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process;
479
remote tools are sent to the Composio backend.
480
481
- Returns a dict with ``data``, ``error``, and ``log_id`` keys for both
482
- local and remote execution paths.
481
+ Local tools return a dict with ``data``, ``error``, ``log_id`` keys.
482
+ Remote tools return the ``SessionExecuteResponse`` model from the client
483
+ (backward-compatible — supports attribute access like ``result.data``).
484
"""
485
# Check if this is a local tool (by original or final slug)
486
entry = find_custom_tool(self._custom_tools_map, tool_slug)
@@ -491,17 +492,12 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
492
"log_id": "",
493
}
494
494
- # Remote execution — normalize to dict for consistent return type
495
- response = self._client.tool_router.session.execute(
495
+ # Remote execution — return client model as-is for backward compat
496
+ return self._client.tool_router.session.execute(
497
session_id=self.session_id,
498
tool_slug=tool_slug,
499
arguments=arguments if arguments is not None else omit,
500
)
500
- return {
501
- "data": response.data if hasattr(response, "data") else {},
502
- "error": response.error if hasattr(response, "error") else None,
503
- "log_id": response.log_id if hasattr(response, "log_id") else "",
504
- }
501
502
def custom_tools(
503
self, *, toolkit: t.Optional[str] = None
python/tests/test_custom_tools.py
+3
-4
@@ -553,10 +553,9 @@ class TestToolRouterSessionCustomTools:
553
s = _session(mock_session_deps)
554
result = s.execute("GMAIL_SEND_EMAIL", arguments={"to": "a@b.com"})
555
mock_session_deps["client"].tool_router.session.execute.assert_called_once()
556
- # Remote returns same dict shape as local
557
- assert isinstance(result, dict)
558
- assert result["data"] == {"sent": True}
559
- assert result["log_id"] == "log_123"
556
+ # Remote returns client model as-is (backward compat, supports attribute access)
557
+ assert result.data == {"sent": True}
558
+ assert result.log_id == "log_123"
559
560
def test_custom_tools_list(self, mock_session_deps):
561
s = _session(mock_session_deps)