Skip to content

Commit ca6a9fa

Browse files
authored
Only uppercase known provider acronyms (GPT, GLM)
Limit acronym uppercasing to GPT and GLM so ordinary Cloudflare model names (e.g. llama-3.1-8b-instruct) are not mangled into misleading all-caps labels. Addresses a Greptile review finding. Generated-By: PostHog Code Task-Id: ea8239ab-8fc1-46b7-8dc6-d3661caf8800
1 parent c520469 commit ca6a9fa

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/agent/src/gateway-models.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ describe("formatGatewayModelName", () => {
7474
).toBe("GLM-5.2");
7575
});
7676

77+
it("leaves non-acronym Cloudflare models lowercase", () => {
78+
expect(
79+
formatGatewayModelName({
80+
id: "@cf/meta/llama-3.1-8b-instruct",
81+
owned_by: "cloudflare",
82+
context_window: 128000,
83+
supports_streaming: true,
84+
supports_vision: false,
85+
allowed: true,
86+
}),
87+
).toBe("llama-3.1-8b-instruct");
88+
});
89+
7790
it("blocks deprecated Claude gateway models", () => {
7891
expect(isBlockedModelId("claude-opus-4-5")).toBe(true);
7992
expect(isBlockedModelId("claude-opus-4-6")).toBe(true);

packages/agent/src/gateway-models.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,14 @@ export function compareModelsForPicker(a: string, b: string): number {
286286

287287
const PROVIDER_PREFIXES = ["anthropic/", "openai/", "google-vertex/"];
288288

289-
// Uppercase the acronym, keep the version attached, title-case any suffix:
290-
// "gpt-5.6-sol" -> "GPT-5.6 Sol", "glm-5.2" -> "GLM-5.2".
289+
const KNOWN_ACRONYMS = new Set(["gpt", "glm"]);
290+
291+
// For a known acronym, uppercase it, keep the version attached, and title-case
292+
// any suffix: "gpt-5.6-sol" -> "GPT-5.6 Sol", "glm-5.2" -> "GLM-5.2". Other ids
293+
// stay lowercase to avoid mangling ordinary names (e.g. "llama-3.1-8b").
291294
function formatProviderModelName(modelId: string): string {
292295
const [acronym, version, ...suffix] = modelId.split("-");
296+
if (!KNOWN_ACRONYMS.has(acronym.toLowerCase())) return modelId.toLowerCase();
293297
const head = version
294298
? `${acronym.toUpperCase()}-${version}`
295299
: acronym.toUpperCase();

0 commit comments

Comments
 (0)