Skip to content

auxiliary compression model does not read context_length from providers config #13807

@gwaves

Description

@gwaves

Bug Description

The auxiliary compression model fails to read context_length from the providers / custom_providers config section, causing it to fallback to endpoint-reported values (e.g. 128K) instead of the user-configured value.

Repro Steps

  1. Configure a custom provider with per-model context_length in config.yaml:
providers:
  local-kimi:
    base_url: http://127.0.0.1:8080/v1
    model: kimi-code/kimi-code
    models:
      kimi-code/kimi-code:
        context_length: 262141

auxiliary:
  compression:
    provider: custom
    model: kimi-code/kimi-code
    base_url: http://127.0.0.1:8080/v1
  1. Start a session.
  2. Observe the warning:
⚠ Compression model (kimi-code/kimi-code) context is 128,000 tokens, but the main model's compression threshold was 209,712 tokens. Auto-lowered this session's threshold to 128,000 tokens so compression can run.

Expected Behavior

The compression model should resolve context_length: 262141 from providers.local-kimi.models.kimi-code/kimi-code, matching how the main model already does.

Actual Behavior

get_model_context_length() for the compression model only checks:

  1. auxiliary.compression.context_length direct override
  2. Endpoint auto-detection (which returns 128K for this local endpoint)

It never looks up providers / custom_providers per-model config, unlike the main model which does (see run_agent.py:1587-1623).

Root Cause

In run_agent.py, _aux_compression_context_length_config is only populated from auxiliary.compression.context_length. The same providers lookup that exists for the main model is missing for the auxiliary model.

Suggested Fix

Add the same providers / custom_providers per-model context_length lookup for the auxiliary compression model before falling back to endpoint detection.


Labels: bug, context-compression

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions