Skip to content

Commit bee97ff

Browse files
committed
fix(sync): preserve Anthropic base model inheritance
1 parent 813e26c commit bee97ff

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

packages/core/src/sync/providers/anthropic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export const anthropic = {
9999
translateModel(model, context) {
100100
const existing = context.existing(model.id);
101101
if (existing !== undefined) {
102-
return { id: model.id, model: buildAnthropicModel(model, existing) };
102+
const baseModel = context.authored(model.id)?.base_model;
103+
return { id: model.id, model: buildAnthropicModel(model, existing, baseModel) };
103104
}
104105

105106
const baseModel = `anthropic/${model.id}`;

packages/core/test/sync.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from "node:path";
55

66
import { formatToml, preserveReasoningOptions, syncProvider, type SyncProvider } from "../src/sync/index.js";
77
import {
8+
anthropic,
89
buildAnthropicModel,
910
parseAnthropicPricing,
1011
type AnthropicModel,
@@ -131,6 +132,42 @@ test("labels Anthropic aliases as latest", () => {
131132
expect(model.name).toBe("Claude Sonnet 5 (latest)");
132133
});
133134

135+
test("Anthropic sync preserves base model inheritance", () => {
136+
const resolved = {
137+
base_model: "anthropic/claude-opus-4-5",
138+
name: "Claude Opus 4.5 (latest)",
139+
description: "Flagship Claude model",
140+
release_date: "2025-11-24",
141+
last_updated: "2025-11-24",
142+
attachment: true,
143+
reasoning: true,
144+
tool_call: true,
145+
knowledge: "2025-05",
146+
open_weights: false,
147+
cost: { input: 5, output: 25 },
148+
limit: { context: 200_000, output: 64_000 },
149+
modalities: { input: ["text" as const, "image" as const], output: ["text" as const] },
150+
};
151+
const translated = anthropic.translateModel(anthropicModel({
152+
id: "claude-opus-4-5",
153+
canonical_id: "claude-opus-4-5-20251101",
154+
display_name: "Claude Opus 4.5",
155+
created_at: "2025-11-24T00:00:00Z",
156+
max_input_tokens: 200_000,
157+
max_tokens: 64_000,
158+
}), {
159+
existing: () => resolved,
160+
authored: () => ({ base_model: "anthropic/claude-opus-4-5" }),
161+
});
162+
163+
expect(translated?.model).toMatchObject({
164+
base_model: "anthropic/claude-opus-4-5",
165+
name: "Claude Opus 4.5 (latest)",
166+
});
167+
expect(translated?.model).not.toHaveProperty("knowledge");
168+
expect(translated?.model).not.toHaveProperty("release_date");
169+
});
170+
134171
test("filters customer-owned OpenAI models from availability tracking", () => {
135172
expect(parseOpenAIModels({
136173
object: "list",

0 commit comments

Comments
 (0)