Skip to content

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: add workbench.enable option to disable workbench in session config

Abir Taheer9752d374b40c
diff --git a/python/composio/core/models/tool_router.py b/python/composio/core/models/tool_router.py
index 5769d5359..3935b8dcf 100644
--- a/python/composio/core/models/tool_router.py
+++ b/python/composio/core/models/tool_router.py
@@ -127,11 +127,17 @@ class ToolRouterWorkbenchConfig(te.TypedDict, total=False):
"""Configuration for workbench settings in tool router session.
Attributes:
+ enable: Whether to enable the workbench entirely. Defaults to True.
+ When set to False, no code execution tools
+ (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are
+ available in the session, workbench-related prompt lines are
+ stripped, and direct workbench calls are rejected.
enable_proxy_execution: Whether to allow proxy execute calls in the workbench.
If False, prevents arbitrary HTTP requests.
auto_offload_threshold: Maximum execution payload size to offload to workbench.
"""
+ enable: bool
enable_proxy_execution: bool
auto_offload_threshold: int
@@ -472,10 +478,15 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
Example: {'github': 'ca_xxx', 'slack': 'ca_yyy'}
:param workbench: Optional workbench configuration (ToolRouterWorkbenchConfig).
Dict with:
+ - 'enable' (bool): Whether to enable the workbench entirely.
+ Defaults to True. When set to False, no code execution tools
+ (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are
+ available in the session.
- 'enable_proxy_execution' (bool): Whether to allow proxy execute
calls in the workbench. If False, prevents arbitrary HTTP requests.
- 'auto_offload_threshold' (int): Maximum execution payload size to
offload to workbench.
+ Example: {'enable': False}
Example: {'enable_proxy_execution': False, 'auto_offload_threshold': 300}
:param experimental: Optional experimental configuration (ToolRouterExperimentalConfig).
Note: These features are experimental and may change.
@@ -541,6 +552,14 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
}
)
+ # Create a session with workbench disabled
+ session = tool_router.create(
+ user_id='user_123',
+ workbench={
+ 'enable': False
+ }
+ )
+
# Create a session with workbench config
session = tool_router.create(
user_id='user_123',
@@ -659,7 +678,9 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
create_params["tags"] = tags_payload
if workbench is not None:
- execution_payload: t.Dict[str, t.Any] = {}
+ execution_payload: t.Dict[str, t.Any] = {
+ "enable": workbench.get("enable", True),
+ }
if "enable_proxy_execution" in workbench:
execution_payload["enable_proxy_execution"] = workbench[
"enable_proxy_execution"
diff --git a/python/tests/test_tool_router.py b/python/tests/test_tool_router.py
index f85e7adde..32a5a0ae4 100644
--- a/python/tests/test_tool_router.py
+++ b/python/tests/test_tool_router.py
@@ -508,9 +508,46 @@ class TestToolRouter:
call_args = mock_client.tool_router.session.create.call_args
kwargs = call_args.kwargs
assert "workbench" in kwargs
+ assert kwargs["workbench"]["enable"] is True
assert kwargs["workbench"]["enable_proxy_execution"] is False
assert kwargs["workbench"]["auto_offload_threshold"] == 300
+ def test_create_session_with_workbench_disabled(self, tool_router, mock_client):
+ """Test creating a session with workbench entirely disabled."""
+ session = tool_router.create(
+ user_id="user_123",
+ workbench={"enable": False},
+ )
+
+ assert session.session_id == "session_123"
+
+ call_args = mock_client.tool_router.session.create.call_args
+ kwargs = call_args.kwargs
+ assert "workbench" in kwargs
+ assert kwargs["workbench"]["enable"] is False
+
+ def test_create_session_with_workbench_enabled_and_configured(
+ self, tool_router, mock_client
+ ):
+ """Test creating a session with workbench explicitly enabled and configured."""
+ session = tool_router.create(
+ user_id="user_123",
+ workbench={
+ "enable": True,
+ "enable_proxy_execution": False,
+ "auto_offload_threshold": 20000,
+ },
+ )
+
+ assert session.session_id == "session_123"
+
+ call_args = mock_client.tool_router.session.create.call_args
+ kwargs = call_args.kwargs
+ assert "workbench" in kwargs
+ assert kwargs["workbench"]["enable"] is True
+ assert kwargs["workbench"]["enable_proxy_execution"] is False
+ assert kwargs["workbench"]["auto_offload_threshold"] == 20000
+
def test_create_session_complex_config(self, tool_router, mock_client):
"""Test creating a session with complex configuration."""
session = tool_router.create(
diff --git a/ts/packages/core/src/lib/toolRouterParams.ts b/ts/packages/core/src/lib/toolRouterParams.ts
index 926eafd21..186ff3287 100644
--- a/ts/packages/core/src/lib/toolRouterParams.ts
+++ b/ts/packages/core/src/lib/toolRouterParams.ts
@@ -119,6 +119,7 @@ export const transformToolRouterWorkbenchParams = (
}
return {
+ enable: params.enable ?? true,
enable_proxy_execution: params.enableProxyExecution,
auto_offload_threshold: params.autoOffloadThreshold,
};
diff --git a/ts/packages/core/src/types/toolRouter.types.ts b/ts/packages/core/src/types/toolRouter.types.ts
index 3c875112a..31c3765e0 100644
--- a/ts/packages/core/src/types/toolRouter.types.ts
+++ b/ts/packages/core/src/types/toolRouter.types.ts
@@ -187,6 +187,12 @@ export const ToolRouterCreateSessionConfigSchema = z
),
workbench: z
.object({
+ enable: z
+ .boolean()
+ .default(true)
+ .describe(
+ 'Whether to enable the workbench entirely. Defaults to true. When set to false, no code execution tools (COMPOSIO_REMOTE_WORKBENCH, COMPOSIO_REMOTE_BASH_TOOL) are available in the session.'
+ ),
enableProxyExecution: z
.boolean()
.optional()
@@ -199,7 +205,7 @@ export const ToolRouterCreateSessionConfigSchema = z
),
})
.optional()
- .describe('The execution config for the tool router session'),
+ .describe('The workbench config for the tool router session'),
experimental: z
.object({
assistivePrompt: z
@@ -243,7 +249,8 @@ export const ToolRouterCreateSessionConfigSchema = z
* @param {boolean} [manageConnections.enable] - Whether to use tools to manage connections in the tool router session @default true
* @param {string} [manageConnections.callbackUrl] - The callback url to use in the tool router session
* @param {object} workbench - Workbench configuration for tool execution
- * @param {boolean} [workbench.proxyExecutionEnabled] - Whether to enable proxy execution
+ * @param {boolean} [workbench.enable] - Whether to enable the workbench entirely. Defaults to true. When false, no code execution tools are available.
+ * @param {boolean} [workbench.enableProxyExecution] - Whether to enable proxy execution
* @param {number} [workbench.autoOffloadThreshold] - Auto offload threshold in characters for moving execution to workbench
*/
export type ToolRouterCreateSessionConfig = z.infer<typeof ToolRouterCreateSessionConfigSchema>;
diff --git a/ts/packages/core/test/models/toolRouter.test.ts b/ts/packages/core/test/models/toolRouter.test.ts
index 974135298..df7c03d2e 100644
--- a/ts/packages/core/test/models/toolRouter.test.ts
+++ b/ts/packages/core/test/models/toolRouter.test.ts
@@ -915,6 +915,7 @@ describe('ToolRouter', () => {
tags: undefined,
manage_connections: createExpectedManageConnections(),
workbench: {
+ enable: true,
enable_proxy_execution: true,
auto_offload_threshold: undefined,
},
@@ -941,6 +942,7 @@ describe('ToolRouter', () => {
tags: undefined,
manage_connections: createExpectedManageConnections(),
workbench: {
+ enable: true,
enable_proxy_execution: undefined,
auto_offload_threshold: 1000,
},
@@ -968,13 +970,14 @@ describe('ToolRouter', () => {
tags: undefined,
manage_connections: createExpectedManageConnections(),
workbench: {
+ enable: true,
enable_proxy_execution: true,
auto_offload_threshold: 500,
},
});
});
- it('should create a session with workbench disable', async () => {
+ it('should create a session with workbench proxy and offload disabled', async () => {
mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
const config: ToolRouterCreateSessionConfig = {
@@ -995,11 +998,68 @@ describe('ToolRouter', () => {
tags: undefined,
manage_connections: createExpectedManageConnections(),
workbench: {
+ enable: true,
enable_proxy_execution: false,
auto_offload_threshold: 0,
},
});
});
+
+ it('should create a session with workbench entirely disabled', async () => {
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
+
+ const config: ToolRouterCreateSessionConfig = {
+ workbench: {
+ enable: false,
+ },
+ };
+
+ await toolRouter.create(userId, config);
+
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
+ user_id: userId,
+ toolkits: undefined,
+ auth_configs: undefined,
+ connected_accounts: undefined,
+ tools: undefined,
+ tags: undefined,
+ manage_connections: createExpectedManageConnections(),
+ workbench: {
+ enable: false,
+ enable_proxy_execution: undefined,
+ auto_offload_threshold: undefined,
+ },
+ });
+ });
+
+ it('should create a session with workbench explicitly enabled', async () => {
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
+
+ const config: ToolRouterCreateSessionConfig = {
+ workbench: {
+ enable: true,
+ enableProxyExecution: true,
+ autoOffloadThreshold: 20000,
+ },
+ };
+
+ await toolRouter.create(userId, config);
+
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
+ user_id: userId,
+ toolkits: undefined,
+ auth_configs: undefined,
+ connected_accounts: undefined,
+ tools: undefined,
+ tags: undefined,
+ manage_connections: createExpectedManageConnections(),
+ workbench: {
+ enable: true,
+ enable_proxy_execution: true,
+ auto_offload_threshold: 20000,
+ },
+ });
+ });
});
// describe('complex configuration combinations', () => {