Repository navigation
fix(chat): treat null or blank temperature as unset instead of 0 - #250
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Code Review Roast 🔥Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. 📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are. The fix correctly handles the Files Reviewed (2 files)
Reviewed by free · Input: 76K · Output: 4.3K · Cached: 219.2K |
resolveChatTemperatureran every non-number throughNumber(), andNumber(null),Number(''),Number(' ')andNumber(false)are all0. So a request with"temperature": null, which is how many clients say "unset", went to the provider as temperature 0 (deterministic sampling) instead of the 0.7 default.resolveChatMaxTokensdoesn't have this problem because its< 1guard rejects the coerced 0.Now only numbers and non-blank strings count as an explicit temperature. An explicit
0/'0'is still kept, and the existing test for that still passes.Tests: a new case in
api/__tests__/chat-temperature.test.mjsfails on main and passes with the fix.vitest run: 84 pass.Note
Low Risk
Narrow parsing change in chat request config with tests; no auth or data-handling impact.
Overview
Fixes
resolveChatTemperatureso clients sending"temperature": null, empty strings, or other non-numeric values get the default (0.7) instead of 0 (which used to happen becauseNumber(null)and similar coerce to 0).Only numbers and non-blank strings are parsed; explicit
0/'0'and clamping in 0–2 are unchanged. Trimmed numeric strings (e.g.' 1.5 ') still work. Coverage added inchat-temperature.test.mjsfor null, blanks,false, arrays, and custom fallbacks.Reviewed by Cursor Bugbot for commit bff96ba. Bugbot is set up for automated code reviews on this repo. Configure here.