diff --git a/run_agent.py b/run_agent.py index 8e1fbfed19..685b8372f8 100644 --- a/run_agent.py +++ b/run_agent.py @@ -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: diff --git a/tests/run_agent/test_compression_feasibility.py b/tests/run_agent/test_compression_feasibility.py index 0756fcda6a..f0db50de4d 100644 --- a/tests/run_agent/test_compression_feasibility.py +++ b/tests/run_agent/test_compression_feasibility.py @@ -38,7 +38,7 @@ def _make_agent( agent.status_callback = None agent.tool_progress_callback = None agent._compression_warning = None - agent.config = None + agent._config = None compressor = MagicMock(spec=ContextCompressor) compressor.context_length = main_context @@ -138,7 +138,7 @@ def test_feasibility_check_passes_config_context_length(mock_get_client, mock_ct get_model_context_length so custom endpoints that lack /models still report the correct context window (fixes #8499).""" agent = _make_agent(main_context=200_000, threshold_percent=0.85) - agent.config = { + agent._config = { "auxiliary": { "compression": { "context_length": 1_000_000, @@ -166,7 +166,7 @@ def test_feasibility_check_passes_config_context_length(mock_get_client, mock_ct def test_feasibility_check_ignores_invalid_context_length(mock_get_client, mock_ctx_len): """Non-integer context_length in config is silently ignored.""" agent = _make_agent(main_context=200_000, threshold_percent=0.50) - agent.config = { + agent._config = { "auxiliary": { "compression": { "context_length": "not-a-number",