Skip to content

feat(retry): pass failed runs to retry_on - #181

Merged
joshrotenberg merged 1 commit into
mainfrom
feat/152-retry-failed-runs
Nov 10, 2026
Merged

joshrotenberg merged 1 commit into
mainfrom
feat/152-retry-failed-runs

Conversation

@joshrotenberg

Copy link
Copy Markdown
Collaborator

Closes #152, with option 2 from the issue thread: keep classification structured-only and ship only the Retry change.

Plan

Need Before After
Retry a run that exited nonzero Retry.execute/3 returns {:ok, %Result{success: false}} after one attempt; :retry_on sees only {:error, _} :retry_on also receives {:ok, %Result{success: false}} and can retry it
Default predicate retries {:timeout, _} and {:system_cmd, _} unchanged; failed runs are not retried by default
Capacity classification none none, documented

The comment on #152 showed that codex-cli 0.165.0 does not pass the provider's status or error code through in --json output. A 429, 503 or 529 appears only in codex's own message text (exceeded retry limit, last status: 429 Too Many Requests, unexpected status 503 ...). A structured-only classifier would match nothing, so none is added. The Retry moduledoc and README document this and show a caller-side predicate over Turn.from_result/1 that matches that text, at the caller's choice.

The docs also state why failed runs are not retried by default: a retry re-sends the prompt and can repeat the failed attempt's tool commands.

Tests

test/codex_wrapper/retry_test.exs, with a fake codex that counts invocations:

  • retry_on receives {:ok, %Result{success: false}} and, returning true with max_retries: 2, runs codex 3 times;
  • the default predicate runs a failing codex once;
  • a successful run returns without calling retry_on.

Checks

mix format --check-formatted, mix compile --warnings-as-errors, mix credo --strict, mix test (837 passed, 4 excluded), mix dialyzer, mix docs --warnings-as-errors.

A run that exits nonzero returns {:ok, %Result{success: false}}, which
Retry.execute/3 returned after one attempt without calling :retry_on.
It now passes that tuple to :retry_on and retries when it returns true.
The default predicate still retries only timeouts and System.cmd errors.

The wrapper does not classify capacity or rate-limit failures: codex-cli
0.165.0 reports a 429, 503 or 529 only in its own message text. The
Retry docs and README say so and show a caller-side predicate.
@joshrotenberg
joshrotenberg marked this pull request as ready for review November 10, 2026 22:22
@joshrotenberg
joshrotenberg merged commit 5e6a652 into main Nov 10, 2026
5 checks passed
@joshrotenberg
joshrotenberg deleted the feat/152-retry-failed-runs branch November 10, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: classify capacity and rate-limit failures, and let Retry retry them

1 participant