@devries-cameron20 / composio Mirror · read-only / commits / b3f587540
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, 14:30 UTC

Fix multi connected in initiate not respecting inactive accounts (#2429)

Musthaq Ahamad committed Jan 21, 2026 at 11:53 UTC b3f58754090628068809599c323a9b15749a900c
32 files changed +215 -28
.changeset/tame-impalas-taste.md new
+5
@@ -0,0 +1,5 @@
1 +---
2 +'@composio/core': patch
3 +---
4 +
5 +Fix multi connected account flag to check only active accounts
.cursor/commands/changelog.md new
+68
@@ -0,0 +1,68 @@
1 +Check the changes between the current branch and next branch, and create a changelog file inside `/fern/pages/src/changelog` in the file format of `MM-DD-YY-<title>.md`.
2 +
3 +## Changelog File Structure
4 +
5 +### Required Sections
6 +
7 +1. **Title** (H1): A clear, descriptive title of the change
8 +2. **Version Information**: Include SDK versions for both TypeScript and Python
9 +3. **Description**: Brief explanation of what changed and why
10 +
11 +### Version Information Format
12 +
13 +```markdown
14 +## Version Information
15 +
16 +### TypeScript/JavaScript
17 +- Package: `@composio/core` (and provider packages if applicable)
18 +- Version: `X.Y.Z`+
19 +
20 +### Python
21 +- Package: `composio` (and provider packages if applicable)
22 +- Version: `X.Y.Z`+
23 +```
24 +
25 +Use `+` suffix to indicate "this version and later".
26 +
27 +### Optional Sections (include as needed)
28 +
29 +- **What Changed**: Before/after comparison with code examples
30 +- **Why This Change?**: Explanation of the motivation
31 +- **New Features/Capabilities**: For feature additions
32 +- **Migration Guide**: For breaking changes
33 +- **Backward Compatibility**: Compatibility notes
34 +- **Impact Summary**: Table showing breaking changes and migration requirements
35 +- **How to Update**: Package manager commands for updating
36 +
37 +### Alerts
38 +
39 +Use these MDX components for important notices:
40 +- `<Warning>` for breaking changes
41 +- `<Note>` for important information
42 +
43 +### Code Examples
44 +
45 +Use `<CodeBlocks>` for side-by-side Python/TypeScript examples:
46 +
47 +```markdown
48 +<CodeBlocks>
49 +```python title="Python SDK"
50 +# Python code
51 +```
52 +
53 +```typescript title="TypeScript SDK"
54 +// TypeScript code
55 +```
56 +</CodeBlocks>
57 +```
58 +
59 +## Examples
60 +
61 +- Bug fix: `01-21-26-initiate-active-status-filter.md`
62 +- Breaking change: `01-14-26-auth-config-patch-semantics.md`
63 +- New feature: `01-12-26-tool-router-improvements.md`
64 +- Simple change: `01-09-26.md`
65 +
66 +## Instructions
67 +- Avoid using emojies in top level, it's okay within code samples only when necessary
68 +
fern/pages/src/changelog/01-21-26-initiate-active-status-filter.md new
+44
@@ -0,0 +1,44 @@
1 +# Connected Account Initiate Now Filters by ACTIVE Status
2 +
3 +## Version Information
4 +
5 +### TypeScript/JavaScript
6 +- Package: `@composio/core`
7 +- Version: `0.5.4`+
8 +
9 +### Python
10 +- Package: `composio`
11 +- Version: `0.10.9`+
12 +
13 +---
14 +
15 +The `initiate()` method now only considers ACTIVE connected accounts when checking for duplicates. Previously, expired or inactive accounts would incorrectly trigger the multiple accounts error.
16 +
17 +## What Changed
18 +
19 +When calling `connectedAccounts.initiate()`, the SDK now filters by `statuses: ["ACTIVE"]` when checking for existing accounts. This prevents expired or inactive accounts from blocking new connection creation.
20 +
21 +### Before (Bug)
22 +
23 +```typescript
24 +// Expired accounts would incorrectly trigger ComposioMultipleConnectedAccountsError
25 +await composio.connectedAccounts.initiate(userId, authConfigId);
26 +// ❌ Error: Multiple connected accounts found (even if they're all expired)
27 +```
28 +
29 +### After (Fixed)
30 +
31 +```typescript
32 +// Only ACTIVE accounts are considered
33 +await composio.connectedAccounts.initiate(userId, authConfigId);
34 +// ✅ Works - expired/inactive accounts are ignored
35 +```
36 +
37 +## Affected SDKs
38 +
39 +- **TypeScript**: `@composio/core`
40 +- **Python**: `composio`
41 +
42 +## Backward Compatibility
43 +
44 +This is a bug fix with no breaking changes. The behavior now matches the expected intent of the multiple accounts check.
python/composio/core/models/connected_accounts.py
+1 -2
@@ -363,8 +363,7 @@ class ConnectedAccounts:
363 """
364 # Check if there are multiple connected accounts for the authConfig of the user
365 connected_accounts = self.list(
366 - user_ids=[user_id],
367 - auth_config_ids=[auth_config_id],
366 + user_ids=[user_id], auth_config_ids=[auth_config_id], statuses=["ACTIVE"]
367 )
368 if connected_accounts.items and not allow_multiple:
369 raise exceptions.ComposioMultipleConnectedAccountsError(
python/providers/anthropic/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-anthropic"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your Anthropic LLMs."
5 readme = "README.md"
6 requires-python = ">=3.10,<4"
python/providers/anthropic/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_anthropic",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Anthropic LLMs.",
python/providers/autogen/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-autogen"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your autogen agent."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/autogen/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_autogen",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Autogen agent.",
python/providers/claude_agent_sdk/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-claude-agent-sdk"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with Claude Code Agents SDK."
5 readme = "README.md"
6 requires-python = ">=3.10,<4"
python/providers/claude_agent_sdk/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9 setup(
10 name="composio_claude_agent_sdk",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get array of tools for Claude Agent SDK",
python/providers/crewai/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-crewai"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your CrewAI agent."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/crewai/setup.py
+1 -1
@@ -6,7 +6,7 @@ from setuptools import setup
6
7 setup(
8 name="composio_crewai",
9 - version="0.10.8",
9 + version="0.10.9",
10 author="Composio",
11 author_email="tech@composio.dev",
12 description="Use Composio to get an array of tools with your CrewAI agent.",
python/providers/gemini/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-gemini"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your Gemini agent."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/gemini/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_gemini",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Gemini agent.",
python/providers/google/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-google"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/google/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_google",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/google_adk/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-google-adk"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/google_adk/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_google_adk",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/langchain/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-langchain"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your Langchain agent."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/langchain/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_langchain",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your Langchain agent.",
python/providers/langgraph/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-langgraph"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get array of tools with LangGraph Agent Workflows."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/langgraph/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_langgraph",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get array of tools with LangGraph Agent Workflows",
python/providers/llamaindex/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-llamaindex"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get array of tools with LlamaIndex Agent Workflows."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/llamaindex/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_llamaindex",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get array of tools with LlamaIndex Agent Workflows",
python/providers/openai/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-openai"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get an array of tools with your OpenAI Function Call."
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/openai/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9 setup(
10 name="composio_openai",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get an array of tools with your OpenAI Function Call.",
python/providers/openai_agents/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-openai-agents"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "Use Composio to get array of strongly typed tools for OpenAI Agents"
5 readme = "README.md"
6 requires-python = ">=3.9,<4"
python/providers/openai_agents/setup.py
+1 -1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9 setup(
10 name="composio_openai_agents",
11 - version="0.10.8",
11 + version="0.10.9",
12 author="Composio",
13 author_email="tech@composio.dev",
14 description="Use Composio to get array of strongly typed tools for OpenAI Agents",
python/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio"
3 -version = "0.10.8"
3 +version = "0.10.9"
4 description = "SDK for integrating Composio with your applications."
5 readme = "README.md"
6 requires-python = ">=3.10,<4"
python/tests/test_connected_accounts.py
+25 -1
@@ -183,6 +183,30 @@ class TestConnectedAccounts:
183 user_id="user-1", auth_config_id="auth-1", allow_multiple=False
184 )
185
186 + def test_initiate_filters_by_active_status_when_checking_existing_accounts(
187 + self, connected_accounts, mock_client
188 + ):
189 + """
190 + Test that initiate only considers ACTIVE accounts when checking for duplicates.
191 + This ensures expired or inactive accounts don't block new connection creation.
192 + """
193 + mock_accounts = Mock()
194 + mock_accounts.items = []
195 + mock_client.connected_accounts.list.return_value = mock_accounts
196 +
197 + mock_response = Mock()
198 + mock_response.id = "conn-123"
199 + mock_response.connection_data.val.status = "PENDING"
200 + mock_response.connection_data.val.redirect_url = "https://redirect"
201 + mock_client.connected_accounts.create.return_value = mock_response
202 +
203 + connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
204 +
205 + # Verify that list is called with statuses=["ACTIVE"] to filter only active accounts
206 + mock_client.connected_accounts.list.assert_called_once_with(
207 + user_ids=["user-1"], auth_config_ids=["auth-1"], statuses=["ACTIVE"]
208 + )
209 +
210 def test_initiate_warns_and_creates_when_allow_multiple(
211 self, connected_accounts, mock_client, caplog
212 ):
@@ -211,7 +235,7 @@ class TestConnectedAccounts:
235 )
236
237 mock_client.connected_accounts.list.assert_called_once_with(
214 - user_ids=["user-1"], auth_config_ids=["auth-1"]
238 + user_ids=["user-1"], auth_config_ids=["auth-1"], statuses=["ACTIVE"]
239 )
240 call_kwargs = mock_client.connected_accounts.create.call_args.kwargs
241 assert call_kwargs["auth_config"] == {"id": "auth-1"}
ts/packages/core/src/models/ConnectedAccounts.ts
+1
@@ -161,6 +161,7 @@ export class ConnectedAccounts {
161 const connectedAccount = await this.list({
162 userIds: [userId],
163 authConfigIds: [authConfigId],
164 + statuses: [ConnectedAccountStatuses.ACTIVE],
165 });
166 if (connectedAccount.items.length > 0 && !options?.allowMultiple) {
167 throw new ComposioMultipleConnectedAccountsError(
ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
+46
@@ -113,6 +113,15 @@ describe('ConnectedAccounts', () => {
113
114 const connectionRequest = await connectedAccounts.initiate(userId, authConfigId, options);
115
116 + // Verify list is called with ACTIVE status filter
117 + expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(
118 + expect.objectContaining({
119 + user_ids: [userId],
120 + auth_config_ids: [authConfigId],
121 + statuses: [ConnectedAccountStatuses.ACTIVE],
122 + })
123 + );
124 +
125 expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({
126 auth_config: {
127 id: authConfigId,
@@ -226,6 +235,43 @@ describe('ConnectedAccounts', () => {
235 );
236 });
237
238 + it('should filter by ACTIVE status when checking for existing accounts', async () => {
239 + const userId = 'user_123';
240 + const authConfigId = 'auth_config_123';
241 +
242 + // Mock list response to return empty list (no ACTIVE accounts)
243 + extendedMockClient.connectedAccounts.list.mockResolvedValueOnce({
244 + items: [],
245 + next_cursor: null,
246 + total_pages: 1,
247 + });
248 +
249 + const mockResponse = {
250 + id: 'conn_123',
251 + connectionData: {
252 + val: {
253 + authScheme: AuthSchemeTypes.OAUTH2,
254 + status: 'INITIALIZING',
255 + redirectUrl: 'https://auth.example.com/connect',
256 + },
257 + },
258 + };
259 +
260 + extendedMockClient.connectedAccounts.create.mockResolvedValueOnce(mockResponse);
261 +
262 + await connectedAccounts.initiate(userId, authConfigId);
263 +
264 + // Verify that list is called with statuses filter set to ACTIVE only
265 + // This ensures expired/inactive accounts don't block new connection creation
266 + expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(
267 + expect.objectContaining({
268 + user_ids: [userId],
269 + auth_config_ids: [authConfigId],
270 + statuses: [ConnectedAccountStatuses.ACTIVE],
271 + })
272 + );
273 + });
274 +
275 it('should allow multiple accounts when allowMultiple is true', async () => {
276 const userId = 'user_123';
277 const authConfigId = 'auth_config_123';