fix: apply config.temperature to LLM client and expose it via opencli config#252
fix: apply config.temperature to LLM client and expose it via opencli config#252zjshen14 wants to merge 4 commits into
Conversation
… config 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 <noreply@anthropic.com>
zjshen14
left a comment
There was a problem hiding this comment.
Review: fix: apply config.temperature to LLM client and expose it via opencli config
What's good: The root cause diagnosis is correct and the fix is minimal. temperature ?? config.temperature in createAgent() gives the right precedence — explicit --temperature flag wins, config file is the fallback — matching how maxTokens, historySize, and autoCompact already work. The opencli config --temperature surface wires cleanly to saveConfig(), and the existing "print current config when nothing was provided" guard was correctly extended to cover the new option.
Only src/cli/index.ts changed (8 additions, 2 deletions). All three CI checks pass. No layering concerns — this stays in the CLI layer as expected.
Not merging: This PR is authored by the same account the review bot runs as, so self-merge is not permitted. This is a clear-cut fix that can be merged directly by the maintainer.
Recommendation: Merge.
Generated by Claude Code
Review: fix: apply config.temperature to LLM client and expose it via opencli configWhat's good: Root cause correctly identified and the fix is precise. Notes1. No test for the The exact bug — 2. GitHub's mergeability check is lazily computed; Recommendation: Merge. Consider adding a test for the Generated by Claude Code |
|
Heads up before merging: dependency on PR #230 (o1 temperature fix) After this PR lands, The current code at ...(this.temperature !== undefined ? { temperature: this.temperature } : {}),Today, After this PR: PR #230 already has the correct fix: a Recommended merge order: #230 first, then this PR. Merging this PR alone will silently break anyone who has Generated by Claude Code |
…given 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 <noreply@anthropic.com>
Status update: fix: apply config.temperature to LLM clientNew commit pushed ( The diff is unchanged from the prior review: a single line in Dependency on #230 still presentThe merge-order constraint noted in the previous comment still applies. Once this PR lands, PR #230 ( Recommended merge order: #230 → this PR (#252). Generated by Claude Code |
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 <noreply@anthropic.com>
Status update: fix: apply config.temperature to LLM clientNew commit pushed ( The diff is unchanged from the prior reviews: a single-file change to Dependency on #230 still unresolvedThe merge-order constraint remains the blocker. Once this PR lands, PR #230 ( Recommended merge order: #230 first, then this PR (#252). Generated by Claude Code |
…given 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 <noreply@anthropic.com>
Summary
createAgent()now usestemperature ?? config.temperatureinstead of only the explicit CLI flag, so the value in~/.opencli/config.jsonis applied to every LLM call when no--temperatureflag is given--temperature <float>toopencli configso users can set the default temperature without manually editing the JSON fileWhy this was broken
Configdeclarestemperature: number(default0.7) andloadConfig()reads it correctly, butcreateAgent()passed the rawtemperatureparameter tocreateClient()— which isundefinedwhen neitherstartChatnorrunSinglereceived an explicit value. The effect:config.temperaturewas dead config that had no effect on any LLM call, whileconfig.maxTokens,config.historySize, andconfig.autoCompactwere all applied correctly.Related:
opencli confighad no--temperatureoption, making the field inaccessible via the CLI.Test plan
npm run typecheck && npm run lint && npm run format:check && npm test— all pass (710 tests)opencli config --temperature 0.2saves the value to~/.opencli/config.jsonopencli config(no args) still prints current configopencli run --temperature 0.5 "…"still takes precedence over config value (??operator)Closes #251
🤖 Generated with Claude Code
Generated by Claude Code