Skip to content

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(cli): send x-cli-session-id header on every request (#3430)

Rahul Tarakeb51b923bbe5
diff --git a/.changeset/cli-session-id-header.md b/.changeset/cli-session-id-header.md
new file mode 100644
index 000000000..adba59583
--- /dev/null
+++ b/.changeset/cli-session-id-header.md
@@ -0,0 +1,5 @@
+---
+"@composio/cli": patch
+---
+
+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.
diff --git a/ts/packages/cli/src/services/composio-clients.ts b/ts/packages/cli/src/services/composio-clients.ts
index 984173802..d0de6c845 100644
--- a/ts/packages/cli/src/services/composio-clients.ts
+++ b/ts/packages/cli/src/services/composio-clients.ts
@@ -28,6 +28,7 @@ import {
import { Session, RetrievedSession } from 'src/models/session';
import { TriggerType, TriggerTypes, TriggerTypesAsEnums } from 'src/models/trigger-types';
import * as constants from 'src/constants';
+import { getCurrentCwdSessionId } from 'src/analytics/dispatch';
import { ComposioUserContext, ComposioUserContextLive } from './user-context';
import { ProjectContext } from './project-context';
import type { NoSuchElementException } from 'effect/Cause';
@@ -1325,6 +1326,7 @@ const buildDefaultHeaders = (params: {
orgId?: string;
projectId?: string;
}): Record<string, string> | undefined => {
+ const cliSessionId = getCurrentCwdSessionId();
const defaultHeaders = {
'x-framework': 'cli',
'x-source': 'CLI',
@@ -1339,6 +1341,9 @@ const buildDefaultHeaders = (params: {
'x-project-id': params.projectId,
} satisfies Record<string, string>)
: {}),
+ ...(cliSessionId
+ ? ({ 'x-cli-session-id': cliSessionId } satisfies Record<string, string>)
+ : {}),
};
return Object.keys(defaultHeaders).length > 0 ? defaultHeaders : undefined;