{"record":{"id":"613845063a6ad81f","repo":"ruvnet/ruflo","slug":"temperature-must-be-between-0-and-2-613845","errorCode":null,"errorMessage":"Temperature must be between 0 and 2","messagePattern":"Temperature must be between 0 and 2","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/providers/src/base-provider.ts","lineNumber":203,"sourceCode":"   * Provider-specific initialization (override in subclass)\n   */\n  protected abstract doInitialize(): Promise<void>;\n\n  /**\n   * Validate provider configuration\n   */\n  protected validateConfig(): void {\n    if (!this.config.model) {\n      throw new Error(`Model is required for ${this.name} provider`);\n    }\n\n    if (!this.validateModel(this.config.model)) {\n      this.logger.warn(`Model ${this.config.model} may not be supported by ${this.name}`);\n    }\n\n    if (this.config.temperature !== undefined) {\n      if (this.config.temperature < 0 || this.config.temperature > 2) {\n        throw new Error('Temperature must be between 0 and 2');\n      }\n    }\n  }\n\n  /**\n   * Complete a request\n   */\n  async complete(request: LLMRequest): Promise<LLMResponse> {\n    const startTime = Date.now();\n\n    try {\n      const response = await this.circuitBreaker.execute(async () => {\n        return await this.doComplete(request);\n      });\n\n      const latency = Date.now() - startTime;\n      this.trackRequest(request, response, latency);\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/providers/src/base-provider.ts#L185-L221","documentation":"validateConfig() enforces the documented sampling-temperature range: when config.temperature is provided it must be a number in [0, 2] inclusive; anything outside throws during provider initialization, before any API request is made.","triggerScenarios":"Initializing a provider with temperature: -0.5 or temperature: 3, or a value scaled from another tool's 0-10 range, or a temperature computed from a string env var that ends up out of bounds.","commonSituations":"Hyperparameters copy-pasted from a library using a 0-1 or 0-10 scale; a UI slider permitting values above 2; env var parsed with parseFloat producing an unexpected value.","solutions":["Set temperature within 0-2 (0.7 is a common default)","Clamp external input before passing it: Math.min(2, Math.max(0, t))","Omit temperature entirely to use the provider default"],"exampleFix":"// before\nconfig: { apiKey, model: 'gpt-4o', temperature: 7 } // copied from a 0-10 scale\n\n// after\nconfig: { apiKey, model: 'gpt-4o', temperature: Math.min(2, Math.max(0, 0.7)) }","handlingStrategy":"validation","validationCode":"function clampTemperature(t: number | undefined): number | undefined {\n  if (t === undefined) return undefined;\n  if (!Number.isFinite(t)) throw new Error('temperature must be a finite number');\n  return Math.min(2, Math.max(0, t));\n}\n// usage: config: { ...cfg, temperature: clampTemperature(cfg.temperature) }","typeGuard":"function isValidTemperature(t: unknown): t is number {\n  return typeof t === 'number' && Number.isFinite(t) && t >= 0 && t <= 2;\n}","tryCatchPattern":null,"preventionTips":["Clamp user- or env-provided temperature before it reaches the provider config","Standardize on the 0-2 scale in your own config schema and document it","Validate numeric env vars with Number.parseFloat and a range check at load time"],"tags":["config","validation","range","sampling"],"backgroundTag":"parameter-out-of-range","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}