Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit aeb3d5e

Browse files
authored
fix(agent): bill loop runs as posthog_code (#3903)
1 parent 3132836 commit aeb3d5e

4 files changed

Lines changed: 32 additions & 1 deletion

File tree

packages/agent/src/server/agent-server.configure-environment.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ describe("AgentServer.configureEnvironment", () => {
166166
},
167167
);
168168

169+
it.each([{ isInternal: true }, { isInternal: false }] as const)(
170+
"tags as posthog_code when origin_product is 'loop' (isInternal=$isInternal)",
171+
({ isInternal }) => {
172+
const env = buildServer("background").configureEnvironment({
173+
isInternal,
174+
originProduct: "loop",
175+
});
176+
177+
expect(env.anthropicBaseUrl).toBe(
178+
"https://gateway.us.posthog.com/posthog_code",
179+
);
180+
expect(env.openaiBaseUrl).toBe(
181+
"https://gateway.us.posthog.com/posthog_code/v1",
182+
);
183+
},
184+
);
185+
169186
// The codex/OpenAI path sets provider http_headers rather than
170187
// ANTHROPIC_CUSTOM_HEADERS, so the same task metadata must be exposed as a
171188
// record — including team_id, which the Claude path adds separately in

packages/agent/src/utils/gateway.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ describe("resolveGatewayProduct", () => {
6161
originProduct: "support_reply",
6262
expected: "conversations",
6363
},
64+
{
65+
isInternal: true,
66+
originProduct: "loop",
67+
expected: "posthog_code",
68+
},
69+
{
70+
isInternal: false,
71+
originProduct: "loop",
72+
expected: "posthog_code",
73+
},
6474
] as const)(
6575
"isInternal=$isInternal originProduct=$originProduct -> $expected",
6676
({ isInternal, originProduct, expected }) => {

packages/agent/src/utils/gateway.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export function resolveGatewayProduct({
2525
if (originProduct === "support_reply") {
2626
return "conversations";
2727
}
28+
if (originProduct === "loop") {
29+
return "posthog_code";
30+
}
2831
if (isInternal) {
2932
return "background_agents";
3033
}

packages/shared/src/task.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export interface Task {
1616
| "session_summaries"
1717
| "signal_report"
1818
| "signals_scout"
19-
| "slack";
19+
| "slack"
20+
| "loop";
2021
signal_report?: string | null; // Inbox report UUID when origin_product is "signal_report"
2122
github_integration?: number | null;
2223
repository: string; // Format: "organization/repository" (e.g., "posthog/posthog-js")

0 commit comments

Comments
 (0)