56e7fd2adf
The outer conversation-loop except handler only left the loop on a local-processing error or when api_call_count >= max_iterations - 1. With the turn budget now unlimited by default (sys.maxsize), a permanent failure that escaped the inner retry/fallback machinery retried forever: ~64 retries/s, one core pegged, and the rotated agent.log history overwritten within minutes. Bound the loop with a small per-turn cap on total escaping exceptions (_MAX_OUTER_LOOP_ERRORS = 8, scaled down by a tiny explicit max_iterations so a manually bounded budget still governs). The legacy local-processing and near-limit exits are byte-identical; a new 'repeated_outer_errors' exit reason gets a user-facing explanation. The inner retry/fallback layer owns transient API recovery and terminates on its own, so only exceptions that escape it reach this cap - a successful turn is unaffected. Fixes #92450