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, 22:15 UTC
fix: accept string | string[] for connectedAccounts, coerce to array
Non-breaking: existing callers passing a single string per toolkit continue to work. The string is silently coerced to a single-element array to match the v3.1 wire format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Abir Taheer committed
May 6, 2026 at 22:57 UTC
bd36c57aaf9c837f17af0d927846d02938b3029c
4 files changed
+22
-11
.changeset/v31-connected-accounts-array.md
+2
-2
@@ -2,6 +2,6 @@
2
'@composio/core': minor
3
---
4
5
-Update `connectedAccounts` from `Record<string, string>` to `Record<string, string[]>`.
5
+`connectedAccounts` now accepts both `string` and `string[]` per toolkit.
6
7
-Matches the v3.1 API where each toolkit maps to an array of connected account IDs. Only one account per toolkit is allowed when multi-account mode is disabled. Bumps `@composio/client` to `0.1.0-alpha.70`.
7
+A single string is automatically coerced to an array to match the v3.1 API wire format. Existing callers passing `{ gmail: "ca_xxx" }` continue to work without changes. Only one account per toolkit is allowed when multi-account mode is disabled. Bumps `@composio/client` to `0.1.0-alpha.70`.
python/composio/core/models/tool_router.py
+8
-4
@@ -537,7 +537,7 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
537
t.Union[bool, ToolRouterManageConnectionsConfig]
538
] = None,
539
auth_configs: t.Optional[t.Dict[str, str]] = None,
540
- connected_accounts: t.Optional[t.Dict[str, t.List[str]]] = None,
540
+ connected_accounts: t.Optional[t.Dict[str, t.Union[str, t.List[str]]]] = None,
541
workbench: t.Optional[ToolRouterWorkbenchConfig] = None,
542
multi_account: t.Optional[ToolRouterMultiAccountConfig] = None,
543
preload: t.Optional[ToolRouterPreloadConfig] = None,
@@ -596,10 +596,11 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
596
Example: {'enable': True, 'callback_url': 'https://example.com/callback', 'wait_for_connections': True}
597
:param auth_configs: Optional mapping of toolkit slug to auth config ID.
598
Example: {'github': 'ac_xxx', 'slack': 'ac_yyy'}
599
- :param connected_accounts: Optional mapping of toolkit slug to connected account IDs.
599
+ :param connected_accounts: Optional mapping of toolkit slug to connected account ID(s).
600
+ Accepts a single string or a list of strings per toolkit.
601
Only one account per toolkit is allowed when multi-account
602
mode is disabled.
602
- Example: {'github': ['ca_xxx'], 'slack': ['ca_yyy']}
603
+ Example: {'github': 'ca_xxx', 'slack': ['ca_yyy']}
604
:param workbench: Optional workbench configuration. Dict with:
605
- 'enable' (bool): Whether to enable the workbench entirely.
606
Defaults to True. When set to False, no code execution tools
@@ -831,7 +832,10 @@ class ToolRouter(Resource, t.Generic[TTool, TToolCollection]):
832
create_params["auth_configs"] = auth_configs
833
834
if connected_accounts is not None:
834
- create_params["connected_accounts"] = connected_accounts
835
+ create_params["connected_accounts"] = {
836
+ k: [v] if isinstance(v, str) else v
837
+ for k, v in connected_accounts.items()
838
+ }
839
840
if toolkits_payload is not None:
841
create_params["toolkits"] = toolkits_payload
ts/packages/core/src/types/toolRouter.types.ts
+9
-2
@@ -202,9 +202,16 @@ const ToolRouterCreateSessionConfigBaseSchema = z
202
)
203
.default({}),
204
connectedAccounts: z
205
- .record(z.string(), z.array(z.string()))
205
+ .record(z.string(), z.union([z.string(), z.array(z.string())]))
206
+ .transform((rec) => {
207
+ const out: Record<string, string[]> = {};
208
+ for (const [k, v] of Object.entries(rec)) {
209
+ out[k] = typeof v === 'string' ? [v] : v;
210
+ }
211
+ return out;
212
+ })
213
.describe(
207
- 'The connected accounts to use in the tool router session. The key is the toolkit slug, the value is an array of connected account ids. Only one account per toolkit is allowed when multi-account mode is disabled.'
214
+ 'The connected accounts to use in the tool router session. The key is the toolkit slug, the value is a connected account id or an array of ids. Only one account per toolkit is allowed when multi-account mode is disabled.'
215
)
216
.default({}),
217
manageConnections: z
ts/packages/core/test/models/toolRouter.test.ts
+3
-3
@@ -1031,12 +1031,12 @@ describe('ToolRouter', () => {
1031
});
1032
});
1033
1034
- it('should create a session with connectedAccounts', async () => {
1034
+ it('should create a session with connectedAccounts (string coerced to array)', async () => {
1035
mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
1036
1037
const config: ToolRouterCreateSessionConfig = {
1038
connectedAccounts: {
1039
- gmail: ['conn_123'],
1039
+ gmail: 'conn_123',
1040
slack: ['conn_456'],
1041
},
1042
};
@@ -1066,7 +1066,7 @@ describe('ToolRouter', () => {
1066
gmail: 'auth_config_123',
1067
},
1068
connectedAccounts: {
1069
- slack: ['conn_456'],
1069
+ slack: 'conn_456',
1070
},
1071
};
1072