Check work and retry
Use test output or a review to accept an agent’s work or request another attempt.
Use a loop when your code can decide whether a result is acceptable. For the agent-and-tests example, prepare the configuration and dependencies first. A retry after an execution error and another attempt after a failed check are different decisions.
Download all files. Extract into a dedicated directory, run npm install, then adapt outpost.config.ts using Installation. The commands below identify the scripts to run.
Repeat until a check accepts
Section titled “Repeat until a check accepts”Define an attempt and a check with defineLoopTask(). The check accepts the result or returns feedback for the next attempt. Set maxRounds so a result that never passes ends with a bounded failure.
Round 1 is rejected; round 2 receives the feedback and is accepted. after, condition and cache work as on other tasks.
Code, then run a command
Section titled “Code, then run a command”The agent works in attempt, the tests run in check, both in one warm sandbox.
Keep the sandbox, attempt and check separate so each step is easy to follow.
Run run-loop.ts; it keeps the sandbox open until the workflow finishes.
coding.perform(context) ties the agent’s tokens and cancellation to the loop and its budget. coder is a helper: only fix goes in the workflow. attempt returns JSON because a checkpoint saves every candidate, even rejected ones.
A failing npm test returns a nonzero status, and its output becomes the feedback. You decide where it goes: the next brief, as here, or a continued conversation. attempt receives the rejected round’s result as its third argument, for example to continue its conversation.
Ask a second agent to review
Section titled “Ask a second agent to review”check can dispatch a reviewer and turn its typed response into a verdict. Both agents count against the same budget.
Pass it as check: reviewChanges. The request’s agent replaces the sandbox’s agent for this dispatch only.
Checkpoint and resume
Section titled “Checkpoint and resume”With a checkpoint, each candidate is saved before check. On resume, a saved candidate goes straight to check, and rejected rounds are not rerun.
An interrupted round replays only with resume: "retry-incomplete", since it may already have changed files. Changing maxRounds makes the checkpoint incompatible.
Each task record lists its rounds, and each phase emits a loop workflow event. The complete event of a rejected round carries its feedback, masked by the workflow’s redact patterns, then limited to its first and last 1,000 characters. context.idempotencyKey differs per round and phase, to deduplicate effects as in Job queues and workers.
API: defineLoopTask · LoopTaskOptions · LoopTaskContext · LoopCheckResult · LoopTaskExhausted · defineAgentTask.
A task copied with { ...task }, including one decorated with defineTask({ ...task, condition }), retains its loop definition and round limit. Pass that resulting task to the workflow and use the same object with result.value(task) and dependency references.
Repeat the brief until the agent declares it done
Section titled “Repeat the brief until the agent declares it done”passes sends the brief again when a pass ends without a completion marker. Ask for the marker in the brief: Outpost does not add it.
Each pass starts a new conversation and sees the commits retained or integrated by the preceding pass. Outpost stops at the first pass whose answer contains a marker. until also accepts a list; until: [] disables matching and runs every pass.
API reference: DispatchResult.
If the agent writes its marker but keeps running, Outpost stops it settleMs after its last output. The result is kept and warn receives a message.
With top-level dispatch(), each pass allocates a fresh sandbox and runs its preparation hooks. A named branch keeps its commits across passes; integrate creates and integrates a separate branch for each pass. With sandbox.dispatch(), passes reuse the open sandbox and workspace. Choose that form when preparation must run only once.
Limits
Section titled “Limits”| Limit or event | What happens |
|---|---|
maxRounds | Caps the rounds, resumes included. |
| Workflow attempts | Each round, and each replay of an interrupted round, counts against budget.attempts. |
timeoutMs | Bounds each round. It stops callbacks that honor context.signal. |
| An exception | Fails the task at once. A loop task has no retry option. |
| The last check rejects | The task fails with LoopTaskExhausted. Its message ends with the first and last 1,000 characters of the last feedback, masked by redact; its feedback property keeps the full text. Dependents do not run. |
Fix a failing CI build handles each outcome in a complete script. YAML recipes declare the same loops with agent and command steps; see the correspondence with TypeScript.

