createAI: binding errors flagged retryable: true are not retried · Issue #2628 · cloudflare/agents · GitHub
Skip to content

createAI: binding errors flagged retryable: true are not retried #2628

Open

Description

@mattzcarey

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions