Skip to content

[Plan / Interface] Server-owned provider recovery - #1912

Merged
JAORMX merged 4 commits into
mainfrom
plan/server-provider-recovery
Oct 5, 2026
Merged

JAORMX merged 4 commits into
mainfrom
plan/server-provider-recovery

Conversation

@JAORMX

@JAORMX JAORMX commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Stage: Plan / Interface

Defines server/runtime-owned live-run recovery for transient precommit provider failures: provider Retry-After, circuit-breaker cooldown and exclusive half-open admission, non-sliding budgets, parent/direct-write-child safety, four-host configuration, and removal of the TUI's duplicate automatic terminal retry.

Contract: docs/acceptance/server-provider-recovery.md
Approved amendment: 5899658b7ec278eee9ab4e9cdbe2e9f64815db55
Current plan after the main refresh: 2b19354ad779982ac87decc8c06feaf019b7a0a9
Pre-amendment plan: 86bc3c350a34b98be5c7ff586c62a40b844df58e
Original approved plan: 13a055fef4b4fbd57b239f488c9659a866bbddb6

Human-approved scope

  • 30m/60 actual wrapper calls per model step; active-process/run scope only, with no disconnected or restart continuation.
  • Existing spinner, operational logs, and attempt evidence. No new ADR or engine/wire API.
  • Recovery remains independent of prompt-cache TTL. Explain possible cache-write/input cost in the choose-models troubleshooting owner; add no TTL cutoff, ignore-TTL flag, cache-expiry state, or cache-specific notices.
  • Preserve caller-owned deadlines and the contextual reviewer's existing 90s total / at-most-three-attempt policy. Reviewer retry redesign and aggregate spend/retry budgets remain separate work.
  • Preserve every provider-neutral usage contribution already accepted by the wrapper, including buffered handoff on cancellation, without canceled semantic output, tool dispatch, or extra network reads.

The directing human approved this narrow amendment and explicitly authorized its commit/push on 2026-10-05. Implementation #1920 was previously authorized to stack before plan merge. Neither PR will be merged by the agent.

Integration prerequisites and implementation handoff

#1920 must integrate and revalidate against this amendment before claiming conformance. The following inherited defects require separately scoped prerequisite fixes:

  1. Engine/resilience cancellation accounting must retain known buffered usage exactly once in result and session accounting.
  2. Provider HTTP/in-band error display must exclude arbitrary upstream sensitive text while preserving typed causes and retry classification.

Opening follow-up issues alone does not satisfy these requirements. Feature-local obsolete retry helpers, redundant configuration, and stale documentation remain cleanup work in #1920. Partial raw-provider usage recovery, cache-aware cost controls, and contextual-review retry ownership are outside this amendment.

Verification of this amendment

  • Acceptance-plan checker: passed, with the existing generic invariant-test naming warning.
  • Checker regression fixtures: passed.
  • task docs: passed.
  • git diff --check: passed.
  • Advisory adversarial review: no remaining findings.

The inherited fixes are separately reviewable in #2097 (accounting) and #2098 (provider error display), and their code is integrated into #1920. The implementation must still pass final aggregate verification; the plan's documentation checks are not runtime acceptance evidence.

Alejandro accepted the cache-policy decision and submitted an approval. The remaining non-blocking cache-write usage logging request is tracked separately in #2096.

@JAORMX
JAORMX force-pushed the plan/server-provider-recovery branch 2 times, most recently from d13bd65 to 1715638 Compare September 25, 2026 11:13
## Human decisions

- [x] Runtime ownership and decision-record route — Decision: the directing human approved shared server/runtime-owned recovery, not a TUI timer, and explicitly requested no ADR. Frozen ADR 0239 remains unchanged.
- [x] Command defaults and exposure — Decision: 30m recovery budget and 60 actual wrapper calls (initial included) per model step for `mecated`, `mecak8s`, embedded `mecatui`, and `mecatequi`; expose `--llm-recovery-budget` and `--llm-max-attempts` on all four (mecatui flags configure only its embedded server), reject negative budget and explicitly nonpositive attempts, add no settings-YAML key, keep zero-valued `app.Config` inert, and give `mecatequi` the existing host parity defaults 300s/180s/5/30s for per-attempt/idle/threshold/cooldown. The approved extra-cost limitation is that this is not a task-wide spend budget: distinct model steps may each recover, and engine token ceilings are checked at turn boundaries rather than between wrapper retries. Existing shorter auxiliary-check deadlines (30s) and guardrail-down policy remain effective without bypass; scheduled fires retain their dominant 30m wall timeout and `StopTimeout` record.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more on the defaults. For providers where we know the TTL, Anthropic being the clear one, I think we should warn at startup when recovery is enabled and the cache TTL is 5m. That's the default, i.e. --anthropic-cache-ttl unset or 5m.

With the TTL cap suggested on AC4.1, 5m leaves very little room. Breaker cooldown, backoff, and a typical 429 Retry-After can eat most of that before the first retry, so I'd expect most meaningful recoveries to end up failing. Without the cap, they'd succeed but on a cold cache. Either way, the operator should hear about it. Something like: "LLM recovery is enabled but the Anthropic cache TTL is 5m, so most recoveries will stop at the TTL; set --anthropic-cache-ttl 1h for longer recovery." The choose-models troubleshooting page this PR already updates seems like the right place to document the pairing too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that choose-models is the right place to explain the pairing. The amendment makes that an explicit documentation requirement, including the cost trade-off: Anthropic's 1h cache has a higher write price than 5m, so it shouldn't be presented as a free upgrade.

For this increment we're leaving out a cache-specific startup warning. A 5m TTL with a longer recovery budget is an intentional availability/cost choice, and without a TTL cap the run won't stop just because those five minutes passed. We also don't have measurements supporting a claim that most recoveries would fail under that cap.

The docs will explain that recovery can outlast retention, later requests may incur cache-write/input charges, and operators can choose a longer cache TTL or lower recovery limits according to their priorities. No automatic TTL changes or new flags. The plan edit is still local, pending publication.

https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pricing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on dropping the cap-based warning; my "most recoveries will fail" claim depended on the cap. Fine with the choose-models docs covering the pairing. One small, non-blocking ask for #1920 or a follow-up: since the cost lands on users who may not know about caching, could the recovered-outcome log from AC7.1 include the cache-write tokens the provider reports on the recovered call? That makes the cost visible from real usage without predicting expiry. Happy to leave it to a follow-up if it's out of scope here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked separately in #2096. Agreed that provider-reported usage is the right signal; no expiry prediction needed.

The follow-up calls out the timing detail: recovery can be reported before terminal usage arrives, so we need to distinguish unavailable usage from a reported zero and attribute the value to the recovered attempt rather than the accumulated discarded attempts. Keeping it non-blocking for this recovery change.

Record human-approved recovery policy and stacked implementation authorization.

Co-Authored-By: OpenAI <[email protected]>
@JAORMX
JAORMX force-pushed the plan/server-provider-recovery branch from 1715638 to 86bc3c3 Compare October 5, 2026 08:17
@JAORMX
JAORMX merged commit 39dcc11 into main Oct 5, 2026
29 checks passed
@JAORMX
JAORMX deleted the plan/server-provider-recovery branch October 5, 2026 15:00
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 7, 2026
2 tasks

This branch was successfully deployed

1 active deployment
Preview — 1cc1a831 Deployed Oct 5, 2026 by vercel[bot]
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.

2 participants