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
13 changes: 9 additions & 4 deletions apps/web/utils/llms/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,15 @@ function selectModel(
function createOpenRouterProviderOptions(
providers: string,
): Record<string, any> {
const order = providers
.split(",")
.map((p: string) => p.trim())
.filter(Boolean);

return {
openrouter: {
provider: {
order: providers.split(",").map((p: string) => p.trim()),
},
provider: order.length > 0 ? { order } : undefined,
reasoning: { max_tokens: 20 },
},
};
}
Expand Down Expand Up @@ -282,7 +286,8 @@ function selectDefaultModel(userAi: UserAIFields): SelectModel {
let aiModel: string | null = null;
const aiApiKey = userAi.aiApiKey;

const providerOptions: Record<string, any> = {};
const providerOptions: Record<string, any> =
createOpenRouterProviderOptions("");
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Sep 16, 2025

Choose a reason for hiding this comment

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

Initializing providerOptions with createOpenRouterProviderOptions("") sets openrouter and prevents DEFAULT_OPENROUTER_PROVIDERS override from applying.

Prompt for AI agents
Address the following comment on apps/web/utils/llms/model.ts at line 290:

<comment>Initializing providerOptions with createOpenRouterProviderOptions(&quot;&quot;) sets openrouter and prevents DEFAULT_OPENROUTER_PROVIDERS override from applying.</comment>

<file context>
@@ -282,7 +286,8 @@ function selectDefaultModel(userAi: UserAIFields): SelectModel {
 
-  const providerOptions: Record&lt;string, any&gt; = {};
+  const providerOptions: Record&lt;string, any&gt; =
+    createOpenRouterProviderOptions(&quot;&quot;);
 
   // If user has not api key set, then use default model
</file context>
Suggested change
createOpenRouterProviderOptions("");
{};
Fix with Cubic


Comment on lines +289 to 291
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.

⚠️ Potential issue

Regression: DEFAULT_OPENROUTER_PROVIDERS never applied.
Pre‑initializing providerOptions.openrouter prevents the later merge (guarded by !providerOptions.openrouter). Result: default provider ordering from env is ignored.

Minimal fix: initialize as empty, and always layer OpenRouter options (ensuring reasoning is present) only when aiProvider is OPENROUTER.

-  const providerOptions: Record<string, any> =
-    createOpenRouterProviderOptions("");
+  const providerOptions: Record<string, any> = {};
-  if (
-    aiProvider === Provider.OPENROUTER &&
-    env.DEFAULT_OPENROUTER_PROVIDERS &&
-    !providerOptions.openrouter
-  ) {
-    const openRouterOptions = createOpenRouterProviderOptions(
-      env.DEFAULT_OPENROUTER_PROVIDERS,
-    );
-    Object.assign(providerOptions, openRouterOptions);
-  }
+  if (aiProvider === Provider.OPENROUTER) {
+    const openRouterOptions = createOpenRouterProviderOptions(
+      env.DEFAULT_OPENROUTER_PROVIDERS || "",
+    );
+    // Preserve any custom options set earlier; always ensure reasoning exists.
+    providerOptions.openrouter = {
+      ...openRouterOptions.openrouter,          // reasoning + env order
+      ...(providerOptions.openrouter || {}),    // custom models/provider override env if present
+      reasoning: {
+        ...openRouterOptions.openrouter.reasoning,
+        ...(providerOptions.openrouter?.reasoning ?? {}),
+      },
+    };
+  }

Also applies to: 365-373

🤖 Prompt for AI Agents
In apps/web/utils/llms/model.ts around lines 289-291 (and similarly lines
365-373), providerOptions is pre-initialized with
createOpenRouterProviderOptions(""), which prevents the later merge guarded by
!providerOptions.openrouter and thus stops DEFAULT_OPENROUTER_PROVIDERS from
being applied; change to initialize providerOptions as an empty object (e.g.,
{}) and only add/merge OpenRouter options when aiProvider === OPENROUTER
(ensuring to include the required reasoning flag), so default ordering from env
can be merged correctly.

// If user has not api key set, then use default model
// If they do they can use the model of their choice
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.9.35
v2.9.36
Loading