eyaltoledano/claude-task-master · error · Error
Temperature must be between 0 and 1
Error message
Temperature must be between 0 and 1
What it means
validateOptionalParams() rejects a temperature outside the [0, 1] range. The provider layer normalizes temperature to this range regardless of some upstream APIs allowing up to 2, so passing e.g. 1.5 throws before the request is sent.
Solutions
- Set temperature between 0 and 1 (e.g., 0.7)
- Clamp the value: Math.min(1, Math.max(0, temp)) before calling
- Remove the temperature param to use the provider default
Example fix
// before
await provider.generateText({ ..., temperature: 2 });
// after
await provider.generateText({ ..., temperature: 0.7 }); Defensive patterns
Strategy: validation
Validate before calling
if (params.temperature !== undefined && !(params.temperature >= 0 && params.temperature <= 1)) throw new Error('temperature must be between 0 and 1'); Type guard
function isValidTemperature(t) { return t === undefined || (typeof t === 'number' && t >= 0 && t <= 1); } Try / catch
try {
await provider.generateText(params);
} catch (err) {
if (err.message === 'Temperature must be between 0 and 1') {
params.temperature = Math.min(1, Math.max(0, Number(params.temperature)));
} else throw err;
} Prevention
- Clamp temperature to [0,1] when read from config or CLI
- Remember this library's range is 0-1, not the 0-2 some APIs allow
- Sanity-check config values after hand edits
When it happens
Trigger: Passing params.temperature < 0 or > 1 (e.g., temperature: 1.5 or 2) to any generation call; loading a config file with an out-of-range temperature.
Common situations: Copy-pasting temperature: 2 from APIs that support it (OpenAI allows 0-2); computing temperature dynamically and exceeding bounds; config file hand-edited.
Related errors
- Invalid or empty messages array provided
- maxTokens must be a finite number greater than 0
- Object name is required for object generation
- Parameter validation failed
- All subtasks for task
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/7ee239b8ef91a6a0.
Report an issue: GitHub.
Appendix: source
Thrown at src/ai-providers/base-provider.js:222
// Validate required model ID
if (!params.modelId) {
throw new Error(`${this.name} Model ID is required`);
}
// Validate optional parameters
this.validateOptionalParams(params);
}
/**
* Validates optional parameters like temperature and maxTokens
* @param {object} params - Parameters to validate
*/
validateOptionalParams(params) {
if (
params.temperature !== undefined &&
(params.temperature < 0 || params.temperature > 1)
) {
throw new Error('Temperature must be between 0 and 1');
}
if (params.maxTokens !== undefined) {
const maxTokens = Number(params.maxTokens);
if (!Number.isFinite(maxTokens) || maxTokens <= 0) {
throw new Error('maxTokens must be a finite number greater than 0');
}
}
}
/**
* Validates message array structure
*/
validateMessages(messages) {
if (!messages || !Array.isArray(messages) || messages.length === 0) {
throw new Error('Invalid or empty messages array provided');
}
for (const msg of messages) {View on GitHub (pinned to c0c98d367c)