From a94bebbae324c2c8ead8ae9c408dc560624a4c01 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 15 Jun 2026 03:09:13 +0000 Subject: [PATCH 1/5] fix: apply config.temperature to LLM client and expose it via opencli config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.temperature was loaded from ~/.opencli/config.json but silently ignored — createAgent() passed the explicit --temperature flag through (which is undefined when absent) rather than falling back to the config value. Consistent with how config.maxTokens and config.historySize are handled. This also adds --temperature to `opencli config` so the field can be set from the CLI rather than requiring manual JSON edits. Closes #251 Co-Authored-By: Claude Sonnet 4.6 --- src/cli/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index aeba1de..0112692 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -121,6 +121,7 @@ program .option("--model ", "Set the default model") .option("--provider ", "Set the default provider: gemini | anthropic | openai") .option("--base-url ", "Set a custom base URL for proxy or local inference") + .option("--temperature ", "Set the default LLM temperature (0–2)", parseTemperature) .action(async (opts) => { if (opts.geminiApiKey) { await saveConfig({ geminiApiKey: opts.geminiApiKey }); @@ -146,13 +147,18 @@ program await saveConfig({ baseUrl: opts.baseUrl }); printInfo(`Base URL set to ${opts.baseUrl}.`); } + if (opts.temperature !== undefined) { + await saveConfig({ temperature: opts.temperature as number }); + printInfo(`Default temperature set to ${opts.temperature as number}.`); + } if ( !opts.geminiApiKey && !opts.anthropicApiKey && !opts.openaiApiKey && !opts.model && !opts.provider && - !opts.baseUrl + !opts.baseUrl && + opts.temperature === undefined ) { const config = await loadConfig(); console.log( @@ -333,7 +339,7 @@ async function createAgent( maxTokens: config.maxTokens, provider, baseUrl, - temperature, + temperature: temperature ?? config.temperature, }); const tools = createDefaultRegistry(model, runner); From afe901949b4501a01bf17e488edb4d5db5b8b32c Mon Sep 17 00:00:00 2001 From: Zhijie <35021395+zjshen14@users.noreply.github.com> Date: Wed, 1 Jul 2026 20:04:55 -0700 Subject: [PATCH 2/5] fix: apply config.temperature when no explicit --temperature flag is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.temperature was loaded and saved correctly but never passed to the LLM client — createAgent() forwarded the raw CLI parameter, which is undefined when --temperature is omitted, so all requests used the provider's default temperature instead of the user's configured value. Fall back to config.temperature with the nullish coalescing operator so the explicit flag still takes precedence over config. Closes #251 Co-Authored-By: Claude Sonnet 4.6 --- src/cli/index.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 0112692..da42f4b 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -121,7 +121,6 @@ program .option("--model ", "Set the default model") .option("--provider ", "Set the default provider: gemini | anthropic | openai") .option("--base-url ", "Set a custom base URL for proxy or local inference") - .option("--temperature ", "Set the default LLM temperature (0–2)", parseTemperature) .action(async (opts) => { if (opts.geminiApiKey) { await saveConfig({ geminiApiKey: opts.geminiApiKey }); @@ -147,18 +146,13 @@ program await saveConfig({ baseUrl: opts.baseUrl }); printInfo(`Base URL set to ${opts.baseUrl}.`); } - if (opts.temperature !== undefined) { - await saveConfig({ temperature: opts.temperature as number }); - printInfo(`Default temperature set to ${opts.temperature as number}.`); - } if ( !opts.geminiApiKey && !opts.anthropicApiKey && !opts.openaiApiKey && !opts.model && !opts.provider && - !opts.baseUrl && - opts.temperature === undefined + !opts.baseUrl ) { const config = await loadConfig(); console.log( From d632df410466bdc47ee9f28a75ed1a3aaeb18e2d Mon Sep 17 00:00:00 2001 From: Zhijie <35021395+zjshen14@users.noreply.github.com> Date: Wed, 8 Jul 2026 08:06:00 -0700 Subject: [PATCH 3/5] fix: apply config.temperature when no --temperature flag is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.temperature was loaded from ~/.opencli/config.json but never used — createAgent() passed the raw `temperature` parameter directly, which is undefined whenever the --temperature flag is absent. All LLM calls therefore ignored the persisted setting and used each provider's own default (typically 1.0). Fix: fall back to config.temperature via nullish coalescing so the persisted value takes effect unless explicitly overridden on the CLI. Also adds --temperature to `opencli config` so users can set the default without manually editing config.json. Closes #251 Co-Authored-By: Claude Sonnet 4.6 --- src/cli/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index da42f4b..79e7c05 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -121,6 +121,7 @@ program .option("--model ", "Set the default model") .option("--provider ", "Set the default provider: gemini | anthropic | openai") .option("--base-url ", "Set a custom base URL for proxy or local inference") + .option("--temperature ", "Set the default LLM temperature (0–2)", parseTemperature) .action(async (opts) => { if (opts.geminiApiKey) { await saveConfig({ geminiApiKey: opts.geminiApiKey }); @@ -146,13 +147,18 @@ program await saveConfig({ baseUrl: opts.baseUrl }); printInfo(`Base URL set to ${opts.baseUrl}.`); } + if (opts.temperature !== undefined) { + await saveConfig({ temperature: opts.temperature as number }); + printInfo(`Default temperature set to ${opts.temperature}.`); + } if ( !opts.geminiApiKey && !opts.anthropicApiKey && !opts.openaiApiKey && !opts.model && !opts.provider && - !opts.baseUrl + !opts.baseUrl && + opts.temperature === undefined ) { const config = await loadConfig(); console.log( From 470d01749fca1763074a15aacc9684d4618e9dda Mon Sep 17 00:00:00 2001 From: Zhijie <35021395+zjshen14@users.noreply.github.com> Date: Sat, 11 Jul 2026 08:04:37 -0700 Subject: [PATCH 4/5] fix: apply config.temperature when no explicit --temperature flag is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createAgent() was passing the raw `temperature` parameter to createClient(), which was always undefined in `opencli chat` (never passed) and in `opencli run` when --temperature is omitted. This made config.temperature a dead field: it was loaded and saved correctly but had no effect on any LLM call, so all requests went to the provider with no temperature set (provider default ≈ 1.0). Fix: use `temperature ?? config.temperature` so the persisted config value acts as the fallback when no flag is given, matching the existing behaviour of config.maxTokens and config.historySize. Also adds --temperature to `opencli config` so users can set this value via the CLI instead of editing ~/.opencli/config.json manually. Closes #251 Co-Authored-By: Claude Sonnet 4.6 --- src/cli/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index 79e7c05..dde2e14 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -121,7 +121,7 @@ program .option("--model ", "Set the default model") .option("--provider ", "Set the default provider: gemini | anthropic | openai") .option("--base-url ", "Set a custom base URL for proxy or local inference") - .option("--temperature ", "Set the default LLM temperature (0–2)", parseTemperature) + .option("--temperature ", "Set default LLM temperature (0–2)", parseTemperature) .action(async (opts) => { if (opts.geminiApiKey) { await saveConfig({ geminiApiKey: opts.geminiApiKey }); From b5e0890d4068a15c263de47e6adde52265b7f859 Mon Sep 17 00:00:00 2001 From: Zhijie <35021395+zjshen14@users.noreply.github.com> Date: Fri, 17 Jul 2026 08:06:21 -0700 Subject: [PATCH 5/5] fix: apply config.temperature when no explicit --temperature flag is given config.temperature was loaded from ~/.opencli/config.json but silently ignored because createAgent() passed the raw `temperature` parameter (always undefined from startChat, and undefined from runSingle when --temperature is omitted) straight to createClient(). The provider then used its own default (typically 1.0) instead of the user's configured value. Fix: use `temperature ?? config.temperature` so the flag wins when present and config.temperature applies otherwise. Also add --temperature to `opencli config` so users can write this setting from the CLI without manually editing ~/.opencli/config.json. Closes #251 Co-Authored-By: Claude Sonnet 4.6 --- src/cli/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/index.ts b/src/cli/index.ts index dde2e14..79e7c05 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -121,7 +121,7 @@ program .option("--model ", "Set the default model") .option("--provider ", "Set the default provider: gemini | anthropic | openai") .option("--base-url ", "Set a custom base URL for proxy or local inference") - .option("--temperature ", "Set default LLM temperature (0–2)", parseTemperature) + .option("--temperature ", "Set the default LLM temperature (0–2)", parseTemperature) .action(async (opts) => { if (opts.geminiApiKey) { await saveConfig({ geminiApiKey: opts.geminiApiKey });