From f1eef8587784f4fa197ecee62215e2833cbc291f Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Wed, 29 Jul 2026 00:12:31 +0500 Subject: [PATCH] fix: replace RuntimeError with graceful degradation for unverified LM Studio loads Salvage of PR #52188. The original PR raised RuntimeError when LM Studio load was rejected or unverifiable, which would abort agent startup on transient network failures. Replace with logger.warning + fallback to configured context length, preserving the old graceful-degradation behavior. --- agent/agent_init.py | 4 ++-- agent/agent_runtime_helpers.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/agent_init.py b/agent/agent_init.py index b14ca117f300..92d89c8d6006 100644 --- a/agent/agent_init.py +++ b/agent/agent_init.py @@ -2280,9 +2280,9 @@ def init_agent( _config_context_length ) if agent._lmstudio_load_was_unverified(_lmstudio_runtime_context_length): - raise RuntimeError( + _ra().logger.warning( "LM Studio model activation was rejected or completed without a " - "verifiable active context length; agent startup aborted" + "verifiable active context length; falling back to configured context" ) _effective_context_length = agent._effective_lmstudio_context_length( _config_context_length, diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.py index c4619de005d6..6192556d2cbe 100644 --- a/agent/agent_runtime_helpers.py +++ b/agent/agent_runtime_helpers.py @@ -2341,10 +2341,10 @@ def switch_model(agent, new_model, new_provider, api_key='', base_url='', api_mo _destination_context_intent ) if agent._lmstudio_load_was_unverified(_runtime_context_length): - _restore_snapshot() - raise RuntimeError( + logger.warning( "LM Studio model activation was rejected or completed without a " - "verifiable active context length; model switch aborted" + "verifiable active context length during model switch; continuing " + "with configured context" ) _effective_context_length = agent._effective_lmstudio_context_length( _destination_context_intent,