fix(compression): resolve missing config attribute in feasibility check

Commit 4a9c3565 added a reference to `self.config` in
`_check_compression_model_feasibility()` to pass the user-configured
`auxiliary.compression.context_length` to `get_model_context_length()`.
However, `AIAgent` never stores the loaded config dict as an instance
attribute — the config is loaded into a local variable `_agent_cfg` in
`__init__()` and discarded after init.

This causes an `AttributeError: 'AIAgent' object has no attribute
'config'` on every session start when compression is enabled, caught by
the try/except and logged as a non-fatal DEBUG message.

Fix: store the loaded config as `self._config` in `__init__()` and
update the reference in the feasibility check to use `self._config`.
This commit is contained in:
kshitijk4poor 2026-04-18 16:00:45 +05:30 committed by kshitij
parent 6af04474a3
commit 045b28733e
2 changed files with 5 additions and 4 deletions

View file

@ -1271,6 +1271,7 @@ class AIAgent:
_agent_cfg = _load_agent_config()
except Exception:
_agent_cfg = {}
self._config = _agent_cfg # stored for later use (e.g. compression feasibility check)
# Persistent memory (MEMORY.md + USER.md) -- loaded from disk
self._memory_store = None
@ -2003,7 +2004,7 @@ class AIAgent:
# get_model_context_length() falls through to the 128K default,
# ignoring the explicit config value. Pass it as the highest-
# priority hint so the configured value is always respected.
_aux_cfg = (self.config or {}).get("auxiliary", {}).get("compression", {})
_aux_cfg = (self._config or {}).get("auxiliary", {}).get("compression", {})
_aux_context_config = _aux_cfg.get("context_length") if isinstance(_aux_cfg, dict) else None
if _aux_context_config is not None:
try: