Skip to content

fix(run_agent): use aux provider for compression context length lookup (salvage #16918)#20218

Merged
teknium1 merged 2 commits into
mainfrom
salvage/pr-16918
May 5, 2026
Merged

fix(run_agent): use aux provider for compression context length lookup (salvage #16918)#20218
teknium1 merged 2 commits into
mainfrom
salvage/pr-16918

Conversation

@teknium1

@teknium1 teknium1 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Salvages @rxdxxxx's PR #16918 onto current main. Closes #12977.

What it does

get_model_context_length() for the auxiliary compression model was called with self.provider (the MAIN model's provider). When the main model is on Bedrock, the Bedrock static-table hard-intercept fired for non-Bedrock auxiliary models and returned BEDROCK_DEFAULT_CONTEXT_LENGTH=128K instead of the aux model's real context window — triggering a false compression warning every session.

Changes

  • run_agent.py — pass _aux_cfg_provider (resolved a few lines above) when explicitly set, fall back to self.provider only when _aux_cfg_provider is unset or auto.

Validation

tests/run_agent/ -k 'compression or aux or context_length' — 69 passed locally.

Closes #16918 via salvage.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/bedrock AWS Bedrock (boto3, IAM) labels May 5, 2026
rxdxxxx and others added 2 commits May 5, 2026 06:11
Each auxiliary model must be resolved with its own provider so that
provider-specific paths (e.g. Bedrock static table, OpenRouter API)
are invoked for the correct client, not inherited from the main model.

When the main model is Bedrock, passing self.provider unconditionally
to get_model_context_length() for the aux model caused the Bedrock
static table hard-intercept (step 1b) to fire for non-Bedrock models,
returning BEDROCK_DEFAULT_CONTEXT_LENGTH=128K instead of the model's
real context window — triggering a false compression warning every session.

Fix: pass _aux_cfg_provider when explicitly set, falling back to
self.provider only when the aux provider is unset or "auto".

Closes #12977
Related: #13807, #17460
@teknium1 teknium1 force-pushed the salvage/pr-16918 branch from 994ef84 to 112e92e Compare May 5, 2026 13:12
@teknium1 teknium1 merged commit 8ebb81f into main May 5, 2026
9 of 10 checks passed
@teknium1 teknium1 deleted the salvage/pr-16918 branch May 5, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/bedrock AWS Bedrock (boto3, IAM) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: custom_providers.models.context_length not propagated to auxiliary compression feasibility check

3 participants