fix: include provider and model name in billing error message (#20510)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 40dbdf62e8
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
青雲
2026-02-19 10:56:00 +08:00
committed by GitHub
parent 2bb8ead187
commit 3d4ef56044
9 changed files with 141 additions and 15 deletions

View File

@@ -92,13 +92,19 @@ describe("formatAssistantErrorText", () => {
const result = formatAssistantErrorText(msg);
expect(result).toBe(BILLING_ERROR_USER_MESSAGE);
});
it("includes provider name in billing message when provider is given", () => {
it("includes provider and assistant model in billing message when provider is given", () => {
const msg = makeAssistantError("insufficient credits");
const result = formatAssistantErrorText(msg, { provider: "Anthropic" });
expect(result).toBe(formatBillingErrorMessage("Anthropic"));
expect(result).toBe(formatBillingErrorMessage("Anthropic", "test-model"));
expect(result).toContain("Anthropic");
expect(result).not.toContain("API provider");
});
it("uses the active assistant model for billing message context", () => {
const msg = makeAssistantError("insufficient credits");
msg.model = "claude-3-5-sonnet";
const result = formatAssistantErrorText(msg, { provider: "Anthropic" });
expect(result).toBe(formatBillingErrorMessage("Anthropic", "claude-3-5-sonnet"));
});
it("returns generic billing message when provider is not given", () => {
const msg = makeAssistantError("insufficient credits");
const result = formatAssistantErrorText(msg);