fix(omp): show model names with slashes and underscores in full (#9836)
OMP model labels were built as `${provider}/${name}` and then cut at the
last `/`, so a free-text name such as "... ~60-70 tok/s on 0.2.10, 52/56)"
showed as "56)". Underscores were rewritten to spaces ("IQ3_S" -> "IQ3 S"),
and a colon inside the name cut everything before it.
Pi had the same bug, fixed in #9823. Move that label rule into a shared
model-label module and use it for both providers: free-text names are
kept, path-like names are shortened to their last segment, and a
"Vendor: " prefix is dropped only when it is a prefix.
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
Co-authored-by: Rahul Sharma <19687913+rms523@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
6 files changed
+97
-62
No files matched your search
@@ -0,0 +1,21 @@
|
||||
// Drops an upstream "Vendor: " prefix ("OpenAI: GPT-5.5"). A colon inside parentheses or after a
|
||||
// comma belongs to the model name ("DeepSeek V4 (ctx: 128k)"), so it is kept.
|
||||
function stripVendorPrefix(label: string): string {
|
||||
const vendorSeparatorIndex = label.indexOf(": ");
|
||||
if (vendorSeparatorIndex === -1 || /[(),]/.test(label.slice(0, vendorSeparatorIndex))) {
|
||||
return label;
|
||||
}
|
||||
return label.slice(vendorSeparatorIndex + 2).trim();
|
||||
}
|
||||
|
||||
// The label Pi and OMP show for a model from their catalogs. A model name is either a path
|
||||
// ("google/gemini_2.5-flash", as OpenRouter reports it) or free text that can contain slashes
|
||||
// and underscores ("IQ3_S ... 52/56"). Only paths are shortened.
|
||||
export function modelDisplayLabel(model: { id: string; name?: string }): string {
|
||||
const text = model.name?.trim().replace(/\s+/g, " ") || model.id.trim();
|
||||
if (/\s/.test(text)) {
|
||||
return stripVendorPrefix(text);
|
||||
}
|
||||
const lastSegment = text.split("/").findLast((segment) => segment.length > 0) ?? text;
|
||||
return stripVendorPrefix(lastSegment.replace(/_+/g, " "));
|
||||
}
|
||||
@@ -1855,3 +1855,69 @@ test("closing OMP during image conversion rejects its pending start", async () =
|
||||
await session.close();
|
||||
await rejected;
|
||||
});
|
||||
|
||||
describe("OMP catalog model labels", () => {
|
||||
test.each([
|
||||
{
|
||||
name: "keeps slashes and underscores inside a free-text model name",
|
||||
model: {
|
||||
provider: "llama-swap",
|
||||
id: "s-q3fn(p-t)",
|
||||
name: "Qwen3.8 Flash Next IQ3_S, prior + tail skip (fastest, ~60-70 tok/s on 0.2.10, 52/56)",
|
||||
},
|
||||
label: "Qwen3.8 Flash Next IQ3_S, prior + tail skip (fastest, ~60-70 tok/s on 0.2.10, 52/56)",
|
||||
},
|
||||
{
|
||||
name: "keeps a free-text name that ends in a slash-separated word",
|
||||
model: {
|
||||
provider: "llama-swap",
|
||||
id: "ds-strata-6",
|
||||
name: "DeepSeek V4.1 Flash 2.25bpw via Strata (full 6 experts, untested, ~5-6 tok/s)",
|
||||
},
|
||||
label: "DeepSeek V4.1 Flash 2.25bpw via Strata (full 6 experts, untested, ~5-6 tok/s)",
|
||||
},
|
||||
{
|
||||
name: "keeps a colon inside a free-text model name",
|
||||
model: {
|
||||
provider: "llama-swap",
|
||||
id: "qwen3-tail",
|
||||
name: "Qwen3 IQ3_S (tail skip: on, 52/56)",
|
||||
},
|
||||
label: "Qwen3 IQ3_S (tail skip: on, 52/56)",
|
||||
},
|
||||
{
|
||||
name: "keeps an OMP catalog name as it is",
|
||||
model: {
|
||||
provider: "openrouter",
|
||||
id: "anthropic/claude-opus-4.1:batch",
|
||||
name: "Claude Opus 4.1 (batch)",
|
||||
},
|
||||
label: "Claude Opus 4.1 (batch)",
|
||||
},
|
||||
{
|
||||
name: "drops the vendor prefix from an upstream model name",
|
||||
model: { provider: "openrouter", id: "openai/gpt-5.5", name: "OpenAI: GPT-5.5" },
|
||||
label: "GPT-5.5",
|
||||
},
|
||||
{
|
||||
name: "falls back to the last segment of a path-like id",
|
||||
model: { provider: "pioneer", id: "canada-quant/glm_5.2" },
|
||||
label: "glm 5.2",
|
||||
},
|
||||
])("$name", async ({ model, label }) => {
|
||||
const runtime = new FakeOmp();
|
||||
runtime.queueSessionSetup((session) => {
|
||||
session.models = [model];
|
||||
});
|
||||
const client = new OmpAgentClient({ logger: createTestLogger(), runtime });
|
||||
|
||||
const catalog = await client.fetchCatalog({
|
||||
scope: "workspace",
|
||||
cwd: "/workspace/project",
|
||||
force: false,
|
||||
});
|
||||
|
||||
expect(catalog.models.map((entry) => entry.label)).toEqual([label]);
|
||||
expect(catalog.models[0]?.id).toBe(`${model.provider}/${model.id}`);
|
||||
});
|
||||
});
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
type AgentLaunchContext,
|
||||
type AgentMetadata,
|
||||
type AgentMode,
|
||||
type AgentModelDefinition,
|
||||
type AgentPermissionRequest,
|
||||
type AgentPermissionResponse,
|
||||
type AgentProviderNotice,
|
||||
@@ -252,36 +251,6 @@ interface OmpSlashCommandInvocation {
|
||||
|
||||
type AutoCompactMode = boolean | "toggle" | "unknown";
|
||||
|
||||
function normalizeOmpModelLabel(label: string): string {
|
||||
const normalizedLabel = label.trim().replace(/[_\s]+/g, " ");
|
||||
const vendorSeparatorIndex = normalizedLabel.indexOf(": ");
|
||||
if (vendorSeparatorIndex === -1) {
|
||||
return normalizedLabel;
|
||||
}
|
||||
|
||||
return normalizedLabel.slice(vendorSeparatorIndex + 2).trim();
|
||||
}
|
||||
|
||||
export function transformOmpModels(models: AgentModelDefinition[]): AgentModelDefinition[] {
|
||||
return models.map((model) => {
|
||||
if (!model.label.includes("/")) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const segments = model.label.split("/").filter((segment) => segment.length > 0);
|
||||
const rawLabel = segments.at(-1);
|
||||
if (!rawLabel) {
|
||||
return model;
|
||||
}
|
||||
|
||||
return {
|
||||
...model,
|
||||
label: normalizeOmpModelLabel(rawLabel),
|
||||
description: model.description ?? model.label,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function isOmpThinkingLevel(value: string | null | undefined): value is OmpThinkingLevel {
|
||||
return (
|
||||
value === "off" ||
|
||||
@@ -2571,13 +2540,11 @@ export class OmpAgentClient implements AgentClient {
|
||||
});
|
||||
if (!runtimeSession) throw new Error("OMP catalog runtime did not start");
|
||||
const catalogSession = runtimeSession;
|
||||
const models = transformOmpModels(
|
||||
(
|
||||
await runProviderRefreshActivity(context, "get_available_models", () =>
|
||||
catalogSession.getAvailableModels(null),
|
||||
)
|
||||
).map((model) => mapOmpModel(model, this.provider)),
|
||||
);
|
||||
const models = (
|
||||
await runProviderRefreshActivity(context, "get_available_models", () =>
|
||||
catalogSession.getAvailableModels(null),
|
||||
)
|
||||
).map((model) => mapOmpModel(model, this.provider));
|
||||
return { models, modes: [...OMP_MODES] };
|
||||
} finally {
|
||||
context?.signal.removeEventListener("abort", handleAbort);
|
||||
|
||||
@@ -164,7 +164,7 @@ describe("mapOmpModel thinking options", () => {
|
||||
|
||||
expect(result.provider).toBe("omp");
|
||||
expect(result.id).toBe("pioneer/canada-quant/glm-5.2");
|
||||
expect(result.label).toBe("pioneer/GLM-5.2");
|
||||
expect(result.label).toBe("GLM-5.2");
|
||||
expect(result.metadata).toEqual({ provider: "pioneer", modelId: "canada-quant/glm-5.2" });
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
AgentProvider,
|
||||
AgentSelectOption,
|
||||
} from "../../agent-sdk-types.js";
|
||||
import { modelDisplayLabel } from "../model-label.js";
|
||||
import type { OmpModel, OmpThinkingLevel } from "./rpc-types.js";
|
||||
|
||||
export const DEFAULT_OMP_THINKING_LEVEL: OmpThinkingLevel = "medium";
|
||||
@@ -43,7 +44,7 @@ export function mapOmpModel(model: OmpModel, provider: AgentProvider): AgentMode
|
||||
return {
|
||||
provider,
|
||||
id: `${model.provider}/${model.id}`,
|
||||
label: `${model.provider}/${model.name ?? model.id}`,
|
||||
label: modelDisplayLabel(model),
|
||||
description: `${model.provider}/${model.id}`,
|
||||
metadata: {
|
||||
provider: model.provider,
|
||||
|
||||
@@ -83,6 +83,7 @@ import {
|
||||
listPiImportableSessions,
|
||||
readPiImportSessionConfig,
|
||||
} from "./session-descriptor.js";
|
||||
import { modelDisplayLabel } from "../model-label.js";
|
||||
import type { PiRuntime, PiRuntimeSession, PiStartSessionInput } from "./runtime.js";
|
||||
import type {
|
||||
PiAgentSessionEvent,
|
||||
@@ -313,27 +314,6 @@ interface PiSlashCommandInvocation {
|
||||
|
||||
type AutoCompactMode = boolean | "toggle" | "unknown";
|
||||
|
||||
// Drops an upstream "Vendor: " prefix ("OpenAI: GPT-5.5"). A colon inside parentheses or after a
|
||||
// comma belongs to the model name ("DeepSeek V4 (ctx: 128k)"), so it is kept.
|
||||
function stripVendorPrefix(label: string): string {
|
||||
const vendorSeparatorIndex = label.indexOf(": ");
|
||||
if (vendorSeparatorIndex === -1 || /[(),]/.test(label.slice(0, vendorSeparatorIndex))) {
|
||||
return label;
|
||||
}
|
||||
return label.slice(vendorSeparatorIndex + 2).trim();
|
||||
}
|
||||
|
||||
// A Pi model name is either a path ("google/gemini_2.5-flash", as OpenRouter reports it) or
|
||||
// free text that can contain slashes and underscores ("IQ3_S ... 52/56"). Only shorten paths.
|
||||
function piModelLabel(model: Pick<PiModel, "id" | "name">): string {
|
||||
const text = model.name?.trim().replace(/\s+/g, " ") || model.id.trim();
|
||||
if (/\s/.test(text)) {
|
||||
return stripVendorPrefix(text);
|
||||
}
|
||||
const lastSegment = text.split("/").findLast((segment) => segment.length > 0) ?? text;
|
||||
return stripVendorPrefix(lastSegment.replace(/_+/g, " "));
|
||||
}
|
||||
|
||||
function isPiThinkingLevel(value: string | null | undefined): value is PiThinkingLevel {
|
||||
return (
|
||||
value === "off" ||
|
||||
@@ -1157,7 +1137,7 @@ function mapPiModel(model: PiModel, provider: AgentProvider): AgentModelDefiniti
|
||||
return {
|
||||
provider,
|
||||
id: `${model.provider}/${model.id}`,
|
||||
label: piModelLabel(model),
|
||||
label: modelDisplayLabel(model),
|
||||
description: `${model.provider}/${model.id}`,
|
||||
metadata: {
|
||||
provider: model.provider,
|
||||
|
||||
Reference in new issue
Block a user