@devries-cameron20 / composio Mirror · read-only / commits / eb51b923b
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 21, 21:00 UTC

feat(cli): send x-cli-session-id header on every request (#3430)

## Summary - Pulls the per-cwd CLI session id (already generated by `getCurrentCwdSessionId()` and used as `cli_session_id` on analytics events) and attaches it as the `x-cli-session-id` header on every request from the composio client. - Backend reads the header off `requestInfo`, threads it through `enrichSessionInfo`, and writes `session_info.cli_session_id` on every tool execution log row. Companion hermes PR: ComposioHQ/hermes#9990 ## Why The CLI already tracks a stable per-cwd session id for analytics, but tool execution logs are blind to it — there's no way to filter the logs UI / retool back to a single CLI session. Wiring the header through lets us group all tool calls from one CLI workflow together. ## Test plan - [x] `pnpm --filter @composio/cli typecheck` clean - [ ] Run `composio tools execute <slug>` against a build with the hermes companion deployed, confirm ClickHouse tool log has `session_info.cli_session_id` - [ ] Confirm header is absent (and log field absent) when no cwd session is cached 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Rahul Tarak committed May 16, 2026 at 13:47 UTC eb51b923bbe5d8666cbc6d99728068e37d54ecea
2 files changed +10
.changeset/cli-session-id-header.md new
+5
@@ -0,0 +1,5 @@
1 +---
2 +"@composio/cli": patch
3 +---
4 +
5 +CLI now sends its per-cwd session id as the `x-cli-session-id` header on every request. The backend uses this to tag tool execution logs with `session_info.cli_session_id`, so all tool executions from a single CLI session (one cwd, one user) can be grouped together in the logs UI.
ts/packages/cli/src/services/composio-clients.ts
+5
@@ -28,6 +28,7 @@ import {
28 import { Session, RetrievedSession } from 'src/models/session';
29 import { TriggerType, TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
30 import * as constants from 'src/constants';
31 +import { getCurrentCwdSessionId } from 'src/analytics/dispatch';
32 import { ComposioUserContext, ComposioUserContextLive } from './user-context';
33 import { ProjectContext } from './project-context';
34 import type { NoSuchElementException } from 'effect/Cause';
@@ -1325,6 +1326,7 @@ const buildDefaultHeaders = (params: {
1326 orgId?: string;
1327 projectId?: string;
1328 }): Record<string, string> | undefined => {
1329 + const cliSessionId = getCurrentCwdSessionId();
1330 const defaultHeaders = {
1331 'x-framework': 'cli',
1332 'x-source': 'CLI',
@@ -1339,6 +1341,9 @@ const buildDefaultHeaders = (params: {
1341 'x-project-id': params.projectId,
1342 } satisfies Record<string, string>)
1343 : {}),
1344 + ...(cliSessionId
1345 + ? ({ 'x-cli-session-id': cliSessionId } satisfies Record<string, string>)
1346 + : {}),
1347 };
1348
1349 return Object.keys(defaultHeaders).length > 0 ? defaultHeaders : undefined;