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 21, 09:45 UTC
test: cover the proxyExecute session option against the live API
jkomyno committed
Oct 13, 2026 at 18:45 UTC
ede453aea2a66bbdaa0e235bfe51c948f3e6be3a
9 files changed
+304
pnpm-lock.yaml
+10
@@ -553,6 +553,16 @@ importers:
553
specifier: workspace:*
554
version: link:../../../_utils
555
556
+ ts/e2e-tests/runtimes/node/tool-router-proxy-execute:
557
+ dependencies:
558
+ '@composio/core':
559
+ specifier: workspace:*
560
+ version: link:../../../../packages/core
561
+ devDependencies:
562
+ '@e2e-tests/utils':
563
+ specifier: workspace:*
564
+ version: link:../../../_utils
565
+
566
ts/e2e-tests/runtimes/node/tool-router-session-update:
567
dependencies:
568
'@composio/core':
python/composio/integration_test/README.md
+1
@@ -29,6 +29,7 @@ uv run pytest composio/integration_test/ -v
29
- **`test_mcp.py`** - MCP (Model Context Protocol) functionality tests
30
- **`test_tool_router.py`** - ToolRouter experimental feature tests
31
- **`test_tool_router_session_update.py`** - `session.update()` with default options against the live API
32
+- **`test_tool_router_session_proxy_execute.py`** - the `proxy_execute` session option against the live API
33
34
## Requirements
35
python/composio/integration_test/test_tool_router_session_proxy_execute.py
new
+64
@@ -0,0 +1,64 @@
1
+"""
2
+Live test for the ``proxy_execute`` session option.
3
+
4
+Unit tests mock the transport, so they cannot tell whether the API accepts
5
+the ``proxy_execute`` block, stores it, or lists the ``COMPOSIO_PROXY_EXECUTE``
6
+meta tool. This test sends the real requests.
7
+"""
8
+
9
+import time
10
+
11
+import pytest
12
+
13
+META_TOOL = "COMPOSIO_PROXY_EXECUTE"
14
+
15
+
16
+def _enable_of(config):
17
+ block = getattr(config, "proxy_execute", None)
18
+ return None if block is None else block.enable
19
+
20
+
21
+def _lists_meta_tool(session) -> bool:
22
+ return META_TOOL in {tool["function"]["name"] for tool in session.tools()}
23
+
24
+
25
+@pytest.mark.integration
26
+def test_proxy_execute_option_round_trip(composio_client):
27
+ user_id = f"pytest-session-proxy-execute-{int(time.time())}"
28
+ sessions = []
29
+ try:
30
+ on = composio_client.sessions.create(
31
+ user_id=user_id, toolkits=["github"], proxy_execute=True
32
+ )
33
+ sessions.append(on)
34
+ assert _enable_of(on.config) is True
35
+ assert _lists_meta_tool(on)
36
+
37
+ assert _enable_of(on.update(proxy_execute=False)) is False
38
+ assert not _lists_meta_tool(on)
39
+
40
+ assert _enable_of(on.update(proxy_execute={"enable": True})) is True
41
+ assert _enable_of(on.update(proxy_execute=None)) is None
42
+ reread = composio_client.sessions.use(session_id=on.session_id)
43
+ assert _enable_of(reread.config) is None
44
+
45
+ off = composio_client.sessions.create(user_id=user_id, toolkits=["github"])
46
+ sessions.append(off)
47
+ assert _enable_of(off.config) is None
48
+ assert not _lists_meta_tool(off)
49
+ finally:
50
+ for session in sessions:
51
+ composio_client.sessions.delete(session.session_id)
52
+
53
+
54
+@pytest.mark.integration
55
+def test_proxy_execute_false_conflicts_with_sandbox_helper(composio_client):
56
+ user_id = f"pytest-session-proxy-execute-conflict-{int(time.time())}"
57
+ with pytest.raises(Exception): # noqa: B017 - the API returns a 400
58
+ session = composio_client.sessions.create(
59
+ user_id=user_id,
60
+ toolkits=["github"],
61
+ proxy_execute=False,
62
+ sandbox={"enable_proxy_execution": True},
63
+ )
64
+ composio_client.sessions.delete(session.session_id)
ts/e2e-tests/README.md
+1
@@ -36,6 +36,7 @@ ts/e2e-tests/
36
│ ├── openai-zod4-compat/ # OpenAI + Zod v4 compatibility tests
37
│ ├── tool-router-files/ # Tool Router session files (list, upload, download, delete)
38
│ ├── tool-router-pagination/ # Tool Router session.toolkits() cursor pagination
39
+ │ ├── tool-router-proxy-execute/ # Tool Router proxyExecute session option (live API)
40
│ ├── tool-router-session-update/ # Tool Router session.update() with default options (live API)
41
│ └── typescript-mjs-import-nodenext/ # TypeScript moduleResolution: nodenext tests
42
└── cloudflare/ # Cloudflare runtime tests
ts/e2e-tests/runtimes/node/tool-router-proxy-execute/README.md
new
+30
@@ -0,0 +1,30 @@
1
+# Tool Router Proxy Execute Option E2E Test
2
+
3
+End-to-end test for the `proxyExecute` session option on `sessions.create()` and `session.update()`.
4
+
5
+## Prerequisites
6
+
7
+- Docker (for running tests in containers)
8
+- `COMPOSIO_API_KEY` environment variable (any Composio project works)
9
+- `COMPOSIO_BASE_URL` (optional) to target a non-production backend
10
+
11
+## Running
12
+
13
+```bash
14
+# From repo root
15
+COMPOSIO_API_KEY=your_key pnpm test:e2e:node --filter=@e2e-tests/node-tool-router-proxy-execute
16
+
17
+# Or from this directory
18
+COMPOSIO_API_KEY=your_key bun test e2e.test.ts
19
+```
20
+
21
+## What it tests
22
+
23
+Unit tests mock the transport, so they cannot tell whether the API accepts the `proxy_execute` block, stores it, or lists the `COMPOSIO_PROXY_EXECUTE` meta tool. This suite sends the real requests.
24
+
25
+1. **Create on** – `sessions.create(userId, { proxyExecute: true })` stores `{ enable: true }` and `session.tools()` lists `COMPOSIO_PROXY_EXECUTE`
26
+2. **Update off** – `session.update({ proxyExecute: false })` stores `{ enable: false }` and the tool is no longer listed
27
+3. **Update block, then remove** – `session.update({ proxyExecute: { enable: true } })` stores the block; `session.update({ proxyExecute: null })` removes it
28
+4. **Default** – `sessions.create(userId)` leaves `proxy_execute` unset and does not list the tool
29
+5. **Conflict** – `proxyExecute: false` with `sandbox: { enableProxyExecution: true }` is rejected at creation
30
+6. **Cleanup** – Delete the sessions
ts/e2e-tests/runtimes/node/tool-router-proxy-execute/e2e.test.ts
new
+69
@@ -0,0 +1,69 @@
1
+/**
2
+ * Tool Router proxyExecute session option E2E test.
3
+ *
4
+ * Unit tests mock the transport, so they cannot tell whether the API accepts
5
+ * the proxy_execute block, stores it, or lists the COMPOSIO_PROXY_EXECUTE meta
6
+ * tool. This test sends the real requests.
7
+ *
8
+ * Project-agnostic: creates its own sessions and deletes them afterwards.
9
+ *
10
+ * Requires COMPOSIO_API_KEY in environment.
11
+ */
12
+
13
+import { e2e, type E2ETestResult } from '@e2e-tests/utils';
14
+import { describe, it, expect, beforeAll } from 'bun:test';
15
+
16
+declare module 'bun' {
17
+ interface Env {
18
+ COMPOSIO_API_KEY: string;
19
+ }
20
+}
21
+
22
+e2e(import.meta.url, {
23
+ versions: { node: ['current'] },
24
+ usesFixtures: true,
25
+ env: {
26
+ COMPOSIO_API_KEY: Bun.env.COMPOSIO_API_KEY,
27
+ },
28
+ defineTests: ({ runFixture }) => {
29
+ let result: E2ETestResult;
30
+
31
+ beforeAll(async () => {
32
+ result = await runFixture({ filename: 'index.mjs' });
33
+ }, 180_000);
34
+
35
+ describe('proxyExecute session option', () => {
36
+ it('exits successfully', () => {
37
+ expect(result.exitCode).toBe(0);
38
+ });
39
+
40
+ it('create(true) stores the block and lists the meta tool', () => {
41
+ expect(result.stdout).toContain('CREATE_ON_OK');
42
+ });
43
+
44
+ it('update(false) stores the block and hides the meta tool', () => {
45
+ expect(result.stdout).toContain('UPDATE_OFF_OK');
46
+ });
47
+
48
+ it('update with the block form, then null removes it', () => {
49
+ expect(result.stdout).toContain('UPDATE_NULL_OK');
50
+ });
51
+
52
+ it('create() leaves the option unset', () => {
53
+ expect(result.stdout).toContain('DEFAULT_OK');
54
+ });
55
+
56
+ it('rejects false together with sandbox.enableProxyExecution', () => {
57
+ expect(result.stdout).toContain('CONFLICT_REJECTED_OK');
58
+ });
59
+
60
+ it('deletes the sessions', () => {
61
+ expect(result.stdout).toContain('DELETE_OK');
62
+ });
63
+
64
+ it('all operations complete', () => {
65
+ expect(result.stdout).toContain('ALL_OK');
66
+ });
67
+ });
68
+ },
69
+});
ts/e2e-tests/runtimes/node/tool-router-proxy-execute/fixtures/index.mjs
new
+100
@@ -0,0 +1,100 @@
1
+/**
2
+ * E2E fixture: the proxyExecute session option against the live API.
3
+ *
4
+ * Covers sessions.create() and session.update() with the boolean shorthand,
5
+ * the { enable } block, and null, and checks what the session lists.
6
+ *
7
+ * Requires COMPOSIO_API_KEY in environment.
8
+ */
9
+import { Composio } from '@composio/core';
10
+
11
+const apiKey = process.env.COMPOSIO_API_KEY;
12
+if (!apiKey) {
13
+ console.error('COMPOSIO_API_KEY is required');
14
+ process.exit(1);
15
+}
16
+
17
+const composio = new Composio({ apiKey });
18
+const META_TOOL = 'COMPOSIO_PROXY_EXECUTE';
19
+
20
+const toolNames = async session => (await session.tools()).map(tool => tool.function.name);
21
+const enableOf = config => config.proxy_execute?.enable;
22
+
23
+const expectEnable = (label, config, expected) => {
24
+ const actual = enableOf(config);
25
+ if (actual !== expected) {
26
+ throw new Error(`${label}: proxy_execute.enable is ${actual}, expected ${expected}`);
27
+ }
28
+};
29
+
30
+const expectListed = async (label, session, expected) => {
31
+ const names = await toolNames(session);
32
+ if (names.includes(META_TOOL) !== expected) {
33
+ throw new Error(
34
+ `${label}: ${META_TOOL} ${expected ? 'missing from' : 'present in'} ${names.join(',')}`
35
+ );
36
+ }
37
+};
38
+
39
+async function main() {
40
+ const userId = `e2e-tool-router-proxy-execute-${Date.now()}`;
41
+ const sessions = [];
42
+
43
+ try {
44
+ const on = await composio.sessions.create(userId, { toolkits: ['github'], proxyExecute: true });
45
+ sessions.push(on);
46
+ expectEnable('create(true)', on.config, true);
47
+ await expectListed('create(true)', on, true);
48
+ console.log('CREATE_ON_OK');
49
+
50
+ expectEnable('update(false)', await on.update({ proxyExecute: false }), false);
51
+ await expectListed('update(false)', on, false);
52
+ console.log('UPDATE_OFF_OK');
53
+
54
+ expectEnable(
55
+ 'update({ enable: true })',
56
+ await on.update({ proxyExecute: { enable: true } }),
57
+ true
58
+ );
59
+ expectEnable('update(null)', await on.update({ proxyExecute: null }), undefined);
60
+ const reread = await composio.sessions.use(on.sessionId);
61
+ expectEnable('use() after update(null)', reread.config, undefined);
62
+ console.log('UPDATE_NULL_OK');
63
+
64
+ const off = await composio.sessions.create(userId, { toolkits: ['github'] });
65
+ sessions.push(off);
66
+ expectEnable('create()', off.config, undefined);
67
+ await expectListed('create()', off, false);
68
+ console.log('DEFAULT_OK');
69
+
70
+ let rejected = false;
71
+ try {
72
+ const conflict = await composio.sessions.create(userId, {
73
+ toolkits: ['github'],
74
+ proxyExecute: false,
75
+ sandbox: { enableProxyExecution: true },
76
+ });
77
+ sessions.push(conflict);
78
+ } catch {
79
+ rejected = true;
80
+ }
81
+ if (!rejected) {
82
+ throw new Error(
83
+ 'create(false + sandbox.enableProxyExecution) was accepted, expected a rejection'
84
+ );
85
+ }
86
+ console.log('CONFLICT_REJECTED_OK');
87
+ } finally {
88
+ for (const session of sessions) {
89
+ await composio.sessions.delete(session.sessionId);
90
+ }
91
+ console.log('DELETE_OK');
92
+ }
93
+
94
+ console.log('ALL_OK');
95
+}
96
+
97
+main().catch(err => {
98
+ console.log('ERROR:', err?.message || err);
99
+ process.exit(1);
100
+});
ts/e2e-tests/runtimes/node/tool-router-proxy-execute/package.json
new
+17
@@ -0,0 +1,17 @@
1
+{
2
+ "name": "@e2e-tests/node-tool-router-proxy-execute",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc --noEmit",
8
+ "test:e2e": "bun test e2e.test.ts",
9
+ "test:e2e:node": "bun test e2e.test.ts"
10
+ },
11
+ "dependencies": {
12
+ "@composio/core": "workspace:*"
13
+ },
14
+ "devDependencies": {
15
+ "@e2e-tests/utils": "workspace:*"
16
+ }
17
+}
ts/e2e-tests/runtimes/node/tool-router-proxy-execute/tsconfig.json
new
+12
@@ -0,0 +1,12 @@
1
+{
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "es2022",
5
+ "module": "esnext",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "noEmit": true
10
+ },
11
+ "include": ["e2e.test.ts"]
12
+}