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 @@ -166,6 +166,23 @@ describe("AgentServer.configureEnvironment", () => {
},
);

it.each([{ isInternal: true }, { isInternal: false }] as const)(
"tags as posthog_code when origin_product is 'loop' (isInternal=$isInternal)",
({ isInternal }) => {
const env = buildServer("background").configureEnvironment({
isInternal,
originProduct: "loop",
});

expect(env.anthropicBaseUrl).toBe(
"https://gateway.us.posthog.com/posthog_code",
);
expect(env.openaiBaseUrl).toBe(
"https://gateway.us.posthog.com/posthog_code/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
Expand Down
10 changes: 10 additions & 0 deletions packages/agent/src/utils/gateway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ describe("resolveGatewayProduct", () => {
originProduct: "support_reply",
expected: "conversations",
},
{
isInternal: true,
originProduct: "loop",
expected: "posthog_code",
},
{
isInternal: false,
originProduct: "loop",
expected: "posthog_code",
},
] as const)(
"isInternal=$isInternal originProduct=$originProduct -> $expected",
({ isInternal, originProduct, expected }) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/agent/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function resolveGatewayProduct({
if (originProduct === "support_reply") {
return "conversations";
}
if (originProduct === "loop") {
return "posthog_code";
}
if (isInternal) {
return "background_agents";
}
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export interface Task {
| "session_summaries"
| "signal_report"
| "signals_scout"
| "slack";
| "slack"
| "loop";
signal_report?: string | null; // Inbox report UUID when origin_product is "signal_report"
github_integration?: number | null;
repository: string; // Format: "organization/repository" (e.g., "posthog/posthog-js")
Expand Down
Loading