linshenkx/prompt-optimizer · error · TestError
Custom conversation test failed: ${errorMessage}
Error message
Custom conversation test failed: ${errorMessage} What it means
Wrapper error reported when the underlying LLM streaming call (sendMessageStreamWithTools or the plain stream) throws during a custom conversation test. The original error message is embedded in the message; if no onError callback is registered it is rethrown as a TestError, otherwise it is delivered to callbacks.onError.
Source
Thrown at packages/core/src/services/prompt/service.ts:1200
},
},
);
}
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : String(error);
console.error(
"[PromptService] Custom conversation test error:",
errorMessage,
);
// 通过回调传递错误
if (callbacks.onError) {
callbacks.onError(
new Error(`Custom conversation test failed: ${errorMessage}`),
);
} else {
throw new TestError(
"",
"",
`Custom conversation test failed: ${errorMessage}`,
);
}
}
}
}
View on GitHub (pinned to 3e677b1d9f)
Solutions
- Read the embedded original message — it identifies the real cause (auth, network, schema)
- Check provider credentials and connectivity (key valid, base URL reachable)
- Validate tool definitions against the provider's schema before testing
- Register callbacks.onError so the failure surfaces in your UI instead of an unhandled throw
Example fix
// before
await svc.testCustomConversationStream(req); // throws TestError
// after
await svc.testCustomConversationStream(req, {
onError: (e) => logger.error('test failed', e.message),
}); Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
await svc.testCustomConversationStream(req, { onError: (err) => ui.showToast(err.message) });
} catch (e) {
if (e instanceof TestError && e.message.startsWith('Custom conversation test failed:')) {
const cause = e.message.split(':').slice(1).join(':').trim(); // real LLM error
handleLlmFailure(cause);
} else throw e;
} Prevention
- Always pass callbacks.onError so failures route to your UI instead of throwing
- Validate tool schemas and credentials before initiating a test
- Parse the embedded original message rather than guessing at the wrapper text
When it happens
Trigger: Any failure inside the streaming LLM call: invalid API key, network failure, provider 4xx/5xx, malformed tool definitions, or the model rejecting the message array. The catch block wraps it as 'Custom conversation test failed: <original message>'.
Common situations: Expired/missing API key; rate limits; wrong base URL for a self-hosted provider; tool schema the model rejects; network offline in an Electron/webview environment.
Related errors
- Evaluation mode configuration must not be empty.
- Workspace prompt must not be empty.
- Messages array cannot be empty
- Each message must have role and content
- Invalid message role: ${msg.role}
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/409f514d82daa073.
Report an issue: GitHub.