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.
This commit is contained in:
kshitijk4poor 2026-07-29 00:12:31 +05:00 committed by kshitij
parent 8c12fa7cf0
commit f1eef85877
2 changed files with 5 additions and 5 deletions

View file

@ -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,

View file

@ -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,