Skip to content

fix: fallback chain nous normalization + same-provider rate-limit dedup - #19

Merged
OmarB97 merged 1 commit into
mainfrom
fix/fallback-chain-nous-normalization-same-provider-dedup
May 28, 2026
Merged

fix: fallback chain nous normalization + same-provider rate-limit dedup#19
OmarB97 merged 1 commit into
mainfrom
fix/fallback-chain-nous-normalization-same-provider-dedup

Conversation

@OmarB97

@OmarB97 OmarB97 commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Two systemic bugs in the fallback provider chain:

Bug 1: nous provider misclassified as aggregator → HTTP 400

The nous provider was in _AGGREGATOR_PROVIDERS, causing _prepend_vendor() to keep the nousresearch/ prefix when falling back to the Nous direct API (inference-api.nousresearch.com). The direct API expects bare model names like hermes-4-70b, not nousresearch/hermes-4-70b, resulting in HTTP 400 "Bad Request".

Fix: Move nous from _AGGREGATOR_PROVIDERS to _MATCHING_PREFIX_STRIP_PROVIDERS and add nousresearch as a provider alias for nous so _strip_matching_provider_prefix() correctly strips the nousresearch/ prefix.

Bug 2: same-provider rate-limit loop → all fallbacks hit same 429

_try_activate_fallback() only deduped entries matching the exact (provider, model) pair. When the primary provider (e.g. opencode-zen) was rate-limited, all fallback entries on the same provider would also hit the same 429, burning the retry budget pointlessly.

Fix: When the trigger is a rate-limit (429) or billing error and an active cooldown is set, skip fallback entries on the same provider. Different providers are still tried normally.

Files Changed

  • hermes_cli/model_normalize.py: Move nous from aggregator to matching-prefix-strip
  • hermes_cli/models.py: Add nousresearchnous alias
  • agent/chat_completion_helpers.py: Add same-provider rate-limit dedup
  • tests/hermes_cli/test_model_normalize.py: Update nous normalization tests
  • tests/run_agent/test_provider_fallback.py: Add same-provider cooldown test

Testing

  • Model normalization: all 79 tests pass
  • Same-provider dedup logic verified inline
  • Pre-existing test failures in test_provider_fallback.py are unrelated (test setup issue)

Two systemic bugs in the fallback provider chain:

1. nous provider was misclassified as _AGGREGATOR_PROVIDERS, causing
   _prepend_vendor() to keep the nousresearch/ prefix when falling back
   to the Nous direct API (inference-api.nousresearch.com). The direct
   API expects bare model names like hermes-4-70b, not
   nousresearch/hermes-4-70b, resulting in HTTP 400 'Bad Request'.

   Fix: Move nous from _AGGREGATOR_PROVIDERS to
   _MATCHING_PREFIX_STRIP_PROVIDERS and add 'nousresearch' as a
   provider alias for 'nous' so _strip_matching_provider_prefix()
   correctly strips the nousresearch/ prefix.

2. _try_activate_fallback() only deduped entries matching the exact
   (provider, model) pair. When the primary provider (e.g. opencode-zen)
   was rate-limited, all fallback entries on the same provider would also
   hit the same 429, burning the retry budget pointlessly.

   Fix: When the trigger is a rate-limit (429) or billing error and an
   active cooldown is set, skip fallback entries on the same provider.
   Different providers are still tried normally.

Files changed:
- hermes_cli/model_normalize.py: Move nous from aggregator to matching-prefix-strip
- hermes_cli/models.py: Add nousresearch → nous alias
- agent/chat_completion_helpers.py: Add same-provider rate-limit dedup
- tests/hermes_cli/test_model_normalize.py: Update nous normalization tests
- tests/run_agent/test_provider_fallback.py: Add same-provider cooldown test

Refs: fallback-chain-nous-normalization-same-provider-rate
@OmarB97
OmarB97 merged commit e635b4e into main May 28, 2026
15 of 19 checks passed
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/fallback-chain-nous-normalization-same-provider-dedup vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9544 on HEAD, 9543 on base (🆕 +1)

🆕 New issues (1):

Rule Count
unresolved-import 1
First entries
tests/run_agent/test_provider_fallback.py:315: [unresolved-import] unresolved-import: Cannot resolve imported module `hermes_cli.failover`

✅ Fixed issues: none

Unchanged: 5029 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@OmarB97
OmarB97 deleted the fix/fallback-chain-nous-normalization-same-provider-dedup branch May 28, 2026 17:11
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.

1 participant