feat(agents): add LLM agent retry mechanisms with exponential backoff #70

Merged
CoreRasurae merged 2 commits from feature/m2-llm-agent-retry-mechanisms into master 2026-07-03 15:21:51 +00:00

2 Commits

Author SHA1 Message Date
CoreRasurae 52451b2550 test(agents): disable retry in error-path tests to avoid unnecessary delays
CI / lint (pull_request) Successful in 36s
CI / typecheck (pull_request) Successful in 52s
CI / security (pull_request) Successful in 50s
CI / quality (pull_request) Successful in 34s
CI / unit_tests (pull_request) Successful in 3m9s
CI / integration_tests (pull_request) Successful in 1m3s
CI / build (pull_request) Successful in 35s
CI / coverage (pull_request) Successful in 3m9s
CI / status-check (pull_request) Successful in 4s
CI / lint (push) Successful in 46s
CI / typecheck (push) Successful in 51s
CI / security (push) Successful in 50s
CI / quality (push) Successful in 34s
CI / unit_tests (push) Successful in 3m8s
CI / build (push) Successful in 37s
CI / coverage (push) Successful in 3m8s
CI / integration_tests (push) Successful in 1m12s
CI / status-check (push) Successful in 2s
Pre-existing tests that inject error-raising mock chat models (raising
LangChainException or RuntimeError) were triggering the full
exponential-backoff retry loop (~63.5s per test). With 6 such tests,
this added minutes to the suite.

Set max_retries=0 in each error-path step definition so the retry loop
fails fast on the first attempt, preserving the test contract while
avoiding unnecessary sleep delays.
2026-07-03 16:00:20 +01:00
CoreRasurae 55734cd512 feat(agents): add LLM agent retry mechanisms with exponential backoff
- Documents the retry feature implementation (issue #69, ADR-2032)

Introduce configurable retry mechanisms (ADR-2032) for all LLM agent
communications (main agent and pruning agent) with exponential backoff.

- New config fields: max_retries (default 7), max_retry_time (default 60s)
  -1 sentinel disables the corresponding guard (infinite retries/time)
- Exponential backoff: initial 0.5s, doubled each retry
- Termination: whichever comes first (max_retries or max_retry_time),
  with -1 disabling the respective check
- Counter and accumulated wait time reset on success
- Timeout ExecutionError includes URL, actor graph name, and retry stats
- Uniform scope: applies to both main agent and pruning agent
- Timeout raises ExecutionError(kind="timeout") with URL, actor graph
  name, retry count, and accumulated wait time in the message (D-7)
- Same client/connection reused across retries, no re-establishment (D-6)
- Uniform scope: applies to both main agent and pruning agent (D-5)
- Graph name threaded through state metadata and ContextVar for error
  reporting
- BDD tests (7 scenarios) for retry behaviour including -1 sentinel cases
- Reject max_retries/max_retry_time values < -1 with ConfigurationError
- Reset current_graph_name ContextVar after node execution
- Wrap no-tools astream() with per-chunk granular retry via call_with_retry
- Update ADR D-7 with symmetrical disabled-guard example
- Update CHANGELOG to reflect full feature scope

ISSUES CLOSED: #69
2026-07-03 16:00:11 +01:00