@devries-cameron20 / composio-1 / commits / a94715f57
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.

feat(sdk): forward user_id on triggers.create for trigger 2FA (#3576)

## What `triggers.create(userId/user_id, ...)` already accepts a user id and uses it to resolve the connected account, but **dropped it** when building the `trigger_instances.upsert` body. With [2FA for triggers](https://linear.app/composio/issue/PLEN-2580) on the backend, 2FA-enabled projects need `user_id` on the upsert to verify the pinned connected account belongs to the caller's user. This forwards `user_id` to upsert in **both SDKs**: - **TS** (`ts/packages/core/src/models/Triggers.ts`): adds `user_id` to the upsert params via a `& { user_id?: string }` bridge. - **Python** (`python/composio/core/models/triggers.py`): forwards `user_id` via the client's supported `extra_body` escape hatch. Both bridges exist only until `@composio/client` / `composio-client` regenerate from the updated OpenAPI spec with a native `user_id` field — drop them then. ## Safety Backends without trigger 2FA ignore the extra field, so this is safe to land ahead of / alongside the backend rollout (hermes PR #10635). ## Tests - TS: upsert-body assertion added. - Python: `tests/test_triggers.py::test_create_with_user_id` asserts `extra_body == {"user_id": ...}`. 49 tests pass. Closes part of PLEN-2580 (SDK follow-up to the agreed approach). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: jkomyno <alberto@composio.dev>

Anshu Garg committed Jun 16, 2026 at 14:40 UTC a94715f57798cda49ee50addcf238de73aa48522
31 files changed +64 -37
.changeset/forward-trigger-user-id.md new
+5
@@ -0,0 +1,5 @@
1 +---
2 +"@composio/core": minor
3 +---
4 +
5 +Forward `userId` when creating trigger instances so trigger 2FA flows can verify connected account ownership.
python/composio/core/models/triggers.py
+6
@@ -842,6 +842,11 @@ class Triggers(Resource):
842 "please provide valid `connected_account` or `user_id`"
843 )
844
845 + # Forward user_id so 2FA-enabled projects can verify the pinned connected
846 + # account belongs to this user (backends without 2FA ignore it). Sent via
847 + # extra_body until composio-client regenerates with the field.
848 + extra_body = {"user_id": user_id} if user_id is not None else {}
849 +
850 return self._client.trigger_instances.upsert(
851 slug=slug,
852 connected_account_id=connected_account_id,
@@ -849,6 +854,7 @@ class Triggers(Resource):
854 body_trigger_config_1=(
855 trigger_config if trigger_config is not None else omit
856 ),
857 + extra_body=extra_body,
858 )
859
860 def _get_connected_account_for_user(self, trigger: str, user_id: str) -> str:
python/providers/anthropic/pyproject.toml
+1 -1
@@ -1,6 +1,6 @@
1 [project]
2 name = "composio-anthropic"
3 -version = "0.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
9 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
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.14.0",
11 + version="0.15.0",
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.14.0"
3 +version = "0.15.0"
4 description = "SDK for integrating Composio with your applications."
5 readme = "README.md"
6 requires-python = ">=3.10,<4"
python/tests/test_triggers.py
+2
@@ -248,6 +248,8 @@ class TestTriggers:
248 call_kwargs = mock_client.trigger_instances.upsert.call_args.kwargs
249 assert call_kwargs["connected_account_id"] == "conn-456"
250 assert call_kwargs["toolkit_versions"] is None
251 + # user_id forwarded for trigger 2FA ownership verification
252 + assert call_kwargs["extra_body"] == {"user_id": "user-123"}
253 assert result == mock_response
254
255 def test_create_with_custom_toolkit_versions(
ts/packages/core/src/models/Triggers.ts
+15 -3
@@ -1,5 +1,8 @@
1 import ComposioClient, { APIError } from '@composio/client';
2 -import { TriggersTypeRetrieveEnumResponse } from '@composio/client/resources/index';
2 +import {
3 + TriggersTypeRetrieveEnumResponse,
4 + type TriggerInstanceUpsertParams as ClientTriggerInstanceUpsertParams,
5 +} from '@composio/client/resources/index';
6 import {
7 TriggerInstanceUpsertResponse,
8 TriggerInstanceUpsertParamsSchema,
@@ -227,11 +230,20 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
230 throw error;
231 }
232
230 - const result = await this.client.triggerInstances.upsert(slug, {
233 + // Forward user_id so 2FA-enabled projects can verify the pinned connected
234 + // account is owned by this user (backends without 2FA ignore it). The
235 + // `& { user_id }` bridges until @composio/client regenerates from the
236 + // updated OpenAPI spec; drop it once the field lands on the generated type.
237 + const upsertParams: ClientTriggerInstanceUpsertParams & {
238 + user_id?: string;
239 + } = {
240 connected_account_id: connectedAccountId,
241 trigger_config: parsedBody.data.triggerConfig,
242 toolkit_versions: this.toolkitVersions,
234 - });
243 + user_id: userId,
244 + };
245 +
246 + const result = await this.client.triggerInstances.upsert(slug, upsertParams);
247
248 return {
249 triggerId: result.trigger_id,
ts/packages/core/test/models/triggers.test.ts
+2
@@ -322,6 +322,7 @@ describe('Triggers', () => {
322 connected_account_id: body.connectedAccountId,
323 trigger_config: body.triggerConfig,
324 toolkit_versions: 'latest',
325 + user_id: userId,
326 });
327 expect(result).toEqual({ triggerId: mockTriggerUpsertResponse.trigger_id });
328 });
@@ -340,6 +341,7 @@ describe('Triggers', () => {
341 connected_account_id: 'conn-456',
342 trigger_config: bodyWithoutConnectedAccount.triggerConfig,
343 toolkit_versions: 'latest',
344 + user_id: userId,
345 });
346 expect(logger.warn).toHaveBeenCalledWith(
347 `[Warn] Multiple connected accounts found for user ${userId}, using the first one. Pass connectedAccountId to select a specific account.`
uv.lock
+9 -9
@@ -592,7 +592,7 @@ wheels = [
592
593 [[package]]
594 name = "composio"
595 -version = "0.14.0"
595 +version = "0.15.0"
596 source = { editable = "python" }
597 dependencies = [
598 { name = "composio-client" },
@@ -649,7 +649,7 @@ dev = [
649
650 [[package]]
651 name = "composio-anthropic"
652 -version = "0.14.0"
652 +version = "0.15.0"
653 source = { editable = "python/providers/anthropic" }
654 dependencies = [
655 { name = "anthropic" },
@@ -681,7 +681,7 @@ wheels = [
681
682 [[package]]
683 name = "composio-crewai"
684 -version = "0.14.0"
684 +version = "0.15.0"
685 source = { editable = "python/providers/crewai" }
686 dependencies = [
687 { name = "composio" },
@@ -696,7 +696,7 @@ requires-dist = [
696
697 [[package]]
698 name = "composio-gemini"
699 -version = "0.14.0"
699 +version = "0.15.0"
700 source = { virtual = "python/providers/gemini" }
701 dependencies = [
702 { name = "composio" },
@@ -711,7 +711,7 @@ requires-dist = [
711
712 [[package]]
713 name = "composio-google"
714 -version = "0.14.0"
714 +version = "0.15.0"
715 source = { editable = "python/providers/google" }
716 dependencies = [
717 { name = "composio" },
@@ -726,7 +726,7 @@ requires-dist = [
726
727 [[package]]
728 name = "composio-google-adk"
729 -version = "0.14.0"
729 +version = "0.15.0"
730 source = { editable = "python/providers/google_adk" }
731 dependencies = [
732 { name = "composio" },
@@ -741,7 +741,7 @@ requires-dist = [
741
742 [[package]]
743 name = "composio-langchain"
744 -version = "0.14.0"
744 +version = "0.15.0"
745 source = { editable = "python/providers/langchain" }
746 dependencies = [
747 { name = "composio" },
@@ -756,7 +756,7 @@ requires-dist = [
756
757 [[package]]
758 name = "composio-openai"
759 -version = "0.14.0"
759 +version = "0.15.0"
760 source = { editable = "python/providers/openai" }
761 dependencies = [
762 { name = "composio" },
@@ -771,7 +771,7 @@ requires-dist = [
771
772 [[package]]
773 name = "composio-openai-agents"
774 -version = "0.14.0"
774 +version = "0.15.0"
775 source = { editable = "python/providers/openai_agents" }
776 dependencies = [
777 { name = "composio" },