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 b62f93383d..ab53562795 100644 --- a/packages/agent/src/server/agent-server.configure-environment.test.ts +++ b/packages/agent/src/server/agent-server.configure-environment.test.ts @@ -144,6 +144,23 @@ describe("AgentServer.configureEnvironment", () => { expect(env.anthropicBaseUrl).toBe("https://gateway.us.posthog.com/signals"); }); + it.each([{ isInternal: true }, { isInternal: false }] as const)( + "tags as conversations when origin_product is 'support_reply' (isInternal=$isInternal)", + ({ isInternal }) => { + const env = buildServer("background").configureEnvironment({ + isInternal, + originProduct: "support_reply", + }); + + expect(env.anthropicBaseUrl).toBe( + "https://gateway.us.posthog.com/conversations", + ); + expect(env.openaiBaseUrl).toBe( + "https://gateway.us.posthog.com/conversations/v1", + ); + }, + ); + it("forwards task metadata as anthropicCustomHeaders", () => { const env = buildServer("background").configureEnvironment({ isInternal: true, diff --git a/packages/agent/src/utils/gateway.test.ts b/packages/agent/src/utils/gateway.test.ts index 2320e7f452..9a2bc0a2aa 100644 --- a/packages/agent/src/utils/gateway.test.ts +++ b/packages/agent/src/utils/gateway.test.ts @@ -49,6 +49,16 @@ describe("resolveGatewayProduct", () => { originProduct: "posthog_ai", expected: "posthog_ai", }, + { + isInternal: false, + originProduct: "support_reply", + expected: "conversations", + }, + { + isInternal: true, + originProduct: "support_reply", + expected: "conversations", + }, ] as const)( "isInternal=$isInternal originProduct=$originProduct -> $expected", ({ isInternal, originProduct, expected }) => { diff --git a/packages/agent/src/utils/gateway.ts b/packages/agent/src/utils/gateway.ts index 7f024fbb88..cbab72646f 100644 --- a/packages/agent/src/utils/gateway.ts +++ b/packages/agent/src/utils/gateway.ts @@ -3,7 +3,8 @@ export type GatewayProduct = | "background_agents" | "signals" | "slack_app" - | "posthog_ai"; + | "posthog_ai" + | "conversations"; export function resolveGatewayProduct({ isInternal, @@ -21,6 +22,9 @@ export function resolveGatewayProduct({ if (originProduct === "signal_report" || originProduct === "signals_scout") { return "signals"; } + if (originProduct === "support_reply") { + return "conversations"; + } if (isInternal) { return "background_agents"; }