Cooldown
Cooldown algorithm
Router keeps last N results (`N = cooldown_streak`, default `7`).
When error rate in this window becomes `> 50%` and at least 2 samples exist, uplink enters cooldown.
Cooldown duration uses exponential backoff: `min(max_cooldown, min_cooldown * 2^attempt_no)`.
On successful recovery (error rate `<= 50%`), attempt counter is reset.
Rate Limit & Capacity
Min interval between dispatches is `1.0 / rate_limit` seconds.
When a request is blocked by rate limit or capacity, it waits in queue before round-robin selection.
Adaptive formula
`observed_rate = min(rate_limit, 1 / delta_t)`
`alpha = exp(-ln(2) * delta_t / ema_half_life_sec)`
`actual_rate = alpha * prev_actual_rate + (1 - alpha) * observed_rate`
`fail => new_rate = old_rate * (1 - on_fail_slowdown)`
`success => increase only if actual_rate >= old_rate * success_min_utilization`
`success update => old_rate * (1 - on_fail_slowdown)^(-target_fails_rate)`
Special Cases
`timeout_sec=0` => non-batch `1800 sec`, batch `18000 sec` (editable in Settings).
`cooldown_streak=0|min_cooldown_sec=0|max_cooldown_sec=0` => settings defaults.
`rate_limit=0|max_capacity=0` => non-batch settings defaults (`10` req/sec, `100` in-flight).
`adaptive_rate_enabled=true` updates current `rate_limit` in runtime + DB within [`adaptive_min_rate`, `adaptive_max_rate`].
`adaptive_* = 0` => adaptive defaults from Settings (including EMA half-life and success utilization gate).
`max_batch_size=0|max_batch_capacity=0` => settings defaults.
`collect_interval_script` empty => settings default collect script.
`hourly_limit=0|daily_limit=0` => unlimited.
`price_200k_enabled=true` applies 200k+ prices only when `prompt_tokens > 200000`.