validate --max-turns and --temperature flags to prevent silent NaN#130
validate --max-turns and --temperature flags to prevent silent NaN#130zjshen14 wants to merge 1 commit into
Conversation
…o agent/provider Bare parseInt/parseFloat coercers silently produce NaN for non-numeric inputs. NaN breaks the turns > maxTurns safety guard (always false) and is passed raw to the LLM provider for temperature. Added parseTurns and parseTemperature validators that throw commander's InvalidArgumentError with a clear message, matching the existing --sandbox / --provider validation pattern. Closes #116 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Good fix — Two things to check before landing: Coverage gap: Stray comma in }),with a trailing comma instead of a semicolon. TypeScript parses this as a comma expression (the return value of Recommendation: confirm Generated by Claude Code |
Summary
parseInt/parseFloatcoercers on--max-turnsand--temperaturewith validator functions that throwInvalidArgumentErroron bad input--max-turns abcor--max-turns 0now exits 1 with"--max-turns must be a positive integer"instead of silently passingNaN(which disabled the safety guard inagent.ts)--temperature notanumberor out-of-range values now exits 1 with"--temperature must be between 0 and 2"instead of forwardingNaNto the provider--sandbox/--providervalidation already in the codebaseCloses #116
Test plan
npm run typecheck && npm run lint && npm run format:check && npm test— all pass--max-turns, zero--max-turns, non-numeric--temperature, out-of-range--temperature(all run against the built dist vianpm run build)--max-turns 5,--temperature 0.7) still pass through unchangedGenerated by Claude Code