Skip to content

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 idPinAuth kindNotes
monday20260721_00BYO (custom OAuth2, OAuth 2.1)FULL and READ configs
jira20260903_00ManagedAdapter adds the cloud id
hubspot20260826_00Managed
zendesk20260903_00Managed
salesforce20260924_00Managed
xero20260721_00BYO (no managed Xero app)Our developer.xero.com app; 25-org cap while uncertified
gmail20260903_00Managed
googlecalendar20260902_00Managed
googledrive20261001_00Managed#649
googledocs20261008_00Managed#650, landed via #649
googlesheets20261001_00Managed#651, landed again via #649
outlooknone⚠ not confirmedRegistered 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 ​

mermaid
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/&lt;provider&gt;/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:

  1. Authorizes the caller (authorizeIntegrationCaller). If the service isn't connected, it returns not_connected, which makes the studio show a Connect card.
  2. Runs the provider rewrite before the approval gate (rewrite.ts, for example rewriteXero adds xero-tenant-id and Accept: application/json).
  3. Pauses writes for approval in chat. Tools tagged destructive (Composio's destructiveHint plus our DESTRUCTIVE_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 answers approval_required.
  4. 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:

ToolkitComposio rootHelper
Drivewww.googleapis.com/drive/v3googleDriveProxyPath strips /drive/v3; /upload/drive/v3/... goes out as an absolute URL
Docsdocs.googleapis.com/v1googleWorkspaceProxyPath(path, "/v1")
Sheetssheets.googleapis.com/v4googleWorkspaceProxyPath(path, "/v4") (verified live: GET /v4/spreadsheets/{id} returned 200)
Calendar/calendar/v3shared 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.

mermaid
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 to activeExecutionCaller(), so code the agent runs still gets the turn's builder. Context is verified against BRILLIANT_TOKEN_KEY (previewVisitor() in services/conductor/src/workspace/preview.ts). It is refused if ws or tenant doesn't match, or if it's a user token, signed with the wrong key, or expired. The 403 code integration_requires_active_turn stays 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" returns 400 user_scope_unavailable from 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>/connect returned 500 with Postgres 22P02 (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 app set to the Workers for Platforms script name (app-<hex>), not the app's uuid. connect.ts wrote that claim raw into integration_connections.app_id (a uuid column) and into the Composio user id. The proxy route (caller.ts) and resolveAppCaller already resolved the claim; the connect route didn't.
  • One resolver: appFromContextClaim(store, claim, tenantId) in apps/control-plane/src/routes/integrations/helpers.ts accepts a uuid or script-name claim and holds it with appInSession in the token's tenant. Connect, the proxy caller and resolveAppCaller all use it, so the three can't drift again. Unknown and other-tenant claims get 404 app_not_found instead of a 500 or a row bound to a bogus id.
  • Back to the app after OAuth: the app_user callback used to redirect to /?connected=1 on the control-plane host, which is the studio, and the validated returnTo was never used. Now returnTo rides on the callback as return_to, and the callback redirects to the published app at returnTo with connected=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 backslash returnTo is 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. For app_user that page says to go back to the app and has no studio button. Studio connects still get "Back to the studio".
  • Absolute app address: absoluteLiveAppUrl in apps/control-plane/src/lib/app-url.ts is 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 on DISPATCH_HOST, and a path with no dispatch host is null. See Control plane: published URL.
  • Tests: workday-connect.test.ts now uses a real app instead of a made-up app: "fake-app" claim, so it still reaches the Workday refusal rather than the new 404.
  • ⚠ Security follow-up #1011: bind the app_user OAuth 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 knows conn). #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>/connect returns 404 from the conductor proxy (only fetch answers user_scope_unavailable), so the app shows a generic error. Follow-up. return_to stays 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 (read or read_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_allowed plus agent_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 via GET /v1/integrations/connect-choice); the Composio grant is created when the link is opened, for the mode left on the toggle. connectUrl is the read-write choice when that grant is allowed (what an older card still opens), and readConnectUrl is 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_unavailable and the full link is not opened. A missing mode starts 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: conductorModeGate in apps/control-plane/src/routes/integrations/proxy-approval.ts returns allow for a full profile with agent writes on. For a read profile, or any connection whose mode was already set (including writes turned off in Integrations settings), it refuses with 403 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/connect mints the pending connection with mode: "read" | "read_write" (read maps to the read profile, read_write to full). The agent-writes route takes agentWritesAllowed: true | false. The integration-agent contract (packages/service-contracts) adds a connect op and readConnectUrl.
  • Salesforce and Workday are read-write only. READ_WRITE_ONLY_PROVIDERS / offersReadProfile in packages/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_connection refusal exist before the new card asks for them.
  • Tests: full bun test passed in conductor, control-plane and control-plane web, plus knip, tsc and biome. Manual checks still open at merge: connect read-only from chat (grant is read-only, or read_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.

EnvComposio projectAuth configsManaged by
ProductionIts 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
StagingShared projectCreated by handComposio dashboard. #702 (adopt staging into Pulumi) was closed without merging, because #799 superseded it.
Side envsStaging's project/ids via brilliant/side-env-baseSame as stagingSet 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 ​

NameWhatWhere it lives
COMPOSIO_API_KEYProject API key (per env)Secrets (Cloudflare Secrets Store via the secrets Worker)
COMPOSIO_AUTH_CONFIG_<PROVIDER>_FULLAuth-config id for full scopePer-env config. Admin Config (CONFIG_KV) overrides the deployed env/secret value.
COMPOSIO_AUTH_CONFIG_<PROVIDER>_READNarrower scope, if one existsSame. 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) ​

  1. Track: a monday item, a GitHub issue and docs/plans/<p>.md.
  2. Pick the backend: Composio if it's in the catalog, otherwise direct.
  3. 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 with apps/control-plane/scripts/spike-composio-s0.ts.
  4. Pin and catalog: add COMPOSIO_TOOLKIT_VERSIONS.<p>, run bun scripts/gen-integration-actions.ts <p>, read the schemas, and tag missed destructive tools in DESTRUCTIVE_OVERRIDES. Find the proxy root, identity call and required headers.
  5. Code fan-out: registry entry and identity probe, rewrite adapter, COMPOSIO_PROVIDERS, icon, template SDK client, skills (skills/integrations/references/<p>.md with Probe: lines, plus the generated actions file), workflow triggers, bundles, landing suggestions, gotchas. Tests fail until these exist, which is intended.
  6. Probe on a side env (bun run env:ci, never staging). Set COMPOSIO_AUTH_CONFIG_<P>_FULL, connect a sandbox, and run scripts/integrations/probe.ts. On canonical apps it gets 401 (#644), so run the probes through a signed agent turn.
  7. End to end: the connection label is correct, a build turn reads live data, writes stop at approval, and e2e-smoke passes.
  8. Release: set …_FULL on staging and prod, and the lead verifies on staging from main.

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 q query rejects spaces and %20 in the proxy validator. Use +.
  • Drive multipart upload through the proxy stores the metadata as the file content. Upload with uploadType=media, then PATCH the name and parents.
  • Xero: multi-org writes fail closed without xero-tenant-id. There are no Composio triggers, so workflows poll with If-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_user OAuth 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 (forProvider works today). #644: probe.ts should sign agent requests.
  • After #799's prod rollout, confirm that every one of the 13 state deletes read (retained: state-only). ⚠ Not confirmed here.