@devries-cameron20 / composio Mirror · read-only / commits / 7b1840645
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 00:45 UTC

fix: address bugbot feedback — empty params guard, alias null check, remove docs

- transformToolRouterMultiAccountParams returns undefined when all fields are undefined (avoids sending empty multi_account: {} to API) - initiate() and link() alias checks use != null instead of && for consistency with Python SDK and update() method - Revert docs changes (multi-account docs to be added in follow-up PR) - Add test for empty-object edge case Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Zen Agent <zen@composio.dev>

abir committed Apr 9, 2026 at 06:18 UTC 7b18406450e5379d42beb88242831b353787e5d7
4 files changed +17 -103
docs/content/docs/configuring-sessions.mdx
-100
@@ -165,106 +165,6 @@ When executing a tool, the connected account is selected in this order:
165
166 If a user has multiple connected accounts for a toolkit, the most recently connected one is used.
167
168 -## Multi-account mode
169 -
170 -Allow users to connect multiple accounts for the same toolkit (e.g. personal and work Gmail). When enabled, the session can manage up to `maxAccountsPerToolkit` connections per toolkit.
171 -
172 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
173 -<Tab value="Python">
174 -```python
175 -session = composio.create(
176 - user_id="user_123",
177 - multi_account={
178 - "enable": True,
179 - "max_accounts_per_toolkit": 3,
180 - "require_explicit_selection": True
181 - }
182 -)
183 -```
184 -</Tab>
185 -<Tab value="TypeScript">
186 -```typescript
187 -// @errors: 2353
188 -import { Composio } from '@composio/core';
189 -const composio = new Composio({ apiKey: 'your_api_key' });
190 -// ---cut---
191 -const session = await composio.create("user_123", {
192 - multiAccount: {
193 - enable: true,
194 - maxAccountsPerToolkit: 3,
195 - requireExplicitSelection: true,
196 - },
197 -});
198 -```
199 -</Tab>
200 -</Tabs>
201 -
202 -| Option | Type | Default | Description |
203 -|--------|------|---------|-------------|
204 -| `enable` | `boolean` | org/project default | Enable multi-account mode for this session |
205 -| `maxAccountsPerToolkit` | `number` (2-10) | 5 | Maximum connected accounts per toolkit |
206 -| `requireExplicitSelection` | `boolean` | `false` | Require explicit account selection when multiple accounts are connected |
207 -
208 -### Account aliases
209 -
210 -Set human-readable aliases on connected accounts so users and agents can distinguish between them:
211 -
212 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
213 -<Tab value="Python">
214 -```python
215 -# Set an alias
216 -composio.connected_accounts.update("ca_abc123", alias="work-gmail")
217 -
218 -# Clear an alias
219 -composio.connected_accounts.update("ca_abc123", alias="")
220 -```
221 -</Tab>
222 -<Tab value="TypeScript">
223 -```typescript
224 -// @errors: 2339
225 -import { Composio } from '@composio/core';
226 -const composio = new Composio({ apiKey: 'your_api_key' });
227 -// ---cut---
228 -// Set an alias
229 -await composio.connectedAccounts.update("ca_abc123", { alias: "work-gmail" });
230 -
231 -// Clear an alias
232 -await composio.connectedAccounts.update("ca_abc123", { alias: "" });
233 -```
234 -</Tab>
235 -</Tabs>
236 -
237 -Aliases must be unique per entity and toolkit within a project.
238 -
239 -You can also set an alias at creation time when initiating a new connection:
240 -
241 -<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
242 -<Tab value="Python">
243 -```python
244 -# Set alias when creating a connected account
245 -connection = composio.connected_accounts.initiate(
246 - "user_123",
247 - "auth_config_123",
248 - alias="work-gmail",
249 -)
250 -```
251 -</Tab>
252 -<Tab value="TypeScript">
253 -```typescript
254 -// @errors: 2353
255 -import { Composio } from '@composio/core';
256 -const composio = new Composio({ apiKey: 'your_api_key' });
257 -// ---cut---
258 -// Set alias when creating a connected account
259 -const connection = await composio.connectedAccounts.initiate(
260 - "user_123",
261 - "auth_config_123",
262 - { alias: "work-gmail" },
263 -);
264 -```
265 -</Tab>
266 -</Tabs>
267 -
168 ## Disabling workbench
169
170 By default, sessions include the [workbench](/docs/workbench) — a persistent sandbox that provides `COMPOSIO_REMOTE_WORKBENCH` and `COMPOSIO_REMOTE_BASH_TOOL`. If your use case doesn't need code execution, you can disable it:
ts/packages/core/src/lib/toolRouterParams.ts
+11 -1
@@ -132,11 +132,21 @@ export const transformToolRouterMultiAccountParams = (
132 return undefined;
133 }
134
135 - return {
135 + const transformedParams = {
136 enable: params.enable,
137 max_accounts_per_toolkit: params.maxAccountsPerToolkit,
138 require_explicit_selection: params.requireExplicitSelection,
139 };
140 +
141 + if (
142 + transformedParams.enable === undefined &&
143 + transformedParams.max_accounts_per_toolkit === undefined &&
144 + transformedParams.require_explicit_selection === undefined
145 + ) {
146 + return undefined;
147 + }
148 +
149 + return transformedParams;
150 };
151
152 export const transformToolRouterToolkitsParams = (
ts/packages/core/src/models/ConnectedAccounts.ts
+2 -2
@@ -202,7 +202,7 @@ export class ConnectedAccounts {
202 user_id: userId,
203 state,
204 },
205 - ...(options?.alias && { alias: options.alias }),
205 + ...(options?.alias != null && { alias: options.alias }),
206 // @TODO: This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
207 } as ConnectedAccountCreateParamsRaw);
208
@@ -271,7 +271,7 @@ export class ConnectedAccounts {
271 auth_config_id: authConfigId,
272 user_id: userId,
273 ...(requestOptions?.data.callbackUrl && { callback_url: requestOptions.data.callbackUrl }),
274 - ...(requestOptions?.data.alias && { alias: requestOptions.data.alias }),
274 + ...(requestOptions?.data.alias != null && { alias: requestOptions.data.alias }),
275 });
276
277 const connectionRequest = createConnectionRequest(
ts/packages/core/test/lib/toolRouterParams.test.ts
+4
@@ -7,6 +7,10 @@ describe('transformToolRouterMultiAccountParams', () => {
7 expect(transformToolRouterMultiAccountParams(undefined)).toBeUndefined();
8 });
9
10 + it('should return undefined when all fields are undefined (empty object)', () => {
11 + expect(transformToolRouterMultiAccountParams({})).toBeUndefined();
12 + });
13 +
14 it('should transform enable only', () => {
15 const result = transformToolRouterMultiAccountParams({ enable: true });
16 expect(result).toEqual({