← Documentation indexdocs/superpowers/plans/2026-10-09-v3-issue-231.md

V3 provider errors, timeouts, and retries implementation plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox syntax for tracking.

Goal: Complete R008, R009 and R167 in issue #231.

Architecture: Provider-owned errors normalize transport failures. A context-scoped deadline, cancellation event and four-attempt budget are shared by adapters, runtime workers and fallback. Successful response decoding stays outside retry.

Tech Stack: Python 3.12/3.13, standard-library contextvars/threading, existing provider SDKs, unittest.

Spec: The user-approved issue #231 plan and GitHub source requirements.

Global constraints

Review focus

Task 1: Normalize provider failures

Files: providers/errors.py, providers/init.py, tests/test_provider_errors.py; adapter transport boundaries. Interfaces: ProviderErrorKind; ProviderError(kind, provider, model, status_code, provider_code, retry_after, attempts); normalize_provider_error(exc, provider, model).

Task 2: Bound retries and fallback

Files: providers/retry.py, providers/fallback.py, adapter transports; tests/test_provider_errors.py, tests/test_providers.py. Interfaces: provider_request_scope(timeout=90, cancelled=None); remaining_timeout(); shared request state; existing _retry_with_backoff gains provider/model identity.

Task 3: Integrate runtime lifecycle and compatibility

Files: providers/calls.py, agent/context.py; runtime and delegation tests. Interfaces: Existing runtime methods/signatures preserved; structured boundary raises ProviderError; explicit text boundary renders legacy errors.

Task 4: Verify and deliver

Verification record

Local final verification: 597 full Python 3.12 tests; 96 focused Python 3.13 tests; make check/lint/docs-check and offline agent/subagent acceptance PASS. No paid calls.

Final follow-up regressions cover explicit retry ownership on dynamic callables, all-candidate Retry-After, and cancellation synchronized during actual backoff. Independent review and all local checks pass.

Automated review follow-up

GitHub findings were reproduced before fixes. Runtime and standalone adapters now reuse provider-owned bounded workers, including continuous-trickle responses. Stream request context remains in its producer worker; completed borrowed scopes stay usable while aborted consumption cancels. Azure identity and truncated Requests responses classify correctly, mid-stream attempt counts persist, unread error JSON does not replace the original failure, exhausted budgets remain typed, and impossible Retry-After waits fail immediately with the classified error. Legacy context sentinels also become typed at the structured boundary. Fresh whole-branch independent review reports no material findings.