Skip to content
Merged
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
7 changes: 7 additions & 0 deletions open-sse/config/providerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export interface RegistryEntry {
modelsUrl?: string;
/** Prefix to prepend to model IDs before upstream API calls (e.g. "accounts/fireworks/models/") */
modelIdPrefix?: string;
/**
* Additional already-qualified model ID prefixes that must NOT receive `modelIdPrefix`
* (e.g. Fireworks router IDs "accounts/fireworks/routers/"). Prevents double-prefixing
* fully-qualified IDs that legitimately differ from `modelIdPrefix`. See issue #3133.
*/
acceptedModelIdPrefixes?: string[];
chatPath?: string;
clientVersion?: string;
timeoutMs?: number;
Expand Down Expand Up @@ -3037,6 +3043,7 @@ const _REGISTRY_EAGER: Record<string, RegistryEntry> = {
modelsUrl:
"https://api.fireworks.ai/v1/accounts/fireworks/models?filter=supports_serverless=true",
modelIdPrefix: "accounts/fireworks/models/",
acceptedModelIdPrefixes: ["accounts/fireworks/models/", "accounts/fireworks/routers/"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since DefaultExecutor automatically prepends entry.modelIdPrefix to the list of accepted prefixes (in open-sse/executors/default.ts), including "accounts/fireworks/models/" in acceptedModelIdPrefixes is redundant. Removing it keeps the registry clean and aligns with the JSDoc description of acceptedModelIdPrefixes as containing additional prefixes that differ from modelIdPrefix.

Suggested change
acceptedModelIdPrefixes: ["accounts/fireworks/models/", "accounts/fireworks/routers/"],
acceptedModelIdPrefixes: ["accounts/fireworks/routers/"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Redundancy in acceptedModelIdPrefixes - the canonical modelIdPrefix ("accounts/fireworks/models/") is already included in the check via the acceptedPrefixes array construction at line 516 in default.ts. Including it here duplicates the entry unnecessarily. Consider removing it to keep the configuration DRY: acceptedModelIdPrefixes: ["accounts/fireworks/routers/"]

authType: "apikey",
authHeader: "bearer",
models: [
Expand Down
12 changes: 10 additions & 2 deletions open-sse/executors/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,16 @@ export class DefaultExecutor extends BaseExecutor {
const entry = getRegistryEntry(this.provider);
if (entry?.modelIdPrefix) {
const body = withDefaults as Record<string, unknown>;
if (typeof body.model === "string" && !body.model.startsWith(entry.modelIdPrefix)) {
body.model = `${entry.modelIdPrefix}${body.model}`;
if (typeof body.model === "string") {
// Skip prepending when the model already carries the canonical prefix OR any
// other accepted fully-qualified prefix (e.g. Fireworks router IDs). #3133.
const acceptedPrefixes = [entry.modelIdPrefix, ...(entry.acceptedModelIdPrefixes ?? [])];
const alreadyQualified = acceptedPrefixes.some((prefix) =>
(body.model as string).startsWith(prefix)
);
if (!alreadyQualified) {
body.model = `${entry.modelIdPrefix}${body.model}`;
}
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/fireworks-model-id-prefix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ test("DefaultExecutor.transformRequest does not double-prepend modelIdPrefix", (
assert.equal((result as Record<string, unknown>).model, "accounts/fireworks/models/kimi-k2p6");
});

test("DefaultExecutor.transformRequest preserves fully-qualified fireworks router IDs (#3133)", () => {
const executor = new DefaultExecutor("fireworks");
const body = {
model: "accounts/fireworks/routers/kimi-k2p6-turbo",
messages: [{ role: "user", content: "hi" }],
};

const result = executor.transformRequest(
"accounts/fireworks/routers/kimi-k2p6-turbo",
body,
false,
{}
);

assert.equal(
(result as Record<string, unknown>).model,
"accounts/fireworks/routers/kimi-k2p6-turbo"
);
});

test("DefaultExecutor.transformRequest does not modify model for providers without modelIdPrefix", () => {
const executor = new DefaultExecutor("openai");
const body = { model: "gpt-4.1", messages: [{ role: "user", content: "hi" }] };
Expand Down