ruvnet/ruflo · error
Temperature must be between 0 and 2
Error message
Temperature must be between 0 and 2
What it means
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.
Source
Thrown at v3/@claude-flow/providers/src/base-provider.ts:203
* Provider-specific initialization (override in subclass)
*/
protected abstract doInitialize(): Promise<void>;
/**
* Validate provider configuration
*/
protected validateConfig(): void {
if (!this.config.model) {
throw new Error(`Model is required for ${this.name} provider`);
}
if (!this.validateModel(this.config.model)) {
this.logger.warn(`Model ${this.config.model} may not be supported by ${this.name}`);
}
if (this.config.temperature !== undefined) {
if (this.config.temperature < 0 || this.config.temperature > 2) {
throw new Error('Temperature must be between 0 and 2');
}
}
}
/**
* Complete a request
*/
async complete(request: LLMRequest): Promise<LLMResponse> {
const startTime = Date.now();
try {
const response = await this.circuitBreaker.execute(async () => {
return await this.doComplete(request);
});
const latency = Date.now() - startTime;
this.trackRequest(request, response, latency);
View on GitHub (pinned to fa13ee4ad6)
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
Example fix
// before
config: { apiKey, model: 'gpt-4o', temperature: 7 } // copied from a 0-10 scale
// after
config: { apiKey, model: 'gpt-4o', temperature: Math.min(2, Math.max(0, 0.7)) } Defensive patterns
Strategy: validation
Validate before calling
function clampTemperature(t: number | undefined): number | undefined {
if (t === undefined) return undefined;
if (!Number.isFinite(t)) throw new Error('temperature must be a finite number');
return Math.min(2, Math.max(0, t));
}
// usage: config: { ...cfg, temperature: clampTemperature(cfg.temperature) } Type guard
function isValidTemperature(t: unknown): t is number {
return typeof t === 'number' && Number.isFinite(t) && t >= 0 && t <= 2;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- localCompute: no adapter for graphId=${input.graphId}
- RuvllmConfig.modelsDir is required
- Key exceeds maximum nesting depth of ${MAX_NESTING_DEPTH}
- Dangerous key segment rejected: ${part}
- task step ${step.stepId} requires config.agentId or workflow
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/613845063a6ad81f.
Report an issue: GitHub.