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 1 commit 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 |
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