diff --git a/packages/agent/src/server/agent-server.configure-environment.test.ts b/packages/agent/src/server/agent-server.configure-environment.test.ts index d16673f4aa..0ae96970f6 100644 --- a/packages/agent/src/server/agent-server.configure-environment.test.ts +++ b/packages/agent/src/server/agent-server.configure-environment.test.ts @@ -183,6 +183,20 @@ describe("AgentServer.configureEnvironment", () => { }, ); + it("tags as onboarding when a wizard cloud run reaches the gateway", () => { + const env = buildServer("background").configureEnvironment({ + isInternal: false, + originProduct: "onboarding", + }); + + expect(env.anthropicBaseUrl).toBe( + "https://gateway.us.posthog.com/onboarding", + ); + expect(env.openaiBaseUrl).toBe( + "https://gateway.us.posthog.com/onboarding/v1", + ); + }); + // The codex/OpenAI path sets provider http_headers rather than // ANTHROPIC_CUSTOM_HEADERS, so the same task metadata must be exposed as a // record — including team_id, which the Claude path adds separately in diff --git a/packages/agent/src/utils/gateway.ts b/packages/agent/src/utils/gateway.ts index cf9c53c09c..c9ef17df70 100644 --- a/packages/agent/src/utils/gateway.ts +++ b/packages/agent/src/utils/gateway.ts @@ -4,7 +4,8 @@ export type GatewayProduct = | "signals" | "slack_app" | "posthog_ai" - | "conversations"; + | "conversations" + | "onboarding"; export function resolveGatewayProduct({ isInternal, @@ -13,20 +14,18 @@ export function resolveGatewayProduct({ isInternal?: boolean; originProduct?: string | null; } = {}): GatewayProduct { - if (originProduct === "slack") { - return "slack_app"; - } - if (originProduct === "posthog_ai") { - return "posthog_ai"; - } - if (originProduct === "signal_report" || originProduct === "signals_scout") { - return "signals"; - } - if (originProduct === "support_reply") { - return "conversations"; - } - if (originProduct === "loop") { - return "posthog_code"; + const originProductToGatewayProductMap: Record = { + loop: "posthog_code", + onboarding: "onboarding", + posthog_ai: "posthog_ai", + signal_report: "signals", + signals_scout: "signals", + slack: "slack_app", + support_reply: "conversations", + }; + + if (originProduct && originProduct in originProductToGatewayProductMap) { + return originProductToGatewayProductMap[originProduct]; } if (isInternal) { return "background_agents";