withRetry
Call Signature
Section titled “Call Signature”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.
Type Parameters
Section titled “Type Parameters”In
The input the wrapped stage receives, before retry feedback is added.
Parameters
Section titled “Parameters”Stage<Retryable<In>, PlannerCandidate>
options
Section titled “options”Returns
Section titled “Returns”Stage<In, PlannerCandidate>
Throws
Section titled “Throws”If options.max is not a non-negative integer.
Example
Section titled “Example”// `modelPlanner` is any `Planner`, for example one that calls a model.const planner = withRetry(modelPlanner, { max: 1 });Call Signature
Section titled “Call Signature”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.
Type Parameters
Section titled “Type Parameters”In
The input the wrapped stage receives, before retry feedback is added.
Parameters
Section titled “Parameters”Stage<Retryable<In, ReplylessCandidate>, ReplylessCandidate>
options
Section titled “options”Returns
Section titled “Returns”Stage<In, ReplylessCandidate>
Throws
Section titled “Throws”If options.max is not a non-negative integer.
Call Signature
Section titled “Call Signature”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. The Engine validates it, partial changes included, and decides whether the request allows it.
Type Parameters
Section titled “Type Parameters”In
The input the wrapped stage receives, before retry feedback is added.
Parameters
Section titled “Parameters”Stage<Retryable<In, ReplylessCandidate>, PlannerOutput>
options
Section titled “options”Returns
Section titled “Returns”Stage<In, PlannerOutput>
Throws
Section titled “Throws”If options.max is not a non-negative integer.