Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Fix multi connected in initiate not respecting inactive accounts (#2429)
Musthaq Ahamadb3f587540906
diff --git a/.changeset/tame-impalas-taste.md b/.changeset/tame-impalas-taste.mdnew file mode 100644index 000000000..c28e2213e--- /dev/null+++ b/.changeset/tame-impalas-taste.md@@ -0,0 +1,5 @@+---+'@composio/core': patch+---++Fix multi connected account flag to check only active accountsdiff --git a/.cursor/commands/changelog.md b/.cursor/commands/changelog.mdnew file mode 100644index 000000000..e8fbcd329--- /dev/null+++ b/.cursor/commands/changelog.md@@ -0,0 +1,68 @@+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`.++## Changelog File Structure++### Required Sections++1. **Title** (H1): A clear, descriptive title of the change+2. **Version Information**: Include SDK versions for both TypeScript and Python+3. **Description**: Brief explanation of what changed and why++### Version Information Format++```markdown+## Version Information++### TypeScript/JavaScript+- Package: `@composio/core` (and provider packages if applicable)+- Version: `X.Y.Z`+++### Python+- Package: `composio` (and provider packages if applicable)+- Version: `X.Y.Z`++```++Use `+` suffix to indicate "this version and later".++### Optional Sections (include as needed)++- **What Changed**: Before/after comparison with code examples+- **Why This Change?**: Explanation of the motivation+- **New Features/Capabilities**: For feature additions+- **Migration Guide**: For breaking changes+- **Backward Compatibility**: Compatibility notes+- **Impact Summary**: Table showing breaking changes and migration requirements+- **How to Update**: Package manager commands for updating++### Alerts++Use these MDX components for important notices:+- `<Warning>` for breaking changes+- `<Note>` for important information++### Code Examples++Use `<CodeBlocks>` for side-by-side Python/TypeScript examples:++```markdown+<CodeBlocks>+```python title="Python SDK"+# Python code+```++```typescript title="TypeScript SDK"+// TypeScript code+```+</CodeBlocks>+```++## Examples++- Bug fix: `01-21-26-initiate-active-status-filter.md`+- Breaking change: `01-14-26-auth-config-patch-semantics.md`+- New feature: `01-12-26-tool-router-improvements.md`+- Simple change: `01-09-26.md`++## Instructions+- Avoid using emojies in top level, it's okay within code samples only when necessary+diff --git a/fern/pages/src/changelog/01-21-26-initiate-active-status-filter.md b/fern/pages/src/changelog/01-21-26-initiate-active-status-filter.mdnew file mode 100644index 000000000..e79767ee8--- /dev/null+++ b/fern/pages/src/changelog/01-21-26-initiate-active-status-filter.md@@ -0,0 +1,44 @@+# Connected Account Initiate Now Filters by ACTIVE Status++## Version Information++### TypeScript/JavaScript+- Package: `@composio/core`+- Version: `0.5.4`+++### Python+- Package: `composio`+- Version: `0.10.9`+++---++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.++## What Changed++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.++### Before (Bug)++```typescript+// Expired accounts would incorrectly trigger ComposioMultipleConnectedAccountsError+await composio.connectedAccounts.initiate(userId, authConfigId);+// ❌ Error: Multiple connected accounts found (even if they're all expired)+```++### After (Fixed)++```typescript+// Only ACTIVE accounts are considered+await composio.connectedAccounts.initiate(userId, authConfigId);+// ✅ Works - expired/inactive accounts are ignored+```++## Affected SDKs++- **TypeScript**: `@composio/core`+- **Python**: `composio`++## Backward Compatibility++This is a bug fix with no breaking changes. The behavior now matches the expected intent of the multiple accounts check.diff --git a/python/composio/core/models/connected_accounts.py b/python/composio/core/models/connected_accounts.pyindex 8f2cb381b..1d5ff80a8 100644--- a/python/composio/core/models/connected_accounts.py+++ b/python/composio/core/models/connected_accounts.py@@ -363,8 +363,7 @@ class ConnectedAccounts:"""# Check if there are multiple connected accounts for the authConfig of the userconnected_accounts = self.list(- user_ids=[user_id],- auth_config_ids=[auth_config_id],+ user_ids=[user_id], auth_config_ids=[auth_config_id], statuses=["ACTIVE"])if connected_accounts.items and not allow_multiple:raise exceptions.ComposioMultipleConnectedAccountsError(diff --git a/python/providers/anthropic/pyproject.toml b/python/providers/anthropic/pyproject.tomlindex 11364567c..780d99788 100644--- a/python/providers/anthropic/pyproject.toml+++ b/python/providers/anthropic/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-anthropic"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your Anthropic LLMs."readme = "README.md"requires-python = ">=3.10,<4"diff --git a/python/providers/anthropic/setup.py b/python/providers/anthropic/setup.pyindex 499c66980..2bcc53a34 100644--- a/python/providers/anthropic/setup.py+++ b/python/providers/anthropic/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_anthropic",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Anthropic LLMs.",diff --git a/python/providers/autogen/pyproject.toml b/python/providers/autogen/pyproject.tomlindex e8b3aa181..67bb6b962 100644--- a/python/providers/autogen/pyproject.toml+++ b/python/providers/autogen/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-autogen"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your autogen agent."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/autogen/setup.py b/python/providers/autogen/setup.pyindex 43c50e0ba..360546698 100644--- a/python/providers/autogen/setup.py+++ b/python/providers/autogen/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_autogen",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Autogen agent.",diff --git a/python/providers/claude_agent_sdk/pyproject.toml b/python/providers/claude_agent_sdk/pyproject.tomlindex 8955278ba..58e0db2db 100644--- a/python/providers/claude_agent_sdk/pyproject.toml+++ b/python/providers/claude_agent_sdk/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-claude-agent-sdk"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with Claude Code Agents SDK."readme = "README.md"requires-python = ">=3.10,<4"diff --git a/python/providers/claude_agent_sdk/setup.py b/python/providers/claude_agent_sdk/setup.pyindex c5b32ba34..c1c14b83a 100644--- a/python/providers/claude_agent_sdk/setup.py+++ b/python/providers/claude_agent_sdk/setup.py@@ -8,7 +8,7 @@ from setuptools import find_packages, setupsetup(name="composio_claude_agent_sdk",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get array of tools for Claude Agent SDK",diff --git a/python/providers/crewai/pyproject.toml b/python/providers/crewai/pyproject.tomlindex 76260c8ed..ffca636fd 100644--- a/python/providers/crewai/pyproject.toml+++ b/python/providers/crewai/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-crewai"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your CrewAI agent."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/crewai/setup.py b/python/providers/crewai/setup.pyindex 6e5421ebf..e2c2693a7 100644--- a/python/providers/crewai/setup.py+++ b/python/providers/crewai/setup.py@@ -6,7 +6,7 @@ from setuptools import setupsetup(name="composio_crewai",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your CrewAI agent.",diff --git a/python/providers/gemini/pyproject.toml b/python/providers/gemini/pyproject.tomlindex 6a021d0a9..7ea43ce5d 100644--- a/python/providers/gemini/pyproject.toml+++ b/python/providers/gemini/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-gemini"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your Gemini agent."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/gemini/setup.py b/python/providers/gemini/setup.pyindex 5f8917c4a..af1bbfef9 100644--- a/python/providers/gemini/setup.py+++ b/python/providers/gemini/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_gemini",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Gemini agent.",diff --git a/python/providers/google/pyproject.toml b/python/providers/google/pyproject.tomlindex ac7dbe4c4..2e95c7924 100644--- a/python/providers/google/pyproject.toml+++ b/python/providers/google/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-google"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your Google AI Python Gemini model."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/google/setup.py b/python/providers/google/setup.pyindex 2019dd665..368f31159 100644--- a/python/providers/google/setup.py+++ b/python/providers/google/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_google",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Google AI Python Gemini model.",diff --git a/python/providers/google_adk/pyproject.toml b/python/providers/google_adk/pyproject.tomlindex acfe38a23..d23857d19 100644--- a/python/providers/google_adk/pyproject.toml+++ b/python/providers/google_adk/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-google-adk"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your Google AI Python Gemini model."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/google_adk/setup.py b/python/providers/google_adk/setup.pyindex 1c3534113..0f9055302 100644--- a/python/providers/google_adk/setup.py+++ b/python/providers/google_adk/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_google_adk",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Google AI Python Gemini model.",diff --git a/python/providers/langchain/pyproject.toml b/python/providers/langchain/pyproject.tomlindex 5ccaac579..afa69695d 100644--- a/python/providers/langchain/pyproject.toml+++ b/python/providers/langchain/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-langchain"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your Langchain agent."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/langchain/setup.py b/python/providers/langchain/setup.pyindex 3ff296a15..bcef9a827 100644--- a/python/providers/langchain/setup.py+++ b/python/providers/langchain/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_langchain",- version="0.10.8",+ version="0.10.9",author="composio",author_email="[email protected]",description="Use Composio to get an array of tools with your Langchain agent.",diff --git a/python/providers/langgraph/pyproject.toml b/python/providers/langgraph/pyproject.tomlindex 24c87107e..867525576 100644--- a/python/providers/langgraph/pyproject.toml+++ b/python/providers/langgraph/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-langgraph"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get array of tools with LangGraph Agent Workflows."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/langgraph/setup.py b/python/providers/langgraph/setup.pyindex e21d0b051..fd5c510a7 100644--- a/python/providers/langgraph/setup.py+++ b/python/providers/langgraph/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_langgraph",- version="0.10.8",+ version="0.10.9",author="composio",author_email="[email protected]",description="Use Composio to get array of tools with LangGraph Agent Workflows",diff --git a/python/providers/llamaindex/pyproject.toml b/python/providers/llamaindex/pyproject.tomlindex d9fd31875..b81b640cb 100644--- a/python/providers/llamaindex/pyproject.toml+++ b/python/providers/llamaindex/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-llamaindex"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get array of tools with LlamaIndex Agent Workflows."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/llamaindex/setup.py b/python/providers/llamaindex/setup.pyindex abbf18dc6..0ea93fcc6 100644--- a/python/providers/llamaindex/setup.py+++ b/python/providers/llamaindex/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_llamaindex",- version="0.10.8",+ version="0.10.9",author="composio",author_email="[email protected]",description="Use Composio to get array of tools with LlamaIndex Agent Workflows",diff --git a/python/providers/openai/pyproject.toml b/python/providers/openai/pyproject.tomlindex 3cbf8cdbc..e3e159637 100644--- a/python/providers/openai/pyproject.toml+++ b/python/providers/openai/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-openai"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get an array of tools with your OpenAI Function Call."readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/openai/setup.py b/python/providers/openai/setup.pyindex 22b4aea50..4e2622fce 100644--- a/python/providers/openai/setup.py+++ b/python/providers/openai/setup.py@@ -8,7 +8,7 @@ from setuptools import setupsetup(name="composio_openai",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get an array of tools with your OpenAI Function Call.",diff --git a/python/providers/openai_agents/pyproject.toml b/python/providers/openai_agents/pyproject.tomlindex f6fd63ec9..2fac1cada 100644--- a/python/providers/openai_agents/pyproject.toml+++ b/python/providers/openai_agents/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio-openai-agents"-version = "0.10.8"+version = "0.10.9"description = "Use Composio to get array of strongly typed tools for OpenAI Agents"readme = "README.md"requires-python = ">=3.9,<4"diff --git a/python/providers/openai_agents/setup.py b/python/providers/openai_agents/setup.pyindex df8ebdcf4..a85041d95 100644--- a/python/providers/openai_agents/setup.py+++ b/python/providers/openai_agents/setup.py@@ -8,7 +8,7 @@ from setuptools import find_packages, setupsetup(name="composio_openai_agents",- version="0.10.8",+ version="0.10.9",author="Composio",author_email="[email protected]",description="Use Composio to get array of strongly typed tools for OpenAI Agents",diff --git a/python/pyproject.toml b/python/pyproject.tomlindex b5eff9d9c..046e7c813 100644--- a/python/pyproject.toml+++ b/python/pyproject.toml@@ -1,6 +1,6 @@[project]name = "composio"-version = "0.10.8"+version = "0.10.9"description = "SDK for integrating Composio with your applications."readme = "README.md"requires-python = ">=3.10,<4"diff --git a/python/tests/test_connected_accounts.py b/python/tests/test_connected_accounts.pyindex 0e60853f9..9f941d299 100644--- a/python/tests/test_connected_accounts.py+++ b/python/tests/test_connected_accounts.py@@ -183,6 +183,30 @@ class TestConnectedAccounts:user_id="user-1", auth_config_id="auth-1", allow_multiple=False)+ def test_initiate_filters_by_active_status_when_checking_existing_accounts(+ self, connected_accounts, mock_client+ ):+ """+ Test that initiate only considers ACTIVE accounts when checking for duplicates.+ This ensures expired or inactive accounts don't block new connection creation.+ """+ mock_accounts = Mock()+ mock_accounts.items = []+ mock_client.connected_accounts.list.return_value = mock_accounts++ mock_response = Mock()+ mock_response.id = "conn-123"+ mock_response.connection_data.val.status = "PENDING"+ mock_response.connection_data.val.redirect_url = "https://redirect"+ mock_client.connected_accounts.create.return_value = mock_response++ connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")++ # Verify that list is called with statuses=["ACTIVE"] to filter only active accounts+ mock_client.connected_accounts.list.assert_called_once_with(+ user_ids=["user-1"], auth_config_ids=["auth-1"], statuses=["ACTIVE"]+ )+def test_initiate_warns_and_creates_when_allow_multiple(self, connected_accounts, mock_client, caplog):@@ -211,7 +235,7 @@ class TestConnectedAccounts:)mock_client.connected_accounts.list.assert_called_once_with(- user_ids=["user-1"], auth_config_ids=["auth-1"]+ user_ids=["user-1"], auth_config_ids=["auth-1"], statuses=["ACTIVE"])call_kwargs = mock_client.connected_accounts.create.call_args.kwargsassert call_kwargs["auth_config"] == {"id": "auth-1"}diff --git a/ts/packages/core/src/models/ConnectedAccounts.ts b/ts/packages/core/src/models/ConnectedAccounts.tsindex 592bd0657..02c47ae9f 100644--- a/ts/packages/core/src/models/ConnectedAccounts.ts+++ b/ts/packages/core/src/models/ConnectedAccounts.ts@@ -161,6 +161,7 @@ export class ConnectedAccounts {const connectedAccount = await this.list({userIds: [userId],authConfigIds: [authConfigId],+ statuses: [ConnectedAccountStatuses.ACTIVE],});if (connectedAccount.items.length > 0 && !options?.allowMultiple) {throw new ComposioMultipleConnectedAccountsError(diff --git a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.tsindex 0e6293fa0..d2a426463 100644--- a/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts+++ b/ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts@@ -113,6 +113,15 @@ describe('ConnectedAccounts', () => {const connectionRequest = await connectedAccounts.initiate(userId, authConfigId, options);+ // Verify list is called with ACTIVE status filter+ expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(+ expect.objectContaining({+ user_ids: [userId],+ auth_config_ids: [authConfigId],+ statuses: [ConnectedAccountStatuses.ACTIVE],+ })+ );+expect(extendedMockClient.connectedAccounts.create).toHaveBeenCalledWith({auth_config: {id: authConfigId,@@ -226,6 +235,43 @@ describe('ConnectedAccounts', () => {);});+ it('should filter by ACTIVE status when checking for existing accounts', async () => {+ const userId = 'user_123';+ const authConfigId = 'auth_config_123';++ // Mock list response to return empty list (no ACTIVE accounts)+ extendedMockClient.connectedAccounts.list.mockResolvedValueOnce({+ items: [],+ next_cursor: null,+ total_pages: 1,+ });++ const mockResponse = {+ id: 'conn_123',+ connectionData: {+ val: {+ authScheme: AuthSchemeTypes.OAUTH2,+ status: 'INITIALIZING',+ redirectUrl: 'https://auth.example.com/connect',+ },+ },+ };++ extendedMockClient.connectedAccounts.create.mockResolvedValueOnce(mockResponse);++ await connectedAccounts.initiate(userId, authConfigId);++ // Verify that list is called with statuses filter set to ACTIVE only+ // This ensures expired/inactive accounts don't block new connection creation+ expect(extendedMockClient.connectedAccounts.list).toHaveBeenCalledWith(+ expect.objectContaining({+ user_ids: [userId],+ auth_config_ids: [authConfigId],+ statuses: [ConnectedAccountStatuses.ACTIVE],+ })+ );+ });+it('should allow multiple accounts when allowMultiple is true', async () => {const userId = 'user_123';const authConfigId = 'auth_config_123';