linshenkx/prompt-optimizer · error · EvaluationModelError
${modelKey}
Error message
${modelKey} What it means
EvaluationModelError is thrown by validateModel when modelManager.getModel(modelKey) resolves to a falsy value — i.e. the evaluationModelKey passed on the request does not correspond to any registered/loaded text model. The message is just the model key; the structured context is in error.params.context and the code is MODEL_NOT_FOUND.
Source
Thrown at packages/core/src/services/evaluation/service.ts:559
throw new EvaluationValidationError('Workspace prompt must not be empty.');
}
if (!request.iterateRequirement?.trim()) {
throw new EvaluationValidationError('Iteration requirement must not be empty.');
}
break;
default:
throw new EvaluationValidationError(`Unknown evaluation type: ${(request as any).type}`);
}
}
/**
* 验证评估模型
*/
private async validateModel(modelKey: string): Promise<TextModelConfig> {
const model = await this.modelManager.getModel(modelKey);
if (!model) {
throw new EvaluationModelError(modelKey);
}
return model;
}
/**
* 获取评估模板
*/
private async getEvaluationTemplate(type: EvaluationType, mode: EvaluationModeConfig): Promise<Template> {
const templateId = this.getTemplateId(type, mode);
try {
const template = await this.templateManager.getTemplate(templateId);
if (!template?.content) {
throw new EvaluationTemplateError(templateId);
}
return template;
} catch (error) {
if (error instanceof EvaluationTemplateError) {View on GitHub (pinned to 3e677b1d9f)
Solutions
- Check that evaluationModelKey exactly matches a key registered in ModelManager (list available models first)
- Register/load the intended model configuration before calling evaluate
- Await model-manager initialization at startup if models load async
- Update persisted user preferences that reference deleted model keys
Example fix
// before
await svc.evaluate({ evaluationModelKey: 'gpt4-turbo', ... });
// after
const models = await modelManager.listModels();
const key = models.some(m => m.key === 'gpt-4-turbo') ? 'gpt-4-turbo' : models[0].key;
await svc.evaluate({ evaluationModelKey: key, ... }); Defensive patterns
Strategy: validation
Validate before calling
const model = await modelManager.getModel(key);
if (!model) throw new Error(`Model '${key}' not registered; available: ...`);
await svc.evaluate({ ...req, evaluationModelKey: key }); Try / catch
try { await svc.evaluate(req); } catch (e) { if (e instanceof EvaluationModelError) { await refreshModelList(); retryWithDefaultModel(); } else throw e; } Prevention
- Populate model pickers from modelManager at runtime, not hardcoded lists
- Await model manager initialization before first evaluate
- Clean up stored preferences referencing removed models
When it happens
Trigger: evaluate({evaluationModelKey:'gpt-4x', ...}) where no model with that key is configured in the ModelManager; model removed/renamed after the request was built; model provider not initialized at startup.
Common situations: Model config file missing or key renamed between environments; user-selected model from an outdated dropdown list; model manager loaded asynchronously and evaluate called before models registered; typo in the key.
Related errors
- ${templateId}
- Evaluation model key must not be empty.
- Function mode must not be empty.
- Sub mode must not be empty.
- Result evaluation snapshot testCaseId must match testCase.id
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/9e29ab731d51d54c.
Report an issue: GitHub.