Skip to content

Commit c112688

Browse files
Merge pull request #377 from alichherawalla/fix/remote-drop-max-tokens-cap
fix(remote): stop sending max_tokens/num_predict to remote servers
2 parents a7bc414 + 890cd2f commit c112688

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/services/providers/openAICompatibleProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ export class OpenAICompatibleProvider implements LLMProvider {
9999
messages: openaiMessages,
100100
stream: true,
101101
...(options.temperature !== undefined && { temperature: options.temperature }),
102-
...(options.maxTokens !== undefined && { max_tokens: options.maxTokens }),
102+
// max_tokens intentionally omitted — the remote server owns output limits.
103+
// A client-side cap (default 1024) silently truncates reasoning models that
104+
// need a larger budget for <think> blocks (Qwen3, DeepSeek-R1, etc).
103105
...(options.topP !== undefined && { top_p: options.topP }),
104106
...(options.tools && options.tools.length > 0 && { tools: options.tools, tool_choice: 'auto' }),
105107
// LM Studio only: control Qwen3 thinking per-request via chat_template_kwargs.

src/services/providers/openAICompatibleStream.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ export async function generateOllamaChatImpl(
289289
...(options.tools && options.tools.length > 0 && { tools: options.tools }),
290290
options: {
291291
...(options.temperature !== undefined && { temperature: options.temperature }),
292-
...(options.maxTokens !== undefined && { num_predict: options.maxTokens }),
292+
// num_predict intentionally omitted — Ollama defaults to -1 (until natural stop).
293+
// A client-side cap truncates reasoning models mid-<think>.
293294
...(options.topP !== undefined && { top_p: options.topP }),
294295
},
295296
};

0 commit comments

Comments
 (0)