Skip to content

feat: retry a timeout-classified provider failure once per turn - #62

Merged
ajianaz merged 1 commit into
developfrom
feat/provider-timeout-retry
Sep 12, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/provider-timeout-retry

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

The turn loop (drive()) now retries a timeout-classified provider error once per turn before surfacing ProviderFailed. Budget is per turn (PROVIDER_TIMEOUT_RETRIES = 1), not per step, so a flapping gateway gets at most one extra call per turn. The retry decision is recorded as a durable ERROR entry ("provider timeout, retrying") before the retry fires. MockProvider::scripted_with_failures is added so provider failures are scriptable in tests.

Why (the problem you're solving)

Issue #58: a provider global timeout at turn start killed entire missions before any tool ran (vetio 8-icon mission, 2026-09-11), while the same durable session completed end-to-end on a manual resume — proving the failure was transient, not fatal. Nuance vs the issue text: the upstream budget that actually binds is tole's own 120s default request timeout (gateway default is 300s); the retry protects the turn either way.

Testing (how you verified this works)

4 new regression tests in turn_loop.rs (all pass, 21/21 in the suite):

  • provider_timeout_retried_once_then_succeeds — timeout → retry → Final, exactly one durable retry record.
  • provider_timeout_second_failure_aborts — second timeout aborts with ProviderFailed (1 retry + 1 failure record).
  • non_timeout_provider_error_not_retried — 401-class errors keep the immediate-abort path.
  • flapping_timeout_retries_only_once_per_turn — timeout → success → timeout: no second retry.
    Full gate: cargo fmt --check clean, clippy -D warnings 0 findings, cargo test --workspace green. Safe-by-construction: a failed provider step commits nothing, so the retried transcript is identical; turn-level ERROR entries are excluded from the wire request body (no parent intent → skipped), so the retry cannot poison the context.

Closes #58

A provider global timeout at turn start killed entire missions before
any tool ran, while the same durable session completed end-to-end on a
manual resume. Drive() now retries a timeout-classified provider error
once per turn (not per step): the failed step commits nothing, so the
transcript is unchanged; the retry decision is appended as a durable
ERROR entry before the retry fires. Non-timeout errors and second
timeouts keep the existing abort path.

Closes #58
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 69d0a11 into develop Sep 12, 2026
13 checks passed
@ajianaz
ajianaz deleted the feat/provider-timeout-retry branch September 12, 2026 04:19
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.

Provider global timeout kills a mission before any tool runs - add harness-level retry-once

1 participant