# Todo 52.13 Provider Cleanup Exception Priority Plan **Status:** done ## Goal Preserve the original provider failure, cancellation, or generator-close signal when cleanup of the wrapped provider iterator also fails. ## Observation `TimingChatClient.stream_chat()` awaits `iterator.aclose()` in `finally`. If a provider exception or `CancelledError` is already propagating and `aclose()` raises another exception, the cleanup exception replaces the original. This can hide the real provider failure and convert cancellation into a normal runtime error instead of preserving interruption semantics. ## Scope - Add regressions for provider exception plus close failure and cancellation plus close failure. - Keep the active provider/cancellation/generator-close exception as the primary propagated exception. - Propagate `aclose()` failure when no other exception is active. - Always append the timing attempt without changing provider-await elapsed, usage completeness, or parallel-probe behavior. ## Files - Modify: `src/agent_lab/application/benchmark.py` - Modify: `tests/test_benchmark_runner.py` ## Verification - `uv run pytest tests/test_benchmark_runner.py -q` - `uv run pytest tests/test_benchmark_runner.py tests/test_benchmark_reporting.py -q` - `uv run pytest` - `git diff --check`