Skip to content

withRetry

withRetry<In>(stage, options): Stage<In, PlannerCandidate>

Defined in: packages/engine/src/lib/planner/with-retry.ts:49

Re-runs stage while the Engine’s validation recommends a retry, up to options.max retries (max + 1 attempts in total).

Each candidate is checked with ctx.validate. A retry happens only when the validation report sets retryHint.recommend; the retry receives the original input plus RetryFeedback about the attempt just rejected (never earlier ones). Every Err, from the stage or from validation, is returned at once without using the budget. When the budget runs out, the last candidate returns to the Engine: healing keeps it renderable, but unresolved application requirements still prevent delivery.

The signal is not checked between attempts; each attempt is responsible for observing it.

Logs Retrying after recommended retry, Retry succeeded and Retries exhausted (the last only when max > 0), at a level derived from the retry severity.

In

The input the wrapped stage receives, before retry feedback is added.

Stage<Retryable<In>, PlannerCandidate>

WithRetryOptions

Stage<In, PlannerCandidate>

If options.max is not a non-negative integer.

// `modelPlanner` is any `Planner`, for example one that calls a model.
const planner = withRetry(modelPlanner, { max: 1 });

withRetry<In>(stage, options): Stage<In, ReplylessCandidate>

Defined in: packages/engine/src/lib/planner/with-retry.ts:61

withRetry for a stage that may omit userMessage: the retry feedback carries the ReplylessCandidate the previous attempt produced, and the wrapper returns replyless candidates too.

In

The input the wrapped stage receives, before retry feedback is added.

Stage<Retryable<In, ReplylessCandidate>, ReplylessCandidate>

WithRetryOptions

Stage<In, ReplylessCandidate>

If options.max is not a non-negative integer.

withRetry<In>(stage, options): Stage<In, PlannerOutput>

Defined in: packages/engine/src/lib/planner/with-retry.ts:78

withRetry for a stage that may return any PlannerOutput, including a needs-clarification result: the retry feedback carries the ReplylessCandidate the previous attempt produced, and the wrapper returns any PlannerOutput too.

A needs-clarification result is returned unchanged on the attempt that produced it, without validation or retry: it has no layout to heal, and the Engine decides whether the request allows it.

In

The input the wrapped stage receives, before retry feedback is added.

Stage<Retryable<In, ReplylessCandidate>, PlannerOutput>

WithRetryOptions

Stage<In, PlannerOutput>

If options.max is not a non-negative integer.