linshenkx/prompt-optimizer · warning · RequestConfigError
Model is not enabled
Error message
Model is not enabled
What it means
Thrown by validateModelConfig when the model config is not enabled, unless the caller passes { allowDisabled: true }. Disabled models are deliberately blocked from normal requests so users don't accidentally hit deactivated providers; only connection testing bypasses the check.
Source
Thrown at packages/core/src/services/llm/service.ts:75
* 验证模型配置
*/
private validateModelConfig(
modelConfig: TextModelConfig,
options: { allowDisabled?: boolean } = {}
): void {
if (!modelConfig) {
throw new RequestConfigError('Model config cannot be empty');
}
if (!modelConfig.providerMeta || !modelConfig.providerMeta.id) {
throw new RequestConfigError('Model provider metadata cannot be empty');
}
if (!modelConfig.modelMeta || !modelConfig.modelMeta.id) {
throw new RequestConfigError('Model metadata cannot be empty');
}
// Default behavior: disabled models cannot be used for normal requests.
// Connection testing is allowed to bypass this check (align with image model test behavior).
if (!options.allowDisabled && !modelConfig.enabled) {
throw new RequestConfigError('Model is not enabled');
}
}
/**
* 发送消息(结构化格式)
*/
async sendMessageStructured(messages: Message[], provider: string): Promise<LLMResponse> {
try {
if (!provider) {
throw new RequestConfigError('Model provider cannot be empty');
}
const modelConfig = await this.modelManager.getModel(provider);
if (!modelConfig) {
throw new RequestConfigError(`Model ${provider} not found`);
}
this.validateModelConfig(modelConfig);View on GitHub (pinned to 3e677b1d9f)
Solutions
- Enable the model in your model manager / settings before sending messages (config.enabled = true)
- If the disabled state is unexpected, inspect the stored config to see why enabled is false or missing
- Ensure new model configs are created with enabled explicitly set to true when they should be usable
Example fix
// before
await modelManager.updateModel('openai', { enabled: false });
await llmService.sendMessageStream(msgs, 'openai', onChunk); // throws
// after
await modelManager.updateModel('openai', { enabled: true });
await llmService.sendMessageStream(msgs, 'openai', onChunk); Defensive patterns
Strategy: validation
Validate before calling
const cfg = await modelManager.getModel(provider);
if (!cfg?.enabled) {
await modelManager.updateModel(provider, { enabled: true }); // or block the send
} Type guard
const isEnabledModel = (c?: ModelConfig | null): c is ModelConfig => !!c && c.enabled === true;
Try / catch
catch (e) { if (e instanceof RequestConfigError && e.message === 'Model is not enabled') { promptUserToEnable(provider); } } Prevention
- Check config.enabled before sending; surface disabled state in the UI
- Persist sessions with a fallback model in case the primary is disabled
- Use testConnection(provider) for health checks — it tolerates disabled models
When it happens
Trigger: Calling sendMessageStructured, sendMessageStream, or sendMessageStreamWithTools on a model whose config.enabled is false (or undefined, which is falsy). testConnection does not throw this because it calls validateModelConfig with allowDisabled: true.
Common situations: User disabled a provider in the settings UI but a chat session still references it; a persisted config where the enabled flag defaults to false; toggling a model off while background jobs still use its id.
Related errors
- Model provider metadata cannot be empty
- Model metadata cannot be empty
- Evaluation mode configuration must not be empty.
- Workspace prompt must not be empty.
- Image understanding service is not available for multimodal
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/9956f34db8141946.
Report an issue: GitHub.