Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(desktop): match the go gateway's canonical model pin (#110973)

Brandon532b92230ef1
diff --git a/packages/agent/packages/agent-contracts/src/cloud-task-models.test.ts b/packages/agent/packages/agent-contracts/src/cloud-task-models.test.ts
index aaaedc8cdea3..a56ca7aebf0e 100644
--- a/packages/agent/packages/agent-contracts/src/cloud-task-models.test.ts
+++ b/packages/agent/packages/agent-contracts/src/cloud-task-models.test.ts
@@ -447,6 +447,26 @@ describe("applyAllowedModels", () => {
]);
});
+ it("matches a pin echoed in canonical spelling", () => {
+ const result = applyAllowedModels(
+ {
+ data: [
+ { id: "claude-opus-5-5", canonical: "anthropic/claude-opus-5.5" },
+ { id: "gpt-6-sol", canonical: "openai/gpt-6-sol" },
+ ],
+ },
+ {
+ productModels: ["claude-opus-5-5", "gpt-6-sol"],
+ allowedModels: ["anthropic/claude-opus-5.5"],
+ },
+ ) as { data: Array<Record<string, unknown>> };
+
+ expect(result.data.map((m) => [m.id, m.allowed])).toEqual([
+ ["claude-opus-5-5", true],
+ ["gpt-6-sol", false],
+ ]);
+ });
+
it("marks every kept entry allowed only when the pin is null", () => {
const result = applyAllowedModels(goBody, {
productModels: [],
diff --git a/packages/agent/packages/agent-contracts/src/cloud-task-models.ts b/packages/agent/packages/agent-contracts/src/cloud-task-models.ts
index 70e9fa64353f..c7b871bc5060 100644
--- a/packages/agent/packages/agent-contracts/src/cloud-task-models.ts
+++ b/packages/agent/packages/agent-contracts/src/cloud-task-models.ts
@@ -508,6 +508,8 @@ export interface AllowedModelsPin {
function modelNames(entry: Record<string, unknown>): string[] {
const names = typeof entry.id === "string" ? [entry.id] : [];
+ // The mint echoes the pin in canonical spelling (`anthropic/claude-opus-4.8`).
+ if (typeof entry.canonical === "string") names.push(entry.canonical);
if (Array.isArray(entry.aliases)) {
for (const alias of entry.aliases) {
if (typeof alias === "string") names.push(alias);
diff --git a/products/desktop/packages/core/src/llm-gateway/llm-gateway.test.ts b/products/desktop/packages/core/src/llm-gateway/llm-gateway.test.ts
index 0de09781ea59..e304014bfe55 100644
--- a/products/desktop/packages/core/src/llm-gateway/llm-gateway.test.ts
+++ b/products/desktop/packages/core/src/llm-gateway/llm-gateway.test.ts
@@ -703,6 +703,28 @@ describe("LlmGatewayService.prompt on the Go gateway", () => {
expect(goFetch).toHaveBeenCalledTimes(1);
});
+ it("keeps the requested model on a paid pin echoed in canonical spelling", async () => {
+ const goFetch = vi.fn().mockResolvedValue(createJsonResponse(SUCCESS_BODY));
+ const { service } = createService(vi.fn(), {
+ route: {
+ ...GO_ROUTE,
+ allowedModels: [
+ "anthropic/claude-haiku-4.5",
+ "anthropic/claude-opus-5.5",
+ ],
+ },
+ fetch: goFetch,
+ });
+
+ await service.prompt([{ role: "user", content: "hi" }], {
+ model: "claude-opus-5-5",
+ });
+
+ expect(JSON.parse(goFetch.mock.calls[0][1].body).model).toBe(
+ "claude-opus-5-5",
+ );
+ });
+
it("keeps the requested model when the pin is null or empty", async () => {
for (const allowedModels of [null, []]) {
const goFetch = vi
diff --git a/products/desktop/packages/core/src/llm-gateway/llm-gateway.ts b/products/desktop/packages/core/src/llm-gateway/llm-gateway.ts
index 7a66eacd7cbb..04bcfca6ca28 100644
--- a/products/desktop/packages/core/src/llm-gateway/llm-gateway.ts
+++ b/products/desktop/packages/core/src/llm-gateway/llm-gateway.ts
@@ -60,9 +60,17 @@ type SendOptions = {
// The Go gateway's model for a helper prompt, picked from the token's pin
// so a free-tier token never spends a round trip on a refused model.
+// A paid pin is the whole product list; Go enforces it in canonical spelling,
+// which a bare requested id never string-matches.
function pickGoModel(route: GoRoute, requested: string): string {
const allowed = route.allowedModels;
- if (allowed === null || allowed.includes(requested)) return requested;
+ if (
+ allowed === null ||
+ route.plan === "paid" ||
+ allowed.includes(requested)
+ ) {
+ return requested;
+ }
if (route.plan === "free" && allowed.includes(FREE_TIER_GATEWAY_MODEL)) {
return FREE_TIER_GATEWAY_MODEL;
}