When IOSM Should Retry—and When It Must Stop
A retry is useful only when another attempt can change the outcome. Otherwise it is automated denial.
I keep seeing agent workflows treat every failure as temporary: run the same tool again, ask the model to “fix it,” consume another context window, then call persistence a recovery strategy. IOSM CLI already contains a better foundation. Its Swarm runtime classifies failures into bounded retry buckets, while the IOSM cycle model distinguishes incomplete work, failed gates, guardrail violations, and insufficient evidence. The practical task is to connect those mechanisms into one operator decision.
This is not a new retry algorithm. It is a way to decide whether the next action should be retry, repair, rollback, replan, or stop.
Start with the failed condition
At the inspected IOSM CLI revision, Swarm retry logic recognizes five buckets:
| Failure bucket | Default retry limit | What may change on another attempt |
|---|---|---|
permission |
1 | approval or tool authority may be corrected |
dependency_import |
2 | a missing package, path, or import may be repaired |
test |
2 | the implementation may be revised against concrete failures |
timeout |
2 | transient load or a bounded execution window may differ |
unknown |
1 | one diagnostic attempt may reveal a real class |
The limits are small on purpose. A retry budget is not a confidence score. It is a cap on how much repeated uncertainty the runtime may spend before the failure changes state.
The important question is not “How many attempts remain?” It is:
What evidence says the next attempt will be materially different?
If the answer is “none,” the correct retry count is zero even when the policy permits two.
Five actions, not one loop
I use this decision matrix:
| Action | Use it when | Required change before execution |
|---|---|---|
| Retry | the same operation may succeed under changed transient conditions | new attempt identity; stable intended effect identity |
| Repair | the failure names a local defect | patch, dependency, input, or test expectation changes |
| Rollback | the candidate state crossed a declared boundary | restore a named checkpoint, then rerun baseline checks |
| Replan | the goal or scope is wrong, ambiguous, or too large | revised cycle scope, hypothesis, or dependency plan |
| Stop | a hard gate, guardrail, authority boundary, or evidence requirement cannot be satisfied | explicit terminal result and blocker record |
These actions preserve different truths. Retry says the intended operation is still valid. Repair says the operation is valid but its implementation is not. Rollback says the current workspace is no longer an acceptable base. Replan says the execution model is wrong. Stop says continuing would manufacture activity rather than evidence.
A practical retry envelope
Before letting an agent repeat work, I want a small record:
retry:
failure_bucket: test
failed_condition: "contract test rejects nullable account_id"
attempt: 2
max_attempts: 2
changed_input:
- "serializer now rejects null before persistence"
stable_effect: "change-set auth-normalization-17"
verify:
- "npm test -- auth-contract"
- "git diff --check"
on_failure: rollback
This is an operating convention, not a current IOSM CLI schema. Its job is to prevent a silent same-input retry.
Two identities matter here. Each attempt must be new so the trace remains honest. The intended external effect must remain stable so a timeout cannot multiply a deployment, message, payment, or database mutation. For filesystem-only work, the stable object may be a named change set. For external effects, it should be an idempotency key or another system-enforced effect identity.
Map failure classes to IOSM cycle states
A Swarm worker failure and an IOSM cycle decision are not the same layer.
The Swarm retry module answers a narrow runtime question: may this worker attempt again? The cycle report answers a broader engineering question: does the accumulated result justify CONTINUE, STOP, or FAIL?
IOSM cycle logic returns FAIL when the cycle itself is failed, a non-waived gate fails, or guardrails are violated. It returns CONTINUE when evidence is incomplete, confidence is too low, metric floors are not met, active waivers remain, or the stabilization window is insufficient. STOP is reserved for a completed, sufficiently evidenced stable state across the configured consecutive cycles.
That gives me a clean hierarchy:
worker error
-> classify failure
-> decide retry / repair / rollback / replan
-> rerun deterministic checks
-> update phase and cycle artifacts
-> derive CONTINUE / STOP / FAIL
A worker retry must never overwrite the cycle decision. Two successful retries do not convert weak evidence into stabilization. Likewise, CONTINUE does not mean “repeat the same prompt.” It means the engineering proof is not complete.
Example: a failing contract test
Suppose a parallel IOSM task changes an authentication serializer and the contract suite fails.
Attempt 1 fails because account_id became nullable. The test failure is specific. Repair is justified: restore the invariant in the serializer, then rerun only the focused contract suite.
Attempt 2 fails with the same assertion and the diff shows the same semantic shape. Another retry adds no new information. The task should stop retrying and return a blocker to the orchestrator.
The orchestrator then chooses among three paths:
- rollback to the checkpoint before the serializer change;
- replan the change because the public contract and internal model conflict;
- request explicit approval for a contract change.
It must not relax the test, mark the gate waived, or broaden the scope merely to obtain green output.
This is where IOSM CLI checkpoints become useful: rollback restores the session and filesystem boundary, but acceptance still comes from rerunning the declared baseline. The cycle remains auditable because the failed attempt, restored state, and next decision are separate events.
Permission failures need authority, not persuasion
A permission error deserves at most one diagnostic retry. If a tool is forbidden, the model should not search for alternative wording or a neighboring command with the same effect.
The next attempt is valid only when authority changes explicitly:
- the operator approves the exact action;
- the tool policy is corrected;
- the task is narrowed to a permitted read-only path;
- the action is delegated to an authorized system.
Without one of those changes, retrying is an authorization bypass attempt disguised as resilience.
Timeouts need duplicate-safe recovery
Timeouts are deceptive because the operation may have completed after the caller stopped waiting. Before retrying, inspect the effect boundary:
Did the tool fail before execution?
Did execution start but return no result?
Can the target system answer whether the effect already exists?
Is the operation protected by an idempotency key?
If completion is unknown and the effect is not duplicate-safe, the state is blocked, not retryable. The operator needs reconciliation or compensation. A second blind call is not recovery.
For a broader treatment of run identity and effect identity, see Retry Identity Test: 100 Duplicate Effects, Then Zero. The difference here is operational: this article turns that invariant into a retry decision inside an IOSM workflow.
Configure budgets by failure cost
The default bucket limits are a reasonable guardrail, not a universal optimum. I would tighten them when:
- the action has external side effects;
- each attempt is expensive;
- the failure is deterministic;
- the workspace has concurrent writers;
- the evidence boundary is already broken.
I would allow the configured budget only when the operation is isolated, the failure class is understood, and each attempt produces a changed input or new diagnostic evidence.
The cycle-level max_iterations_per_phase is also not permission to repeat a failed action that many times. A phase iteration should represent a new engineering move: a revised hypothesis, implementation, measurement, or boundary—not another request for the model to try harder.
The operator rule
My rule is simple:
Never spend a retry without naming what changed.
A resilient IOSM workflow does not hide failure behind repeated execution. It converts failure into a typed transition: retry with changed conditions, repair a local defect, rollback an invalid state, replan an invalid approach, or stop at a hard boundary.
That is the difference between an agent loop and an engineering cycle. The loop wants another answer. The cycle wants a justified next state.