Skip to content

feat(discuss): retry a participant turn or scribe call once after a provider timeout - #791

Merged
ajianaz merged 3 commits into
developfrom
feat/discuss-timeout-retry
Nov 15, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/discuss-timeout-retry

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What

In the discussion driver, a participant turn or scribe call that fails with the provider's own timeout is made once more before the turn fails. Second ask of #756 (the knob itself is #786).

Why

A timeout cost a whole resume cycle for a participant turn, and the scribe's digest was refused at the first timeout (round passed on as written). One retry absorbs the occasional slow generation without changing what the discussion may spend or decide.

Changes

  • Only the transport's own timeout qualifies (failover::is_timeout_error: timeout: <phase>, or the same after the json: prefix of a reply cut while read). Anchored: an http status: 4xx/5xx (whatever its body says), io:, malformed, stream and capability errors never retry.
  • Driver::call takes a retry flag: true for participant turns and the scribe, false for the checker. At most one retry per call, a bounded loop with no recursion. A second timeout fails the turn exactly as before (resumable ledger).
  • The retry is a call like any other. It goes through admit, so the discussion budget and the goal pot still hard-stop it (a retry that does not fit records the budget escalation and no second call runs), it is settled, and charged to the pot. A timed-out call keeps the existing accounting (what the provider reported, nothing when it reported nothing).
  • Ledger: Event::Reserve gains an optional retry_of (the audit note), skipped when absent, so ordinary reservations are written exactly as before and older readers ignore the field. DiscussionLog::reserve_retry enforces the rules in the ledger itself: the original must be settled, of the same round and kind, not itself a retry, and not retried before. The gate, max_rounds, rosters and the dissent rules are untouched.
  • tole audit --discussion shows how many calls of a round were retried; the outcome carries a note per retry.
  • Docs: threat-model row and CHANGELOG.

Testing

  • Driver tests: participant timeout retried once, charged (ledger and pot) and recorded with retry_of; a second timeout fails the turn with exactly two calls and a resume goes on; no retry for 500, http status: 504 ... timeout, 429, 400, io, malformed, stream-read and thread-died errors (while the body-read json: timeout: global form is one); scribe retried once (digest used) and a second timeout falls back as before with dissent passed on; the checker is not retried; a retry that does not fit the discussion budget or the goal pot is the hard stop with a single call.
  • Ledger tests: retry rules (unsettled, unknown, other kind, other round, once, retry of a retry, charged), budget escalation on a retry that does not fit, old ledger lines still read, no new key on ordinary reservations. Classifier test for is_timeout_error.
  • Mutation checks, each killed by a test: retry on any text containing "timeout", no once-limit in the host, ledger without the single-retry rules (two variants), retry not charged to the pot, retry not recorded, retry skipping the budget check, checker retried, scribe not retried, participant not retried.
  • cargo fmt, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace.

Closes #756

…rovider timeout (#756)

A timeout cost a whole resume cycle for a participant turn and the scribe digest was refused at the first one. The driver now repeats such a call once when the provider failed with its own timeout and nothing else (not 4xx/5xx, not other errors). The retry is reserved and settled like any call, so the discussion budget and the goal pot still hard-stop it, and the ledger records it as a reservation with retry_of naming the timed-out call; the ledger refuses a second retry of a call and a retry of a retry. A second timeout fails the turn as before. The checker is unchanged.
Threat-model row and changelog entry for the one retry of a timed-out participant or scribe call.
@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 c12072a into develop Nov 15, 2026
18 checks passed
ajianaz added a commit that referenced this pull request Nov 15, 2026
…s estimate when no usage is reported (#804) (#805)

A call that failed with no reported usage settled at 0 tokens, so a discussion budget (a hard cap) could be exceeded without the ledger knowing, and the retry of #791 doubled the exposure. A call that fails with no reported usage after the request may have left now settles at its reserved estimate, never more than its own carve, and the settle record carries charged: timeout or charged: unreported. Reported usage still wins and a successful call without usage keeps its estimate. The classifier request_may_have_been_sent is a closed list of anchored prefixes for failures before the send (host not found, connection failed, timeout: connect and timeout: resolve, bad uri, invalid proxy url, TLS handshake errors, the image-input pre-check); anything else, unknown text included, and any failover chain is charged. charged is an optional field of the settle event, skipped when absent, so old ledgers and readers still work, and a settle is final so a resume never charges a call twice. The driver charges both the ledger and the goal pot, the retry still goes through admit (two timeouts cost two estimates and the budget stops the discussion at the cap), and tole audit --discussion now lists rounds that only have reservations, with retries and the charged calls in text and --json.

Closes #804
@ajianaz
ajianaz deleted the feat/discuss-timeout-retry branch November 20, 2026 08:36
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.

discuss: provider calls use the 120s default timeout — long-context rounds on reasoning models always die at 'timeout: global'

2 participants