createAI: binding errors flagged retryable: true are not retried
When env.AI.run throws an error that the runtime marks retryable: true (e.g. Network connection lost.), createAI wraps it as non-retryable, so the AI SDK's maxRetries never kicks in and fallback legs treat it as terminal.
const ai = createAI({ binding: env.AI });
await generateText({ model: ai("@cf/meta/llama-3.3-70b-instruct-fp8-fast"), prompt, maxRetries: 2 });
// binding throws Object.assign(new Error("Network connection lost."), { retryable: true })
// -> one call, no retry
normalizeThrownError in packages/agents/src/models/core/errors.ts only looks for a known Workers AI code in the message; with no code it sets isRetryable: false and ignores the error's own retryable flag. It should honour retryable: true (and false) when present, before falling back to the code table.
Confirmed with a fake-binding test on main.
From cloudflare/ai#656.
Proposed fix on kanchingyg:fix/createai-retryable-flag (API PR creation is blocked by collaborators_only).
Compare: https://github.com/cloudflare/agents/compare/main...kanchingyg:fix/createai-retryable-flag?expand=1
Honours the binding's boolean retryable flag in normalizeThrownError.