Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe("AgentServer.configureEnvironment", () => {
originProduct: "signal_report",
signalReportId: "report-123",
aiStage: "research",
aiSessionId: "report-1:r2",
taskId: "task-abc",
taskRunId: "run-xyz",
taskUserId: 42,
Expand All @@ -218,6 +219,7 @@ describe("AgentServer.configureEnvironment", () => {
"x-posthog-property-task_internal": "true",
"x-posthog-property-signal_report_id": "report-123",
"x-posthog-property-ai_stage": "research",
"x-posthog-property-ai_session_id": "report-1:r2",
"x-posthog-property-task_id": "task-abc",
"x-posthog-property-task_run_id": "run-xyz",
"x-posthog-property-task_user_id": "42",
Expand All @@ -232,6 +234,7 @@ describe("AgentServer.configureEnvironment", () => {
originProduct: "signal_report",
signalReportId: "report-123",
aiStage: "research",
aiSessionId: "report-1:r2",
taskId: "task-abc",
taskRunId: "run-xyz",
taskUserId: 42,
Expand All @@ -244,6 +247,7 @@ describe("AgentServer.configureEnvironment", () => {
"x-posthog-property-task_internal: true",
"x-posthog-property-signal_report_id: report-123",
"x-posthog-property-ai_stage: research",
"x-posthog-property-ai_session_id: report-1:r2",
"x-posthog-property-task_id: task-abc",
"x-posthog-property-task_run_id: run-xyz",
"x-posthog-property-task_user_id: 42",
Expand Down
8 changes: 8 additions & 0 deletions packages/agent/src/server/agent-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,7 @@ export class AgentServer {
originProduct: preTask?.origin_product,
signalReportId: preTask?.signal_report,
aiStage: getTaskRunStateString(preTaskRun, "ai_stage"),
aiSessionId: getTaskRunStateString(preTaskRun, "ai_session_id"),
taskId: payload.task_id,
taskRunId: payload.run_id,
taskUserId: payload.user_id || preTask?.created_by?.id || null,
Expand Down Expand Up @@ -3912,6 +3913,7 @@ ${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}
originProduct,
signalReportId,
aiStage,
aiSessionId,
taskId,
taskRunId,
taskUserId,
Expand All @@ -3921,6 +3923,7 @@ ${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}
originProduct?: Task["origin_product"] | null;
signalReportId?: string | null;
aiStage?: string | null;
aiSessionId?: string | null;
taskId?: string | null;
taskRunId?: string | null;
taskUserId?: number | null;
Expand All @@ -3946,6 +3949,11 @@ ${signedCommitInstructions}${prLinkInstructions}${shellEfficiencyInstructions}
task_internal: isInternal,
signal_report_id: signalReportId,
ai_stage: aiStage,
// Session key for LLM analytics, grouping the run's generations under the caller's
// logical operation (e.g. one ReviewHog review turn). Transported unreserved — $-keys
// are stripped at gateway header boundaries — and promoted to `$ai_session_id` by the
// llm-gateway when it captures the event.
ai_session_id: aiSessionId,
task_id: taskId,
task_run_id: taskRunId,
task_user_id: taskUserId,
Expand Down
Loading