{"record":{"id":"9e29ab731d51d54c","repo":"linshenkx/prompt-optimizer","slug":"modelkey","errorCode":null,"errorMessage":"${modelKey}","messagePattern":"\\$\\{modelKey\\}","errorType":"exception","errorClass":"EvaluationModelError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/evaluation/service.ts","lineNumber":559,"sourceCode":"          throw new EvaluationValidationError('Workspace prompt must not be empty.');\n        }\n        if (!request.iterateRequirement?.trim()) {\n          throw new EvaluationValidationError('Iteration requirement must not be empty.');\n        }\n        break;\n\n      default:\n        throw new EvaluationValidationError(`Unknown evaluation type: ${(request as any).type}`);\n    }\n  }\n\n  /**\n   * 验证评估模型\n   */\n  private async validateModel(modelKey: string): Promise<TextModelConfig> {\n    const model = await this.modelManager.getModel(modelKey);\n    if (!model) {\n      throw new EvaluationModelError(modelKey);\n    }\n    return model;\n  }\n\n  /**\n   * 获取评估模板\n   */\n  private async getEvaluationTemplate(type: EvaluationType, mode: EvaluationModeConfig): Promise<Template> {\n    const templateId = this.getTemplateId(type, mode);\n\n    try {\n      const template = await this.templateManager.getTemplate(templateId);\n      if (!template?.content) {\n        throw new EvaluationTemplateError(templateId);\n      }\n      return template;\n    } catch (error) {\n      if (error instanceof EvaluationTemplateError) {","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/evaluation/service.ts#L541-L577","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait svc.evaluate({ evaluationModelKey: 'gpt4-turbo', ... });\n\n// after\nconst models = await modelManager.listModels();\nconst key = models.some(m => m.key === 'gpt-4-turbo') ? 'gpt-4-turbo' : models[0].key;\nawait svc.evaluate({ evaluationModelKey: key, ... });","handlingStrategy":"validation","validationCode":"const model = await modelManager.getModel(key);\nif (!model) throw new Error(`Model '${key}' not registered; available: ...`);\nawait svc.evaluate({ ...req, evaluationModelKey: key });","typeGuard":null,"tryCatchPattern":"try { await svc.evaluate(req); } catch (e) { if (e instanceof EvaluationModelError) { await refreshModelList(); retryWithDefaultModel(); } else throw e; }","preventionTips":["Populate model pickers from modelManager at runtime, not hardcoded lists","Await model manager initialization before first evaluate","Clean up stored preferences referencing removed models"],"tags":["evaluation","model","config","not-found"],"backgroundTag":"model-config-not-found","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}