Skip to content

feat: optional debug logging of fallback decisions#8

Merged
ShutovKS merged 1 commit into
devfrom
feat/debug-logging
Jul 14, 2026
Merged

feat: optional debug logging of fallback decisions#8
ShutovKS merged 1 commit into
devfrom
feat/debug-logging

Conversation

@ShutovKS

Copy link
Copy Markdown
Owner

Проблема

Невозможно понять, почему fallback сработал или не сработал (не тот статус? исчерпаны попытки? cooldown? нет доступной модели?) — поддержка вслепую.

Решение

Новая опция debug (по умолчанию false). При включении плагин пишет однострочный трейс [model-fallback] … в stderr для каждого решения: причина срабатывания/пропуска (disabled / нет fallback_models / не ретраится / max_attempts / stale error / нет доступной модели / in-flight), задержка backoff, сам switch и recovery к исходной модели. По умолчанию выключено — нет вывода.

OpenCode выводит stderr плагина в свой лог-поток, поэтому трейс грепается без необходимости экспортировать logger в плагины.

Тесты

  • debug: false → stderr пуст.
  • debug: true + retry → лог содержит [model-fallback] и switched to ….
  • debug: true + не-ретраимая ошибка → лог содержит not retryable.

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

🤖 Generated with Claude Code

When `debug: true`, the plugin writes a single-line `[model-fallback] ...`
trace to stderr for every fallback decision: why a retry fired or was
skipped (disabled, no fallback_models, not retryable, max_attempts reached,
stale error, no available model, in-flight), the backoff delay, the actual
switch, and recovery to the original model. Default off; no output otherwise.

OpenCode surfaces plugin stderr in its log stream, so this is greppable
without exposing a logger to plugins.

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

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 25fe4e5 into dev Jul 14, 2026
1 check passed
@ShutovKS ShutovKS deleted the feat/debug-logging branch July 14, 2026 07:48
@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