Skip to content

fix(run_agent): pass custom_providers to compression feasibility check (#20608) - #20724

Closed
Beandon13 wants to merge 1 commit into
NousResearch:mainfrom
Beandon13:fix/hermes-20608-compression-feasibility-custom-providers
Closed

fix(run_agent): pass custom_providers to compression feasibility check (#20608)#20724
Beandon13 wants to merge 1 commit into
NousResearch:mainfrom
Beandon13:fix/hermes-20608-compression-feasibility-custom-providers

Conversation

@Beandon13

Copy link
Copy Markdown
Contributor

Bug

_check_compression_model_feasibility() calls get_model_context_length() without the custom_providers argument. The main model path in the same file (lines 2039, 2436) correctly passes custom_providers, but the compression check omits it.

get_model_context_length has step 0b that checks custom_providers for per-model context_length overrides — but only when custom_providers is passed. When omitted, step 0b is skipped and resolution falls through to the 256K default, causing a spurious startup warning:

⚠ Compression model deepseek/deepseek/deepseek-v4-flash (zhinao) context is 256,000 tokens,
but the main model deepseek/deepseek/deepseek-v4-pro (custom)'s compression threshold was
750,000 tokens. Auto-lowered this session's threshold to 256,000 tokens so compression can run.

This happens even when the custom provider defines context_length: 1000000 for that model in config.yaml.

Fix

Load custom_providers via load_config() / get_compatible_custom_providers() (mirroring the existing pattern at line ~2429) and forward it to get_model_context_length() inside _check_compression_model_feasibility().

Broken call (before):

aux_context = get_model_context_length(
    aux_model,
    base_url=aux_base_url,
    api_key=aux_api_key,
    config_context_length=...,
    provider=...,
    # custom_providers=... ← MISSING
)

Fixed call (after):

_ccp_custom_providers = None
try:
    from hermes_cli.config import load_config, get_compatible_custom_providers
    _ccp_cfg = load_config()
    _ccp_custom_providers = get_compatible_custom_providers(_ccp_cfg)
except Exception:
    _ccp_custom_providers = None

aux_context = get_model_context_length(
    ...,
    custom_providers=_ccp_custom_providers,  # ← ADDED
)

Tests

  • Updated 3 existing tests that assert the exact call signature of get_model_context_length to include custom_providers=None (they now patch load_config + get_compatible_custom_providers to return None).
  • Added test_feasibility_check_passes_custom_providers — regression test confirming custom_providers is forwarded when set, and that no spurious warning is emitted when the custom provider reports 1M context.
$ python3 -m pytest tests/run_agent/test_compression_feasibility.py -v 2>&1 | tail -25
PASSED ...test_auto_corrects_threshold_when_aux_context_below_threshold
PASSED ...test_rejects_aux_below_minimum_context
PASSED ...test_no_warning_when_aux_context_sufficient
PASSED ...test_feasibility_check_passes_live_main_runtime
PASSED ...test_feasibility_check_passes_config_context_length
PASSED ...test_feasibility_check_ignores_invalid_context_length
PASSED ...test_init_feasibility_check_uses_aux_context_override_from_config
PASSED ...test_warns_when_no_auxiliary_provider
PASSED ...test_skips_check_when_compression_disabled
PASSED ...test_exception_does_not_crash
PASSED ...test_exact_threshold_boundary_no_warning
PASSED ...test_just_below_threshold_auto_corrects
PASSED ...test_warning_stored_for_gateway_replay
PASSED ...test_no_replay_when_no_warning
PASSED ...test_replay_without_callback_is_noop
PASSED ...test_run_conversation_clears_warning_after_replay
PASSED ...test_feasibility_check_passes_custom_providers    ← new
17 passed

Closes #20608

…compression feasibility check (NousResearch#20608)

_check_compression_model_feasibility() called get_model_context_length() without
the custom_providers argument. The main model path in the same file (lines 2039,
2436) correctly passes custom_providers, but the compression feasibility check
omitted it. As a result, step 0b (per-model context_length lookup in
custom_providers) was skipped and resolution fell through to the 256K default,
producing a spurious "Auto-lowered threshold" warning at startup for any user
with a custom provider model as their compression model.

Fix loads custom_providers via load_config/get_compatible_custom_providers
(mirroring the pattern at line 2429) and forwards it to get_model_context_length.

Updated three existing tests that asserted the exact call signature to include
custom_providers=. Added test_feasibility_check_passes_custom_providers as a
regression test confirming the kwarg is forwarded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists labels May 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of PR #19553 — same fix: pass custom_providers to get_model_context_length() inside _check_compression_model_feasibility(). Both address issue #20608 / #19539.

@teknium1

Copy link
Copy Markdown
Contributor

Automated hermes-sweeper review: this PR's fix is already present on current main.

Evidence:

  • agent/conversation_compression.py:145 now calls get_model_context_length(..., custom_providers=agent._custom_providers) in the compression feasibility path.
  • agent/agent_init.py:1399-1407 resolves compatible custom providers during agent initialization and stores them on agent._custom_providers for reuse by the feasibility check.
  • The mainline commit that added this behavior is 7becb19ea00c13bdff6f78b71aa3ddfb0bdb5378 (fix(auxiliary): forward custom_providers to compression model context-length detection).
  • git tag --contains 7becb19ea00c13bdff6f78b71aa3ddfb0bdb5378 shows the fix is included in v2026.5.16 and later releases.

Thanks for the useful duplicate fix and regression context around #20608.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_check_compression_model_feasibility doesn't pass custom_providers to get_model_context_length

3 participants