Skip to content

Commit 0a4cb0d

Browse files
authored
Merge pull request #604 from clawdbot/fix/model-fallback-error-message
Fix model fallback error message handling
2 parents 60bd21d + 9ecef09 commit 0a4cb0d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Commands: add `/usage` as an alias for `/status`. (#492) — thanks @lc0rp
1717
- Models/Auth: add MiniMax Anthropic-compatible API onboarding (minimax-api). (#590) — thanks @mneves75
1818
- Models: centralize model override validation + hooks Gmail warnings in doctor. (#602) — thanks @steipete
19+
- Agents: avoid base-to-string error stringification in model fallback. (#604) — thanks @steipete
1920
- Commands: harden slash command registry and list text-only commands in `/commands`.
2021
- Models/Auth: show per-agent auth candidates in `/model status`, and add `clawdbot models auth order {get,set,clear}` (per-agent auth rotation overrides). — thanks @steipete
2122
- Debugging: add raw model stream logging flags and document gateway watch mode.

src/agents/model-fallback.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ function getErrorCode(err: unknown): string {
5454

5555
function getErrorMessage(err: unknown): string {
5656
if (err instanceof Error) return err.message;
57-
return String(err ?? "");
57+
if (typeof err === "string") return err;
58+
if (
59+
typeof err === "number" ||
60+
typeof err === "boolean" ||
61+
typeof err === "bigint"
62+
) {
63+
return String(err);
64+
}
65+
if (typeof err === "symbol") return err.description ?? "";
66+
if (err && typeof err === "object") {
67+
const message = (err as { message?: unknown }).message;
68+
if (typeof message === "string") return message;
69+
}
70+
return "";
5871
}
5972

6073
function isTimeoutErrorMessage(raw: string): boolean {

0 commit comments

Comments
 (0)