fix(tui): show correct context length

This commit is contained in:
Rugved Somwanshi
2026-04-27 11:59:32 -04:00
committed by kshitij
parent fa2bee1215
commit 01ad0aacaf
3 changed files with 29 additions and 12 deletions

View File

@@ -2145,9 +2145,25 @@ class AIAgent:
if config_context_length is None:
config_context_length = getattr(self, "_config_context_length", None)
target_ctx = max(config_context_length or 0, MINIMUM_CONTEXT_LENGTH)
ensure_lmstudio_model_loaded(
loaded_ctx = ensure_lmstudio_model_loaded(
self.model, self.base_url, getattr(self, "api_key", ""), target_ctx,
)
if loaded_ctx:
self._lmstudio_loaded_context = loaded_ctx
# Push into the live compressor so the status bar reflects the
# real loaded ctx the moment the load resolves, instead of
# holding the previous model's value (or "ctx --") through the
# next render tick.
cc = getattr(self, "context_compressor", None)
if cc is not None:
cc.update_model(
model=self.model,
context_length=loaded_ctx,
base_url=self.base_url,
api_key=getattr(self, "api_key", ""),
provider=self.provider,
api_mode=self.api_mode,
)
except Exception as err:
logger.debug("LM Studio preload skipped: %s", err)