Composio at Brilliant: overview for dev leads
About a 10-minute read. Checked against DaPulse/brilliant-ai main on 2026-10-12. Detailed per-provider notes are on Integrations. In-repo references: docs/new-integration.md and gotchas/integrations.md.
1. What Composio is and why we use it
Composio is a hosted integration layer. It gives us OAuth flows, token storage and refresh, a catalog of typed tools (actions) and triggers for each SaaS toolkit, and an authenticated proxy that forwards raw HTTP calls to the vendor API using the user's token.
Brilliant apps and the coding agent need access to customers' SaaS data (monday, Google, Jira, Salesforce and others). Composio lets us offer that without:
- registering and running our own OAuth app for every vendor (for managed toolkits),
- storing customers' OAuth tokens or vendor client secrets ourselves. Brilliant stores only auth-config ids. Tokens stay in Composio.
- writing a tool catalog by hand. We generate ours from Composio's catalog.
Composio is one of two integration backends. The other is direct (backend.kind: "direct"), which uses our own vault and connect form. It's for API-key integrations and for agent-proposed custom APIs. Use Composio when its catalog has the toolkit, and direct otherwise (docs/new-integration.md §2).
2. Toolkits we use
The source of truth is COMPOSIO_TOOLKIT_VERSIONS in apps/control-plane/src/integrations/providers.ts, which spreads in GOOGLE_TOOLKIT_VERSIONS from google-providers.ts. The config-key list is COMPOSIO_PROVIDERS in packages/config/src/composio.ts.
| Provider id | Pin | Auth kind | Notes |
|---|---|---|---|
monday | 20260721_00 | BYO (custom OAuth2, OAuth 2.1) | FULL and READ configs |
jira | 20260903_00 | Managed | Adapter adds the cloud id |
hubspot | 20260826_00 | Managed | |
zendesk | 20260903_00 | Managed | |
salesforce | 20260924_00 | Managed | |
xero | 20260721_00 | BYO (no managed Xero app) | Our developer.xero.com app; 25-org cap while uncertified |
gmail | 20260903_00 | Managed | |
googlecalendar | 20260902_00 | Managed | |
googledrive | 20261001_00 | Managed | #649 |
googledocs | 20261008_00 | Managed | #650, landed via #649 |
googlesheets | 20261001_00 | Managed | #651, landed again via #649 |
outlook | none | ⚠ not confirmed | Registered and listed in COMPOSIO_PROVIDERS, but it has no pinnedVersion. Earlier notes say staging has no Outlook auth config. |
All of these are released in the registry (no release: "experimental"). Managed toolkits use Composio's own OAuth app, so the consent screen says "Composio". A Brilliant-owned Google app is still open as issue #11.
Why pins matter: tool list and execute calls must carry the same version. Otherwise a tool that exists only in the latest version returns 404.
3. Architecture
flowchart LR
subgraph Sandbox["App container (conductor workspace)"]
A[Coding agent tools<br/>integration_call / integration_run]
P[Preview / app server code<br/>template integrations client]
end
B[Studio builder's browser] -- "preview load<br/>x-brilliant-context (≤30s, ws claim)" --> P
A --> C
P -- "POST /integrations/<provider>/proxy" --> C[Conductor<br/>brilliant-proxy.ts]
C -- "caller + source: coding_agent" --> CP[Control plane<br/>integration broker]
CP -- "access check, approval gate,<br/>provider rewrite, auth-config id" --> X[Composio API<br/>tools / proxy]
X --> V[(Vendor API<br/>Google, monday, Jira…)]Control plane (broker). The provider registry (providers.ts, google-providers.ts) gives each provider a toolkit slug, an action prefix, a pinned version, authConfigEnvKeys (read/full), an identity probe for the connection label, and an optional request rewrite. For every call it:
- Authorizes the caller (
authorizeIntegrationCaller). If the service isn't connected, it returnsnot_connected, which makes the studio show a Connect card. - Runs the provider rewrite before the approval gate (
rewrite.ts, for examplerewriteXeroaddsxero-tenant-idandAccept: application/json). - Pauses writes for approval in chat. Tools tagged destructive (Composio's
destructiveHintplus ourDESTRUCTIVE_OVERRIDES) are flagged. Since #1012 (merged 2026-10-19) there is no per-write "Allow once" prompt: each connection carries a read-only or read-write mode chosen once on the chat connect card, and writes follow it. Only an older full connection that never got a mode still answersapproval_required. - Strips adapter- and caller-supplied headers case-insensitively and merges them (
mergeAdapterHeaders), then calls Composio.
Connect. Composio OAuth runs under a scoped Composio user id. The connection is labelled with the account the identity probe returns (an email, org name or site), not a generic host.
Proxy root stripping (the "/v4 strip"). Composio's proxy base URL for a toolkit often already includes the API version, so a path the agent writes "naturally" would double it. Helpers strip the duplicate prefix:
| Toolkit | Composio root | Helper |
|---|---|---|
| Drive | www.googleapis.com/drive/v3 | googleDriveProxyPath strips /drive/v3; /upload/drive/v3/... goes out as an absolute URL |
| Docs | docs.googleapis.com/v1 | googleWorkspaceProxyPath(path, "/v1") |
| Sheets | sheets.googleapis.com/v4 | googleWorkspaceProxyPath(path, "/v4") (verified live: GET /v4/spreadsheets/{id} returned 200) |
| Calendar | /calendar/v3 | shared stripProxyRoot in provider-identity.ts |
Docs and Sheets send /drive/v3/... paths (search, export) to the Drive host as absolute URLs with the same token.
Identity and the active-turn rule (#807)
There are two callers in the container. Only builders can ever reach integrations from a preview.
sequenceDiagram
participant Br as Builder browser
participant Pv as Preview server code
participant Co as Conductor proxy
participant CP as Control plane
Br->>Pv: load draft preview (admitted builder)
Note over Pv: withPreviewContext mints HS256 x-brilliant-context<br/>(tenant, ws=environmentId, ≤30s)
Pv->>Co: POST /integrations/gmail/proxy {as:"app"}
Co->>Co: previewVisitor() verifies key, ws, tenant
alt valid visitor context
Co->>CP: proxy as visiting builder (source: coding_agent)
else no visitor, builder turn running
Co->>CP: proxy as the turn's builder
else neither
Co-->>Pv: 403 integration_requires_active_turn
end- Before #807: preview calls worked only during a builder's agent turn, and every visitor was signed as that turn's pinned builder.
- After #807 (merged 2026-10-12):
handleContainerIntegrationProxy(services/conductor/src/llm/brilliant-proxy.ts) signs as the visitor when a valid context is present. Otherwise it falls back toactiveExecutionCaller(), so code the agent runs still gets the turn's builder. Context is verified againstBRILLIANT_TOKEN_KEY(previewVisitor()inservices/conductor/src/workspace/preview.ts). It is refused ifwsortenantdoesn't match, or if it's a user token, signed with the wrong key, or expired. The 403 codeintegration_requires_active_turnstays for client compatibility, and it now also means "no signed-in builder". - Unchanged: the control plane re-checks builder access on every call. The body must say
as: "app".as: "user"returns400 user_scope_unavailablefrom a preview (#526). - ⚠ No live end-to-end test of #807 was done at merge time.
Per-user connect from a published app (#1010, merged)
PR #1010 (opened 2026-10-17 16:14 IDT by Brilliant Fixer as monday-sphera-ai[bot], requested by Amichay Even Chen; fixes issue #992; branch fix-992-app-user-connect; merged 2026-10-17 21:11 IDT by yoni-monday, merge 29a2a0e7, head c690882e, 3 commits, +329/−36 in 9 files) fixes the "every user connects their own account" flow in published apps. It touches tenant isolation: it decides which app a published-app context token can bind a per-user connection to.
- Symptom: an end user's Connect click in a published app failed every time.
POST /v1/integrations/<provider>/connectreturned 500 with Postgres22P02(3 times in prod on 2026-10-16, Gmail in the Invoice Gmail Scanner app). Every provider was affected, not just Gmail. - Cause: Dispatch signs the app context with
appset to the Workers for Platforms script name (app-<hex>), not the app's uuid.connect.tswrote that claim raw intointegration_connections.app_id(auuidcolumn) and into the Composio user id. The proxy route (caller.ts) andresolveAppCalleralready resolved the claim; the connect route didn't. - One resolver:
appFromContextClaim(store, claim, tenantId)inapps/control-plane/src/routes/integrations/helpers.tsaccepts a uuid or script-name claim and holds it withappInSessionin the token's tenant. Connect, the proxy caller andresolveAppCallerall use it, so the three can't drift again. Unknown and other-tenant claims get404 app_not_foundinstead of a 500 or a row bound to a bogus id. - Back to the app after OAuth: the
app_usercallback used to redirect to/?connected=1on the control-plane host, which is the studio, and the validatedreturnTowas never used. NowreturnTorides on the callback asreturn_to, and the callback redirects to the published app atreturnTowithconnected=1(for a root-published app,https://<label>.<APPS_DOMAIN>/<returnTo>?…&connected=1). A path that leaves the app with a raw or percent-encoded dot segment (..,%2e%2e,.%2e,%2e.) lands on the app root. A protocol-relative (//host) or backslashreturnTois refused at connect. - No app URL to return to: when the published URL can't be made absolute (the app row is gone, or the app has a path-shaped URL and there's no
DISPATCH_HOST), the callback renders the close-this-tab page. Forapp_userthat page says to go back to the app and has no studio button. Studio connects still get "Back to the studio". - Absolute app address:
absoluteLiveAppUrlinapps/control-plane/src/lib/app-url.tsis now the one absolute published-app address used by connect, invitations (routes/invitations.ts) and email (email/event-context.ts). An apps-domain URL stays absolute, a root publish needs no dispatch host, a path resolves onDISPATCH_HOST, and a path with no dispatch host is null. See Control plane: published URL. - Tests:
workday-connect.test.tsnow uses a real app instead of a made-upapp: "fake-app"claim, so it still reaches the Workday refusal rather than the new 404. - ⚠ Security follow-up #1011: bind the
app_userOAuth callback to the end user who started it (a forwarded-link attack from the Sentinel review, plus a callback-replay variant, since the callback falls back to the stored connected-account id and the starter knowsconn). #1010 merged first, so per-user connect works in prod with that gap open until #1011 lands. - Not in the PR: in the studio preview,
brilliant.internal/integrations/<p>/connectreturns 404 from the conductor proxy (onlyfetchanswersuser_scope_unavailable), so the app shows a generic error. Follow-up.return_tostays on the callback query; editing it can only move the landing spot inside the same app.
Related: Troubleshooting: Connect in a published app fails with 500 22P02, Dispatch, Permissions & data.
Connection mode: read-only or read-write, asked once (#1012, merged)
PR #1012 "Ask once whether an integration connection can write" (opened 2026-10-17 21:34 IDT by yoni-monday, branch integrations-modes; merged 2026-10-19 08:01 IDT by yoni-monday, merge fdcd8838, head 5b52f1cb, 5 commits, +2565/−633 in 65 files) replaces per-write approval with a mode stored on each connection.
- Before: every conductor write to a connection without the agent-write flag returned
approval_required, and the chat asked "Allow once", "Allow for this app from now on" or "Not now" each time. - After: one connect card with a mode toggle. The agent sets
mode(readorread_write) on the call, and that choice is the toggle on the chat connect row (ConnectRow.tsx). The user sees it and can flip it before connecting. The choice is stored on the connection (agent_writes_allowedplusagent_writes_set_at) and later writes follow it with no prompt. - The link mints the grant for the chosen mode. Chat connect links are signed choices (
apps/control-plane/src/routes/integrations/connect-choice.ts, opened viaGET /v1/integrations/connect-choice); the Composio grant is created when the link is opened, for the mode left on the toggle.connectUrlis the read-write choice when that grant is allowed (what an older card still opens), andreadConnectUrlis sent only when a read grant can be minted. - Read-only means a read-only grant. Where no read grant exists, the call returns
400 read_only_unavailableand the full link is not opened. A missingmodestarts on read-only when a read grant exists, so an omitted mode never authorizes writes. - Admin policy. A workspace whose policy allows only read can still connect from chat: the card offers read-only and locks the toggle there. A read-write connect stays blocked, and a workspace that blocks both still gets
blocked_by_admin. - Proxy gate:
conductorModeGateinapps/control-plane/src/routes/integrations/proxy-approval.tsreturns allow for afullprofile with agent writes on. For areadprofile, or any connection whose mode was already set (including writes turned off in Integrations settings), it refuses with403 read_only("do not ask the user to approve this write, and do not retry it") plus a recovery hint: a read token must be disconnected and reconnected read-write, while a full token just needs agent writes turned back on in settings. Otherwise it returns ask. - Backward compatible: an older full connection that never got a mode still returns
approval_required, so conductors without this change keep working; the new conductor (services/conductor/src/coding-agent/tools/integrations/,connection-mode.ts) shows the same toggle once for that connection. - Shared connections: a workspace-scoped (company) connection shared across apps can't have its mode changed from one app's chat. That returns
409 shared_connection; change it in Integrations settings. - Endpoints:
POST /internal/workspaces/:id/apps/:appId/integrations/:provider/connectmints the pending connection withmode: "read" | "read_write"(readmaps to thereadprofile,read_writetofull). The agent-writes route takesagentWritesAllowed: true | false. The integration-agent contract (packages/service-contracts) adds aconnectop andreadConnectUrl. - Salesforce and Workday are read-write only.
READ_WRITE_ONLY_PROVIDERS/offersReadProfileinpackages/capabilities/src/integrations.ts: their grants can't be read-only, so the toggle is hidden and the row says read and write. The Workday stamp runs after the admin claims the OAuth row, and a missing account email is refused instead of recorded. - ⚠ Deploy order and behavior change: existing connections with agent writes turned off start refusing writes when this deploys. Ship the control plane before the conductor, so the read-only link and the
shared_connectionrefusal exist before the new card asks for them. - Tests: full
bun testpassed in conductor, control-plane and control-plane web, plus knip,tscand biome. Manual checks still open at merge: connect read-only from chat (grant is read-only, orread_only_unavailable) and confirm a later write is refused without a prompt; flip to read-write and confirm writes proceed without asking; Salesforce and Workday show read and write with no switch; an existing writes-off connection refuses writes after the control plane deploys; a read-only-policy workspace connects read-only while read-write stays blocked.
Related: Permissions & data (integration writes as a WritePermit), Integrations, Troubleshooting.
4. Auth configs and connected accounts per environment
An auth config is Composio's per-project record of how to authenticate a toolkit (managed, or BYO client id and secret). A connected account is one user's authorized link under that config. Brilliant stores only the auth-config id, per environment, as a config value.
| Env | Composio project | Auth configs | Managed by |
|---|---|---|---|
| Production | Its own project (#564). The cutover to the new key and settings was a manual step; ⚠ not confirmed here whether it's complete. | Ten created by Pulumi (#564/#568/#569, BYO secrets repaired in #579), plus three Google Workspace configs made by hand and adopted by id (#760). 13 in total. | Composio dashboard since #799 |
| Staging | Shared project | Created by hand | Composio dashboard. #702 (adopt staging into Pulumi) was closed without merging, because #799 superseded it. |
| Side envs | Staging's project/ids via brilliant/side-env-base | Same as staging | Set per env |
History in one line: auth configs were first under Pulumi (infra/pulumi/src/composio.ts). #798 set all 13 to retainOnDelete: true, and #799 (merged 2026-10-11) removed Composio from Pulumi state without deleting the live configs. Today, the dashboard is the source of truth.
Connected accounts are not moved by a new project key. Moving prod to its own project meant users had to reconnect (prod had zero connections at the time).
5. Config, secrets and env var names
| Name | What | Where it lives |
|---|---|---|
COMPOSIO_API_KEY | Project API key (per env) | Secrets (Cloudflare Secrets Store via the secrets Worker) |
COMPOSIO_AUTH_CONFIG_<PROVIDER>_FULL | Auth-config id for full scope | Per-env config. Admin Config (CONFIG_KV) overrides the deployed env/secret value. |
COMPOSIO_AUTH_CONFIG_<PROVIDER>_READ | Narrower scope, if one exists | Same. If READ is missing, the request falls back to FULL (for example, the Google Workspace providers have no READ config). |
<PROVIDER> is the uppercased id from COMPOSIO_PROVIDERS (for example GOOGLESHEETS). The keys are generated as provider × {READ, FULL}. The secrets Worker treats each expanded name as optional (#696), so a missing toolkit is skipped instead of returning a 409. Local dev: apps/control-plane/.dev.vars.example.
Rule: if …_FULL isn't set on an environment, the Connect button doesn't appear there.
6. Adding a new toolkit (summary of docs/new-integration.md)
- Track: a monday item, a GitHub issue and
docs/plans/<p>.md. - Pick the backend: Composio if it's in the catalog, otherwise direct.
- Auth: managed if Composio offers it. Otherwise BYO: register the vendor app under the integrations team's login, with redirect
https://backend.composio.dev/api/v3/toolkits/auth/callback. Create the auth config in the Composio dashboard. The client secret lives only in Composio. Prove it withapps/control-plane/scripts/spike-composio-s0.ts. - Pin and catalog: add
COMPOSIO_TOOLKIT_VERSIONS.<p>, runbun scripts/gen-integration-actions.ts <p>, read the schemas, and tag missed destructive tools inDESTRUCTIVE_OVERRIDES. Find the proxy root, identity call and required headers. - Code fan-out: registry entry and identity probe, rewrite adapter,
COMPOSIO_PROVIDERS, icon, template SDK client, skills (skills/integrations/references/<p>.mdwithProbe:lines, plus the generated actions file), workflow triggers, bundles, landing suggestions, gotchas. Tests fail until these exist, which is intended. - Probe on a side env (
bun run env:ci, never staging). SetCOMPOSIO_AUTH_CONFIG_<P>_FULL, connect a sandbox, and runscripts/integrations/probe.ts. On canonical apps it gets 401 (#644), so run the probes through a signed agent turn. - End to end: the connection label is correct, a build turn reads live data, writes stop at approval, and
e2e-smokepasses. - Release: set
…_FULLon staging and prod, and the lead verifies on staging frommain.
7. Known gotchas
- GET returns masked secrets (
abcd...wxyz). Never copy custom client or signing secrets from a Composio GET, and don't treat GET equality as proof. Prove credentials with a real connect (#579). - Create fields differ from GET fields: custom auth uses camel-case
authScheme, and managed creation sends no scheme field (#569). Scopes are sent comma-separated, and empty scopes are omitted (#568). - The Drive
qquery rejects spaces and%20in the proxy validator. Use+. - Drive multipart upload through the proxy stores the metadata as the file content. Upload with
uploadType=media, thenPATCHthe name and parents. - Xero: multi-org writes fail closed without
xero-tenant-id. There are no Composio triggers, so workflows poll withIf-Modified-Since. - monday: keep
use_oauth2_1, since legacy OAuth 2.0 tokens expired on 2026-10-01. - The secrets Worker binds only secrets that exist when it deploys. Deploy it after all
COMPOSIO_*names exist (#815). - Don't paste
ac_/ca_ids into docs, the wiki or chat. Set them through Admin Config or side-env secrets.
8. Open items
- ⚠ Outlook has no pin. Its staging and prod auth-config status is unconfirmed.
- ⚠ Prod project cutover (#564 steps 3–5 and issue #577, a real monday/Xero connect in prod): completion is not confirmed in this doc.
- Staging configs were created by hand and are unmanaged as code (#702 closed). With #799, this is now by design.
- #807 has no live end-to-end check yet.
- #1012 (merged 2026-10-19): manual checks for connection mode (read-only refusal, read-write without prompts, Salesforce/Workday, writes-off connections after deploy) were still open at merge (section above).
- #1011 (open): bind the
app_userOAuth callback to the user who started it. Follow-up to the merged per-user connect fix #1010 (section above). Studio-preview connect returning 404 is a separate follow-up. - #11: Brilliant-owned Google OAuth app (consent currently says "Composio").
- #637: named
integrations.<provider>accessors in the template SDK (forProviderworks today). #644:probe.tsshould sign agent requests. - After #799's prod rollout, confirm that every one of the 13 state deletes read
(retained: state-only). ⚠ Not confirmed here.