fix(agent): resolve context_length for plugin context engines
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 NousResearch/hermes-agent#9071 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Teknium
parent
204e9190c4
commit
c763ed5801
16
run_agent.py
16
run_agent.py
@@ -1331,6 +1331,22 @@ class AIAgent:
|
||||
|
||||
if _selected_engine is not None:
|
||||
self.context_compressor = _selected_engine
|
||||
# Resolve context_length for plugin engines — mirrors switch_model() path
|
||||
from agent.model_metadata import get_model_context_length
|
||||
_plugin_ctx_len = get_model_context_length(
|
||||
self.model,
|
||||
base_url=self.base_url,
|
||||
api_key=getattr(self, "api_key", ""),
|
||||
config_context_length=_config_context_length,
|
||||
provider=self.provider,
|
||||
)
|
||||
self.context_compressor.update_model(
|
||||
model=self.model,
|
||||
context_length=_plugin_ctx_len,
|
||||
base_url=self.base_url,
|
||||
api_key=getattr(self, "api_key", ""),
|
||||
provider=self.provider,
|
||||
)
|
||||
if not self.quiet_mode:
|
||||
logger.info("Using context engine: %s", _selected_engine.name)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user