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

  1. Read the embedded original message — it identifies the real cause (auth, network, schema)
  2. Check provider credentials and connectivity (key valid, base URL reachable)
  3. Validate tool definitions against the provider's schema before testing
  4. 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

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


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/409f514d82daa073. Report an issue: GitHub.