Commit fab8a09
feat(resilience): add parse error recovery, tool timeout, and circuit breaker
4.1 Parse Error Recovery: track consecutive __parse_error tool calls;
bail with clear error after max_parse_retries (default 2) consecutive
failures. Counter resets to 0 when any tool with valid args executes.
4.2 Tool Execution Timeout: wrap execute_with_context in
tokio::time::timeout when tool_timeout_ms is set. Timeout produces an
error message fed back to the LLM so the session can recover.
4.3 Circuit Breaker: non-streaming LLM calls are retried up to
circuit_breaker_threshold times (default 3) with 100ms*attempt backoff
before the loop aborts. Streaming mode fails immediately on any error
(events cannot be replayed).
All three settings exposed via SessionOptions builder methods:
.with_parse_retries(n)
.with_tool_timeout(ms)
.with_circuit_breaker(n)
.with_resilience_defaults() — convenience bundle
8 new tests; total: 1166 passing.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>1 parent 4959e55 commit fab8a09
4 files changed
Lines changed: 535 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| |||
0 commit comments