fix(credential-pool): harden multi-account pool — health scoring, dynamic cooldown, leases, mark_success#5692
Closed
MestreY0d4-Uninter wants to merge 1 commit into
Conversation
…ldown, leases, mark_success Ported from fix/credential-pool-hardening onto current upstream main. Layer 1 — PooledCredential + dynamic cooldown + health scoring - Add fields: cooldown_until, last_retry_after_seconds, last_error_category, last_success_at, consecutive_failures, consecutive_429s, transient_error_count, structural_error_count - Add helpers: _is_structural_error(), _is_transient_error() - Add _entry_health_score(): 100-point score penalising failures/429s, bonus for recency - Update _mark_exhausted(): accept retry_after_seconds + error_category - Update _available_entries(): tri-level cooldown (Retry-After > reset_at > fixed TTL) - Update _select_unlocked(): pre-sort by health score before applying strategy - Update mark_exhausted_and_rotate(): propagate retry_after_seconds + error_category - Add mark_success(): reset counters + set last_success_at on successful requests - Add size(), acquire_lease(), release_lease(), active_lease_count() Layer 2 — run_agent failure classification + Retry-After extraction - Add _extract_retry_after_seconds(): reads Retry-After, x-ratelimit-reset headers - Add _classify_api_failure(): stable error categories for pool/logging decisions - Add _should_defer_fallback_to_credential_pool(): prefer pool recovery over fallback - Update _recover_with_credential_pool(): pass api_error for Retry-After extraction - Wire mark_success() call after every successful API response - Wire _should_defer_fallback_to_credential_pool() into rate-limit error path Layer 3 — Subagent pool participation + lease-based concurrency - _resolve_child_credential_pool() in delegate_tool.py: children share parent pool - acquire_lease()/release_lease() in _run_single_child() for concurrency control Layer 4 — Task-tier delegation profiles - SUPPORTED_TIERS + resolve_tier_config() in delegate_tool.py - tier param in delegate_task() + per-task batch schema Fix gaps vs original PR: - api_error now passed to _recover_with_credential_pool (Retry-After was unreachable) - mark_success() added and called in success path (last_success_at was never set) - consecutive_failures/429s reset on success (counters were monotonically increasing)
Contributor
Author
|
Superseded by three focused slices from the refreshed audit: A (credential_pool.py) — Codex CLI sync identity guard + mark_success + size + active_lease_count Each slice validated individually in clean worktrees against current origin/main. Patches ready for local review. |
MestreY0d4-Uninter
pushed a commit
to MestreY0d4-Uninter/hermes-agent
that referenced
this pull request
Apr 13, 2026
…override - Add SUPPORTED_TIERS and resolve_tier_config() for task-profile routing - Per-task tier resolution in batch delegation with reasoning floor guardrails - Explicit override_reasoning_effort in _build_child_agent() - 18 new tier/reasoning tests, 73 total delegate tests passing Extracted from refreshed audit of stale PR NousResearch#5692.
MestreY0d4-Uninter
pushed a commit
to MestreY0d4-Uninter/hermes-agent
that referenced
this pull request
Apr 13, 2026
… reasoning_effort Unified implementation combining tier profiles (from stale PR NousResearch#5692) with model pool validation (inspired by PR NousResearch#5229). Features: - 5 named tiers: light, heavy, review, planning, research - Each tier configures model, provider, reasoning_effort, max_iterations - Reasoning floor guardrails prevent silent degradation: heavy/research >= medium, planning/review >= high - Per-task tier in batch mode overrides top-level tier - Optional delegation pool for model validation - override_reasoning_effort in _build_child_agent - resolve_tier_config() merges tier over flat base config - Schema updated with tier enum at top-level and per-task Resolution order: task.tier > top-level tier > default_tier > flat config > parent Config example: delegation: default_tier: heavy tiers: light: {model: gpt-5.4-mini, reasoning_effort: low, max_iterations: 25} review: {model: gpt-5.4, reasoning_effort: xhigh, max_iterations: 60} pool: - model: gpt-5.4, strengths: coding, debugging Tests: - 56 new unit tests (test_delegate_tiers.py) - 7 real integration tests (test_delegate_tiers_real.py) - 128 total delegate tests passing - Backward compatibility verified (flat configs work unchanged)
MestreY0d4-Uninter
added a commit
to MestreY0d4-Uninter/hermes-agent
that referenced
this pull request
Apr 14, 2026
… reasoning_effort Unified implementation combining tier profiles (from stale PR NousResearch#5692) with model pool validation (inspired by PR NousResearch#5229). Features: - 5 named tiers: light, heavy, review, planning, research - Each tier configures model, provider, reasoning_effort, max_iterations - Reasoning floor guardrails prevent silent degradation: heavy/research >= medium, planning/review >= high - Per-task tier in batch mode overrides top-level tier - Optional delegation pool for model validation - override_reasoning_effort in _build_child_agent - resolve_tier_config() merges tier over flat base config - Schema updated with tier enum at top-level and per-task Resolution order: task.tier > top-level tier > default_tier > flat config > parent Config example: delegation: default_tier: heavy tiers: light: {model: gpt-5.4-mini, reasoning_effort: low, max_iterations: 25} review: {model: gpt-5.4, reasoning_effort: xhigh, max_iterations: 60} pool: - model: gpt-5.4, strengths: coding, debugging Tests: - 56 new unit tests (test_delegate_tiers.py) - 7 real integration tests (test_delegate_tiers_real.py) - 128 total delegate tests passing - Backward compatibility verified (flat configs work unchanged)
MestreY0d4-Uninter
pushed a commit
to MestreY0d4-Uninter/hermes-agent
that referenced
this pull request
Apr 19, 2026
…rom_cli - Add account-identity verification before syncing tokens from ~/.codex/auth.json - Fail closed if CLI identity cannot be proven to match the pool entry - Add mark_success(), size(), active_lease_count() helpers to CredentialPool - Tests: 3 sync identity guard + mark_success persistence Extracted from refreshed audit of stale PR NousResearch#5692.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports and refreshes the multi-account credential-pool hardening work onto current
main.This PR improves credential selection, cooldown handling, fallback behavior, and subagent concurrency when a provider has multiple accounts/credentials in the pool.
It also fixes three functional gaps in the earlier version of this work:
api_errorwas not passed into pool recovery, soRetry-Afterextraction was unreachablelast_success_atexisted but was never updatedconsecutive_failures/consecutive_429sWhat changes
Credential pool health and cooldown
PooledCredential_entry_health_score()fill_first,round_robin,random, orleast_usedRetry-After/ rate-limit headersreset_at/resets_at)Success-path recovery
mark_success()to updatelast_success_atconsecutive_failuresandconsecutive_429safter a successful requestmark_success()from the main API success pathFailure classification and fallback behavior
_extract_retry_after_seconds()_classify_api_failure()api_errorinto_recover_with_credential_pool()Subagent coordination
delegate_tool.pyWhy this helps
Without these changes, a multi-account pool can still behave poorly under rate limits:
Testing
Passed locally:
python -m pytest tests/test_credential_pool_routing.py tests/tools/test_delegate.py tests/test_run_agent.py -o 'addopts=' -q312 passedNotes
This PR is the current-upstream refresh of the earlier
fix/credential-pool-hardeningwork, rebased as a clean replacement on top of today'smainrather than continuing from the stale branch history.