-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Limit reasoning tokens used #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
@@ -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(""); | ||
|
|
||
|
Comment on lines
+289
to
291
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regression: DEFAULT_OPENROUTER_PROVIDERS never applied. 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 |
||
| // If user has not api key set, then use default model | ||
| // If they do they can use the model of their choice | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v2.9.35 | ||
| v2.9.36 |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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