@devries-cameron20 / composio-1 / commits / 5d9a974a0
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: per-action permissions page with verified allow/deny behavior (DEVREL-316) (#5457)

## Problem Agent-preference runs (Gauge) keep recommending Arcade over Composio because agents conclude "Composio enforces permissions per connection, not per action." It was the most frequent Composio objection in the 2026-11-09 head-to-head runs (8 of 20 sessions, then 5 of 8 Arcade-vs-Composio sessions). Sessions do enforce per-tool policy, but no doc page says so, says where the policy is checked, or shows it rejecting a call. [DEVREL-316](https://linear.app/composio/issue/DEVREL-316) ## What changed - New page **Governance → Per-action permissions** (`docs/content/docs/governance/action-permissions.mdx`): - the four permission layers (OAuth scopes, connection ownership, session tool policy, approvals/Firewall) - a runnable allow/deny example in Python, TypeScript, and cURL using Hacker News, which needs no connected account - a table of execution paths and what each does with a blocked tool - what the session policy does **not** cover: direct execution, proxy on unfiltered toolkits and the legacy proxy endpoint, deprecated auth-config tool lists, scoped API keys - error codes - One-line links to it from Configuring sessions (tool filters) and Controlling scopes. - Sidebar and home navigation entries, with the nav tests updated to match. ## Evidence All results come from live calls against an internal test project (`testnoauth`, with no customer data), run on 2026-11-18. For apps that need credentials I used an OpenAI connection with a deliberately invalid key. An allowed call came back with OpenAI's own `invalid_api_key` error, which proves it reached OpenAI. A blocked call came back with a Composio error, which proves it never left Composio. | Path | Blocked tool | Result | |---|---|---| | `POST /tool_router/session/{id}/execute` | not in `enable` list | `400` `4310 ToolRouterV2_ToolNotInEnabledList` | | same | in `disable` list (set via `PATCH` on a live session) | `400` `4311`, effective on the next call | | same | toolkit not in allowlist / in denylist | `4324` / `4325` | | same | `tags.disable: ["destructiveHint"]` | `4328 ToolRouterV2_ToolTagNotAllowed` | | `COMPOSIO_MULTI_EXECUTE_TOOL` | not in `enable` list | per-tool `[Session Restriction]` error, allowed tool in the same batch ran | | sandbox `run_composio_tool()` | not in `enable` list | `4310`. From inside the sandbox, `/api/v3/tools/execute` → `401` "Workbench credentials are not accepted on this endpoint". Another session's execute → `401` | | session MCP URL | not in `enable` list | absent from `tools/list`, `tools/call` → "not found", via multi-execute → `[Session Restriction]` | | `COMPOSIO_SEARCH_TOOLS` | not in `enable` list | left out of results, named as restricted in guidance | | session `proxy_execute` / `COMPOSIO_PROXY_EXECUTE` | toolkit has a tool list or tag filter | `403` `4327 ToolRouterV2_ProxyExecutionDisabled` | | session create, bob pinned to alice's `ca_` | n/a | `400` `4306` | | `/api/v3/tools/execute`, `user_id` bob + alice's `ca_` | n/a | `400` `1812` | | **`/api/v3/tools/execute` (direct)** | tool blocked in sessions | **reached OpenAI** (no session, so no session policy) | | **auth config `tools_available_for_execution` + `restrict_to_following_tools`** | tool outside the list | **reached OpenAI** on both direct and session execution, retried after 90 s | | **legacy `/api/v3/tools/execute/proxy`** | n/a | **forwarded** with only `connected_account_id`. Direct execute requires `user_id` (`1811`) | The page's SDK examples were run as written, swapping only the constructor for user-key auth scoped to the test project: ``` $ python allow_deny.py # composio from this repo completed 400 4310 400 [Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. You cannot execute this tool. $ bun run.ts # @composio/core@0.30.0, the docs pin completed 400 4310 Error executing the tool HACKERNEWS_GET_LATEST_POSTS: [Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. You cannot execute this tool. ``` Local checks from `docs/`: `bun run test` (838 pass, 0 fail), `check:code-examples`, `check:python-snippets`, `check:typescript-snippets`, `scripts/validate-links.ts`, all clean. Production build: see the comment below. ## Details and open questions Not tested: legacy single-toolkit MCP servers (`allowed_tools`). Their endpoint takes only a project API key, and I couldn't mint one for the test project through a public route, so the page makes no claim about them. Questions for product/security, not decided here: 1. **Auth config tool lists.** The API accepts `tool_access_config.tools_available_for_execution` and `restrict_to_following_tools`, stores them, and returns them, but they don't block execution. Is that a bug, or intended because the fields are deprecated? If intended, should the API reject or warn on them instead of silently accepting them? 2. **Direct execution and the legacy proxy** don't apply any tool policy, and the legacy proxy doesn't require `user_id`. Is that the intended contract, given that the project key holder is trusted? The page states it as current behavior. 3. **What to promise publicly.** The page describes observed behavior ("we checked each path"). Is product comfortable with that framing and with publishing the limitations section? 4. Blocked tools on the session MCP URL return "not found" rather than a restriction error. That's minor, but agents may read it as a missing tool. ## ELI5 When you give an AI agent access to someone's Gmail, you can also tell Composio "this agent may only read email, not send it." This page shows that rule being enforced: the "send" call gets refused before it reaches Gmail. It also lists the few places where the rule doesn't apply, so nobody assumes more than is true. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Brendan O'Leary committed Nov 18, 2026 at 10:11 UTC 5d9a974a0032da73eb600e4aa311b29f9d517a23
9 files changed +173 -7
docs/content/docs/authentication/controlling-scopes.mdx
+2
@@ -8,6 +8,8 @@ Scopes are the permissions an OAuth toolkit grants your app: read email, write t
8
9 You control scopes on an [auth config](/docs/authentication#behind-the-scenes), then [pass that auth config to a session](#use-the-auth-config-in-a-session) so the session requests your scopes when users connect.
10
11 +Scopes limit what the app's API allows. To limit which tools an agent can call with those credentials, add tool filters to the session. See [Per-action permissions](/docs/governance/action-permissions).
12 +
13 <Callout type="info">
14 Scopes apply to OAuth toolkits. Toolkits that authenticate with API keys or bearer tokens don't have scopes to set.
15 </Callout>
docs/content/docs/configuring-sessions.mdx
+2
@@ -399,6 +399,8 @@ curl -s -X GET https://backend.composio.dev/api/v3.1/tool_router/session/$SESSIO
399
400 To control which individual tools are available within a toolkit, use the `tools` configuration. The key is the toolkit slug and the value specifies which tools to enable or disable.
401
402 +Composio enforces these filters on every session execution path, including multi-execute, the sandbox, and MCP. See [Per-action permissions](/docs/governance/action-permissions) for allow and deny examples and the paths the filters don't cover.
403 +
404 To enable only specific tools, pass an `enable` list per toolkit:
405
406 <Tabs groupId="language" items={['Python', 'TypeScript', 'API']} persist>
docs/content/docs/extending-sessions/proxy-execute.mdx
+6 -4
@@ -155,14 +155,16 @@ At creation, the API rejects a disabled proxy setting combined with an enabled s
155
156 Proxy execute follows the session's toolkit lists: a call for a toolkit outside `toolkits.enable` or inside `toolkits.disable` is rejected with the same error a blocked tool call gets, including from the session's sandbox.
157
158 -Hint filters and per-toolkit tool rules do not apply, because a proxy request names an endpoint, not a tool. To remove the raw HTTP path from the session's sandbox, turn proxy execution off in the sandbox config:
158 +A proxy request names an endpoint, not a tool, so Composio can't match it against a tool rule. Instead, the session refuses every proxy call for a toolkit that has a tool `enable` or `disable` list, or a hint filter that applies to it, with `403` `ToolRouterV2_ProxyExecutionDisabled`. Toolkits without those filters keep proxy access to any endpoint on their API domain. See [Per-action permissions](/docs/governance/action-permissions).
159 +
160 +To remove the raw HTTP path from the session's sandbox for every toolkit, turn proxy execution off in the sandbox config:
161
162 <Tabs groupId="language" items={['Python', 'TypeScript', 'API']} persist>
163 <Tab value="Python">
164 ```python
165 session = composio.create(
166 user_id="user_123",
165 - tags=["readOnlyHint"],
167 + toolkits=["github"],
168 sandbox={"enable": True, "enable_proxy_execution": False},
169 )
170 ```
@@ -173,7 +175,7 @@ import { Composio } from '@composio/core';
175 const composio = new Composio({ apiKey: 'your_api_key' });
176 // ---cut---
177 const session = await composio.create("user_123", {
176 - tags: ["readOnlyHint"],
178 + toolkits: ["github"],
179 sandbox: { enable: true, enableProxyExecution: false },
180 });
181 ```
@@ -185,7 +187,7 @@ curl -X POST https://backend.composio.dev/api/v3.1/tool_router/session \
187 -H "Content-Type: application/json" \
188 -d '{
189 "user_id": "user_123",
188 - "tags": {"enable": ["readOnlyHint"]},
190 + "toolkits": {"enable": ["github"]},
191 "workbench": {"enable": true, "enable_proxy_execution": false}
192 }'
193 ```
docs/content/docs/governance/action-permissions.mdx new
+150
@@ -0,0 +1,150 @@
1 +---
2 +title: Per-action permissions
3 +description: Restrict which tools an agent can run in each session, and see where Composio enforces that policy
4 +keywords: [per-action permissions, action-level authorization, least privilege, restrict tools per session, tool allowlist, tool denylist, permissions, governance, authorization]
5 +---
6 +
7 +A connected account holds a user's credentials for an app. A session decides which actions an agent can take with those credentials. You set the session's policy with toolkit, tool, and [hint](/docs/governance/tool-hints) filters, and the Composio backend checks it on every Composio tool call made through the session. A tool the policy blocks never reaches the app's API. [Local tools](/docs/extending-sessions/local-tools-and-toolkits) run in your own process and need their own checks.
8 +
9 +Permissions in Composio sit at four layers. Each one answers a different question:
10 +
11 +| Layer | Controls | Where you set it |
12 +| --- | --- | --- |
13 +| [OAuth scopes](/docs/authentication/controlling-scopes) | What the app's API lets the credentials do | Auth config |
14 +| Connected account ownership | Whose credentials a call uses | `user_id` on the session or execution |
15 +| Session tool policy | Which toolkits and tools the agent can run | `toolkits`, `tools`, and `tags` on the session |
16 +| [Approvals](/docs/governance/approvals) and [Firewall](/docs/firewall) | Whether a person or a check signs off on a specific call (both experimental) | `require_approval` and `hooks` on the session |
17 +
18 +Scopes are the only layer the app itself enforces. The other three run in Composio before the request goes out.
19 +
20 +## Allow one tool, deny the rest
21 +
22 +This example uses Hacker News, which needs no connected account, so you can run it with only an API key. The session allows `HACKERNEWS_GET_USER` and nothing else from the toolkit.
23 +
24 +<Tabs groupId="language" items={['Python', 'TypeScript', 'API']} persist>
25 +<Tab value="Python">
26 +```python
27 +from composio import Composio
28 +from composio_client import BadRequestError
29 +
30 +composio = Composio()
31 +
32 +session = composio.create(
33 + user_id="user_123",
34 + toolkits=["hackernews"],
35 + tools={"hackernews": {"enable": ["HACKERNEWS_GET_USER"]}},
36 +)
37 +
38 +allowed = session.execute("HACKERNEWS_GET_USER", arguments={"username": "pg"})
39 +print(allowed.result_type) # completed
40 +
41 +try:
42 + session.execute("HACKERNEWS_GET_LATEST_POSTS", arguments={})
43 +except BadRequestError as error:
44 + print(error.message)
45 + # 400 [Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. ...
46 +```
47 +</Tab>
48 +<Tab value="TypeScript">
49 +```typescript
50 +import { Composio, ComposioToolExecutionError } from '@composio/core';
51 +
52 +const composio = new Composio();
53 +
54 +const session = await composio.create('user_123', {
55 + toolkits: ['hackernews'],
56 + tools: { hackernews: { enable: ['HACKERNEWS_GET_USER'] } },
57 +});
58 +
59 +const allowed = await session.execute('HACKERNEWS_GET_USER', { username: 'pg' });
60 +console.log(allowed.resultType); // completed
61 +
62 +try {
63 + await session.execute('HACKERNEWS_GET_LATEST_POSTS', {});
64 +} catch (error) {
65 + if (!(error instanceof ComposioToolExecutionError)) throw error;
66 + console.log(error.statusCode, error.apiErrorCode); // 400 4310
67 +}
68 +```
69 +</Tab>
70 +<Tab value="API">
71 +```bash
72 +SESSION_ID=$(curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session \
73 + -H "x-api-key: $COMPOSIO_API_KEY" \
74 + -H "Content-Type: application/json" \
75 + -d '{
76 + "user_id": "user_123",
77 + "toolkits": {"enable": ["hackernews"]},
78 + "tools": {"hackernews": {"enable": ["HACKERNEWS_GET_USER"]}}
79 + }' | jq -r '.session_id')
80 +
81 +# Allowed: returns the user's profile
82 +curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/execute \
83 + -H "x-api-key: $COMPOSIO_API_KEY" \
84 + -H "Content-Type: application/json" \
85 + -d '{"tool_slug": "HACKERNEWS_GET_USER", "arguments": {"username": "pg"}}'
86 +
87 +# Denied: HTTP 400 before any request reaches Hacker News
88 +curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/execute \
89 + -H "x-api-key: $COMPOSIO_API_KEY" \
90 + -H "Content-Type: application/json" \
91 + -d '{"tool_slug": "HACKERNEWS_GET_LATEST_POSTS", "arguments": {}}'
92 +```
93 +
94 +The denied call returns:
95 +
96 +```json
97 +{
98 + "error": {
99 + "message": "[Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. You cannot execute this tool.",
100 + "code": 4310,
101 + "slug": "ToolRouterV2_ToolNotInEnabledList",
102 + "status": 400
103 + }
104 +}
105 +```
106 +</Tab>
107 +</Tabs>
108 +
109 +The same policy shape works with `disable` lists, toolkit allowlists, and hint filters such as `tags: { disable: ["destructiveHint"] }`. See [Configuring sessions](/docs/configuring-sessions#enabling-or-disabling-specific-tools) for every option. If you change the policy with `session.update()`, the next call follows the new policy.
110 +
111 +## Where the session policy applies
112 +
113 +We checked each path below against a test project with an allowed and a blocked tool. For apps that need credentials, we used a connection with a deliberately invalid key: an allowed call came back with the app's own "invalid API key" error, so it reached the app, and a blocked call came back with a Composio error, so it never left Composio.
114 +
115 +| Path | Blocked tool |
116 +| --- | --- |
117 +| `session.execute()` and `POST /tool_router/session/{id}/execute` | Rejected with a session restriction error |
118 +| `COMPOSIO_MULTI_EXECUTE_TOOL` | That tool's result carries the session restriction error. Allowed tools in the same batch still run |
119 +| `run_composio_tool()` inside the [sandbox](/docs/sandbox/remote) | Rejected with the same error. Sandbox credentials only work for their own session: calls to the direct execution endpoint or to another session's endpoints return `401` |
120 +| Session MCP URL | Not listed in `tools/list`, so a direct `tools/call` returns `Tool ... not found`. Through `COMPOSIO_MULTI_EXECUTE_TOOL`, it returns the session restriction error |
121 +| `COMPOSIO_SEARCH_TOOLS` | Left out of results. The response tells the agent the tool is restricted |
122 +| `session.proxyExecute()` and `COMPOSIO_PROXY_EXECUTE` | Refused with `403` for any toolkit that has a tool allowlist, denylist, or applicable hint filter, so the proxy can't be used to reach an endpoint whose tool you blocked |
123 +| Tools that need approval | Return `input_required` and don't run until the person answers. Two exceptions: over MCP, a client without elicitation support runs them without asking if you set `no_elicitation_support_fallback` to `"allow"`, and a sandbox script can call a tool the approval check misses. If approval must never be skipped, [disable the sandbox](/docs/configuring-sessions#disabling-the-sandbox). See [Approvals](/docs/governance/approvals) |
124 +
125 +Ownership is checked on both session and direct execution. A session can't be pinned to another user's connected account (`4306`), and a direct execution with a `connected_account_id` that belongs to a different `user_id` fails (`1812`). Which Composio `user_id` a request maps to is still your application's decision. See [Building B2B agents](/docs/b2b-agents) for shared and workspace-owned connections.
126 +
127 +## What the session policy does not cover
128 +
129 +These limits are current behavior. Plan around them.
130 +
131 +- **Direct execution has no session policy.** `composio.tools.execute()` and `POST /api/v3/tools/execute/{tool_slug}` run any tool in the project for the user's connected account. Your backend decides which tools to call on this path. Give agents a session instead of direct execution when you want Composio to enforce a tool policy.
132 +- **Proxy calls on an unfiltered toolkit can reach any endpoint on its domain.** In a session, a toolkit with no tool or hint filters allows proxy calls to any endpoint on that toolkit's API domain. The legacy `POST /api/v3/tools/execute/proxy` takes a connected account ID and never checks a session policy. Use [OAuth scopes](/docs/authentication/controlling-scopes) to bound what the credentials can do at the app.
133 +- **Auth config tool lists don't block execution.** The deprecated `tool_access_config.tools_available_for_execution` and `restrict_to_following_tools` fields are saved and returned, but tools outside them still run on direct and session execution. Set scopes on the auth config and tool filters on the session instead.
134 +- **Local tools run in your process.** SDK [local tools and toolkits](/docs/extending-sessions/local-tools-and-toolkits) run in your application when `session.execute()` calls them, without a backend policy check. Put permission checks in their handlers.
135 +- **Scoped API keys gate endpoints, not tools.** [Project API key permissions](/reference/authenticating-to-composio/project-api-key-permissions) decide whether a key can manage sessions, execute tools, or use the proxy. They don't pick individual tools.
136 +
137 +## Error codes
138 +
139 +| Code | Slug | Cause |
140 +| --- | --- | --- |
141 +| `4310` | `ToolRouterV2_ToolNotInEnabledList` | The tool isn't in the toolkit's `enable` list |
142 +| `4311` | `ToolRouterV2_ToolDisabledInSession` | The tool is in the toolkit's `disable` list |
143 +| `4324` | `ToolRouterV2_ToolkitNotAllowed` | The toolkit isn't in the session's toolkit allowlist |
144 +| `4325` | `ToolRouterV2_ToolkitDisabled` | The toolkit is in the session's toolkit denylist |
145 +| `4328` | `ToolRouterV2_ToolTagNotAllowed` | A hint filter blocks the tool |
146 +| `4327` | `ToolRouterV2_ProxyExecutionDisabled` | Proxy call to a toolkit that has tool or hint filters |
147 +| `4306` | `ToolRouterV2_InvalidConnectedAccountIds` | The session names a connected account that belongs to another user |
148 +| `1812` | `ActionExecute_ConnectedAccountEntityIdMismatch` | Direct execution with a connected account that belongs to another user |
149 +
150 +In TypeScript, read the code from `error.apiErrorCode` on `ComposioToolExecutionError`. In Python, `session.execute()` raises `composio_client.BadRequestError` with `status_code` `400`.
docs/content/docs/governance/meta.json
+1 -1
@@ -1,4 +1,4 @@
1 {
2 "title": "Governance",
3 - "pages": ["tool-hints", "approvals"]
3 + "pages": ["action-permissions", "tool-hints", "approvals"]
4 }
docs/content/docs/meta.json
+1
@@ -20,6 +20,7 @@
20 "triggers",
21 "skills",
22 "---Governance---",
23 + "governance/action-permissions",
24 "governance/tool-hints",
25 "governance/approvals",
26 "firewall",
docs/lib/home-navigation.ts
+2
@@ -131,6 +131,7 @@ export const DOCS_PRODUCTS = {
131 '/docs/apps-and-toolkits',
132 '/docs/configuring-sessions',
133 '/docs/session-configs',
134 + '/docs/governance/action-permissions',
135 '/docs/governance/approvals',
136 '/docs/firewall',
137 '/docs/instant-tools',
@@ -188,6 +189,7 @@ export const DOCS_PRODUCTS = {
189 type: 'group',
190 label: 'Governance',
191 links: [
192 + { url: '/docs/governance/action-permissions' },
193 { url: '/docs/governance/tool-hints' },
194 { url: '/docs/governance/approvals' },
195 { url: '/docs/firewall' },
docs/tests/static/navigation.test.ts
+1
@@ -82,6 +82,7 @@ describe("Navigation - meta.json validity", () => {
82 pages.indexOf("---Guides---")
83 )
84 ).toEqual([
85 + "governance/action-permissions",
86 "governance/tool-hints",
87 "governance/approvals",
88 "firewall",
docs/tests/static/sidebar-nav-index.test.ts
+8 -2
@@ -62,18 +62,24 @@ describe('buildSidebarNavIndex', () => {
62 });
63
64 test('governance guides stay top-level within the Governance section', () => {
65 - expect(index['/docs/governance/tool-hints']).toEqual({
65 + expect(index['/docs/governance/action-permissions']).toEqual({
66 group: 'Governance',
67 folder: null,
68 depth: 1,
69 position: 1,
70 });
71 - expect(index['/docs/governance/approvals']).toEqual({
71 + expect(index['/docs/governance/tool-hints']).toEqual({
72 group: 'Governance',
73 folder: null,
74 depth: 1,
75 position: 2,
76 });
77 + expect(index['/docs/governance/approvals']).toEqual({
78 + group: 'Governance',
79 + folder: null,
80 + depth: 1,
81 + position: 3,
82 + });
83 });
84
85 test('folder index pages resolve to the folder row', () => {