Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(python): preserve backward compat for remote session.execute()
Dhawal Upadhyay35d0af43e1b2
diff --git a/python/composio/core/models/tool_router_session.py b/python/composio/core/models/tool_router_session.pyindex 2c40d7194..b0f4f14ac 100644--- a/python/composio/core/models/tool_router_session.py+++ b/python/composio/core/models/tool_router_session.py@@ -478,8 +478,9 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):full slug (e.g. "LOCAL_GREP"). Custom tools are executed in-process;remote tools are sent to the Composio backend.- Returns a dict with ``data``, ``error``, and ``log_id`` keys for both- local and remote execution paths.+ Local tools return a dict with ``data``, ``error``, ``log_id`` keys.+ Remote tools return the ``SessionExecuteResponse`` model from the client+ (backward-compatible — supports attribute access like ``result.data``)."""# Check if this is a local tool (by original or final slug)entry = find_custom_tool(self._custom_tools_map, tool_slug)@@ -491,17 +492,12 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):"log_id": "",}- # Remote execution — normalize to dict for consistent return type- response = self._client.tool_router.session.execute(+ # Remote execution — return client model as-is for backward compat+ return self._client.tool_router.session.execute(session_id=self.session_id,tool_slug=tool_slug,arguments=arguments if arguments is not None else omit,)- return {- "data": response.data if hasattr(response, "data") else {},- "error": response.error if hasattr(response, "error") else None,- "log_id": response.log_id if hasattr(response, "log_id") else "",- }def custom_tools(self, *, toolkit: t.Optional[str] = Nonediff --git a/python/tests/test_custom_tools.py b/python/tests/test_custom_tools.pyindex c800b78d1..384be531c 100644--- a/python/tests/test_custom_tools.py+++ b/python/tests/test_custom_tools.py@@ -553,10 +553,9 @@ class TestToolRouterSessionCustomTools:s = _session(mock_session_deps)result = s.execute("GMAIL_SEND_EMAIL", arguments={"to": "[email protected]"})mock_session_deps["client"].tool_router.session.execute.assert_called_once()- # Remote returns same dict shape as local- assert isinstance(result, dict)- assert result["data"] == {"sent": True}- assert result["log_id"] == "log_123"+ # Remote returns client model as-is (backward compat, supports attribute access)+ assert result.data == {"sent": True}+ assert result.log_id == "log_123"def test_custom_tools_list(self, mock_session_deps):s = _session(mock_session_deps)