fix: address cubic review — broaden error detection, add test coverage
1. isAgentNotFoundError now handles: - Plain objects with .message field (not just Error instances) - "agent.name"/"undefined" error variants from SDK validation - The original "Agent not found" format 2. New tests: - agent.name/undefined error variant triggers fallback - Plain object errors with .message field trigger fallback - "fallback also fails" test now verifies retry was attempted (callCount=2) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,19 @@ import type { ConcurrencyManager } from "./concurrency"
|
||||
export const FALLBACK_AGENT = "general"
|
||||
|
||||
export function isAgentNotFoundError(error: unknown): boolean {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return message.includes("Agent not found")
|
||||
const message =
|
||||
typeof error === "string"
|
||||
? error
|
||||
: error instanceof Error
|
||||
? error.message
|
||||
: typeof error === "object" && error !== null && typeof (error as { message?: unknown }).message === "string"
|
||||
? (error as { message: string }).message
|
||||
: String(error)
|
||||
return (
|
||||
message.includes("Agent not found") ||
|
||||
message.includes("agent.name") ||
|
||||
(message.includes("agent") && message.includes("undefined"))
|
||||
)
|
||||
}
|
||||
|
||||
export function buildFallbackBody(
|
||||
|
||||
Reference in New Issue
Block a user