Skip to content

fix(discuss): charge a timed-out call its estimate and show incomplete rounds in the audit - #805

Merged
ajianaz merged 1 commit into
developfrom
fix/discuss-timeout-charge
Nov 15, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/discuss-timeout-charge

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

A discussion call that fails with no reported usage after the request may have left (a transport timeout above all) is charged its reserved estimate instead of 0. tole audit --discussion now also lists rounds that never completed, with their retries and charged calls.

Why

A timed-out call settled at 0 tokens, so the discussion budget (a hard cap) could be exceeded without the ledger knowing, and the retry of #791 doubled the exposure. The live E2E of #756 showed tokens_used 0 after two real provider calls. A timeout is the same kind of unknown as a crash, which is already charged the whole carve.

Changes

  • tole_core::failover::request_may_have_been_sent: closed list of anchored prefixes for failures that provably came before the request left (refused connection, DNS, timeout: connect/resolve, bad URL, TLS handshake). Anything else, an unknown text included, and any failover chain is charged.
  • DiscussionLog::settle_charged: settles at the call's own estimate (never more) and records charged (timeout or unreported) on the settle event. The field is optional and skipped when absent, so old ledgers and readers are unaffected. The settle stays final, so a resume never charges a call twice.
  • Driver attempt: reported usage wins as before; no usage plus a possibly-sent failure is charged to the ledger and the goal's pot. The retry still goes through admit: two timeouts cost two estimates and the budget stops the discussion with the existing escalation.
  • Audit (text and --json): rounds with only reservations are listed; charged: [{call, why, tokens}] added.
  • Docs: docs/automation-design.md, threat model row, CHANGELOG under Unreleased.

Testing

  • New tests: timed-out call charged the estimate, second timeout stops at the budget and resume does not double charge, connect failure before sending not charged, other failure without usage charged as unreported, goal-pot charged, classifier table, ledger format compatibility, incomplete-round audit output.
  • Mutation checks (each fails the matching tests): timeout settles 0, classifier always false, classifier always true, pot not charged, incomplete rounds not listed.
  • cargo fmt, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace pass locally.

Closes #804

…e rounds in the audit (#804)

A call that fails with no reported usage after the request may have left settles at its reserved estimate (bounded by its carve) with a charged note, instead of 0. Only a failure before the request left stays free. tole audit --discussion lists rounds that never completed with their retries and charged calls.
@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 8c80411 into develop Nov 15, 2026
22 checks passed
@ajianaz
ajianaz deleted the fix/discuss-timeout-charge branch November 20, 2026 08:38
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: a timed-out call settles at 0 tokens, so the discussion budget can be exceeded without the ledger knowing (made worse by the retry of #791)

2 participants