fix(agent): resolve context_length for plugin context engines - #9238
Merged
Conversation
Plugin context engines loaded via load_context_engine() were never given context_length, causing the CLI status bar to show "ctx --" with an empty progress bar. Call update_model() immediately after loading the plugin engine, mirroring what switch_model() already does. Fixes #9071 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that plugin context engines receive update_model() with correct context_length during AIAgent init — regression test for the ctx -- bug.
This was referenced Apr 13, 2026
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
Salvage of PR #9218 by @stephenschoettler. Also addresses #9117 by @corazzione (duplicate fix, submitted first).
Plugin context engines (like LCM) were never initialized with
context_lengthduring agent startup. The built-inContextCompressorresolves it in its__init__, but the plugin path just assigned the engine directly — leavingcontext_lengthat the ABC default of 0. This caused the CLI status bar to permanently showctx --with an empty progress bar.The fix calls
update_model()on the plugin engine immediately after loading, mirroring whatswitch_model()already does.Changes
run_agent.py: Callget_model_context_length()+update_model()after assigning plugin engine (cherry-picked from fix(agent): resolve context_length for plugin context engines #9218)tests/run_agent/test_plugin_context_engine_init.py: Regression tests verifying plugin engines get correctcontext_lengthandupdate_model()argsTest plan
49 passed.
Fixes #9071
Closes #9218
Closes #9117