Skip to content

feat: optional exponential backoff with jitter before re-prompting#7

Merged
ShutovKS merged 1 commit into
devfrom
feat/retry-backoff
Jul 14, 2026
Merged

feat: optional exponential backoff with jitter before re-prompting#7
ShutovKS merged 1 commit into
devfrom
feat/retry-backoff

Conversation

@ShutovKS

Copy link
Copy Markdown
Owner

Проблема

На транзиентной ошибке плагин мгновенно ре-промптил fallback-модель. Если провайдер лимитирует все свои модели, это лишь усиливает нагрузку.

Решение

  • backoff_ms (по умолчанию 0 — мгновенно, поведение не меняется) и backoff_max_ms (по умолчанию 30s).
  • При включении — computeBackoff(): экспоненциальный рост по номеру попытки с equal-jitter, ограничен backoff_max_ms; ожидание перед ре-промптом.
  • Значения клампятся к >= 0.
  • computeBackoff экспортирован и покрыт юнит-тестами с инъекцией RNG (детерминированно).

Тесты

  • backoff_ms: 0 → 0.
  • Рост и границы equal-jitter (random 0/1).
  • Клампинг к backoff_max_ms.
  • Интеграционный: retry всё равно происходит, с задержкой.

Юнит-тесты 53/53, typecheck чист.

🤖 Generated with Claude Code

On a transient error the plugin re-prompted the fallback model instantly,
which can hammer a provider that is rate-limiting all of its models.

Adds `backoff_ms` (default 0 = instant, unchanged) and `backoff_max_ms`
(default 30s cap). When set, the plugin waits computeBackoff() = exponential
growth per attempt with equal jitter, clamped to the cap, before the retry.
computeBackoff is exported and unit-tested with an injected RNG.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ShutovKS ShutovKS merged commit 1693b60 into dev Jul 14, 2026
1 check passed
@ShutovKS ShutovKS deleted the feat/retry-backoff branch July 14, 2026 07:27
@ShutovKS ShutovKS mentioned this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants