Skip to content
Merged
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
18 changes: 12 additions & 6 deletions @omniroute/opencode-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export function createOmniRouteProvider(options: OmniRouteProviderOptions): Open
const seen = new Set<string>();
for (const raw of modelList) {
const id =
typeof raw === "object" && raw !== null && "id" in raw
typeof raw === "object" && raw !== null && "id" in raw && typeof (raw as any).id === "string"
? (raw as { id: string }).id.trim()
: typeof raw === "string"
? raw.trim()
Expand All @@ -278,11 +278,17 @@ export function createOmniRouteProvider(options: OmniRouteProviderOptions): Open
if (typeof merged.tool_call === "boolean") entry.tool_call = merged.tool_call;

// Context window: live model entry (from API catalog) > modelContextLengths > static defaults
const liveContext = typeof raw === "object" && raw !== null
? (raw as { contextLength?: number }).contextLength
: undefined;
const contextLength = liveContext ?? options.modelContextLengths?.[id] ?? OMNIROUTE_DEFAULT_MODEL_CONTEXT_LENGTHS[id];
if (typeof contextLength === "number" && contextLength > 0) {
const liveContext =
typeof raw === "object" && raw !== null
? (raw as { contextLength?: number }).contextLength
: undefined;
const rawContextLength =
liveContext ??
options.modelContextLengths?.[id] ??
OMNIROUTE_DEFAULT_MODEL_CONTEXT_LENGTHS[id];
const contextLength =
typeof rawContextLength === "string" ? parseInt(rawContextLength, 10) : rawContextLength;
if (typeof contextLength === "number" && !isNaN(contextLength) && contextLength > 0) {
entry.limit = { context: contextLength };
}

Expand Down