The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compaction): preserve switch compatibility fixtures
Stephen Chin48a4201f40c4
diff --git a/agent/agent_runtime_helpers.py b/agent/agent_runtime_helpers.pyindex 6a2e0f2b8d7..c5eb9b34fc6 100644--- a/agent/agent_runtime_helpers.py+++ b/agent/agent_runtime_helpers.py@@ -3227,23 +3227,32 @@ def switch_model(except Exception:_destination_context_intent = Noneagent._config_context_length = _destination_context_intent- try:- _runtime_context_length = agent._ensure_lmstudio_runtime_loaded(- _destination_context_intent- )- except Exception:- _restore_snapshot()- raise- if agent._lmstudio_load_was_unverified(_runtime_context_length):+ if hasattr(agent, "_ensure_lmstudio_runtime_loaded"):+ try:+ _runtime_context_length = agent._ensure_lmstudio_runtime_loaded(+ _destination_context_intent+ )+ except Exception:+ _restore_snapshot()+ raise+ else:+ _runtime_context_length = None+ if (+ hasattr(agent, "_lmstudio_load_was_unverified")+ and agent._lmstudio_load_was_unverified(_runtime_context_length)+ ):logger.warning("LM Studio model activation was rejected or completed without a ""verifiable active context length during model switch; continuing ""with configured context")- _effective_context_length = agent._effective_lmstudio_context_length(- _destination_context_intent,- _runtime_context_length,- )+ if hasattr(agent, "_effective_lmstudio_context_length"):+ _effective_context_length = agent._effective_lmstudio_context_length(+ _destination_context_intent,+ _runtime_context_length,+ )+ else:+ _effective_context_length = _destination_context_intent# ── Re-evaluate prompt caching ──# Refresh the custom-provider snapshot from the config just loaded abovediff --git a/cli.py b/cli.pyindex f92fd5d4cbe..256e3b23e08 100644--- a/cli.py+++ b/cli.py@@ -10306,7 +10306,9 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):api_key=_reset_result.api_key,base_url=_reset_result.base_url,api_mode=_reset_result.api_mode,- capabilities=_reset_result.runtime_capabilities,+ capabilities=getattr(+ _reset_result, "runtime_capabilities", None+ ),)self.model = _reset_result.new_modelself.provider = _reset_result.target_provider@@ -11626,7 +11628,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):api_key=result.api_key,base_url=result.base_url,api_mode=result.api_mode,- capabilities=result.runtime_capabilities,+ capabilities=getattr(result, "runtime_capabilities", None),)except Exception as exc:# The agent rolled itself back to the old working model/client.@@ -12017,7 +12019,7 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):api_key=result.api_key,base_url=result.base_url,api_mode=result.api_mode,- capabilities=result.runtime_capabilities,+ capabilities=getattr(result, "runtime_capabilities", None),)except Exception as exc:# Agent rolled itself back; roll the CLI back too and abort so adiff --git a/gateway/slash_commands.py b/gateway/slash_commands.pyindex b8ce7cc6162..627ff37f0ea 100644--- a/gateway/slash_commands.py+++ b/gateway/slash_commands.py@@ -1950,7 +1950,9 @@ class GatewaySlashCommandsMixin:api_key=result.api_key,base_url=result.base_url,api_mode=result.api_mode,- capabilities=result.runtime_capabilities,+ capabilities=getattr(+ result, "runtime_capabilities", None+ ),)except Exception as exc:# The in-place swap rolled the agent back to the@@ -2265,7 +2267,7 @@ class GatewaySlashCommandsMixin:api_key=result.api_key,base_url=result.base_url,api_mode=result.api_mode,- capabilities=result.runtime_capabilities,+ capabilities=getattr(result, "runtime_capabilities", None),)except Exception as exc:# In-place swap rolled the agent back to the OLD workingdiff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex e4b70649ea9..8fc646a3771 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -6348,7 +6348,7 @@ def _apply_model_switch(api_key=result.api_key,base_url=result.base_url,api_mode=result.api_mode,- capabilities=result.runtime_capabilities,+ capabilities=getattr(result, "runtime_capabilities", None),)except Exception as exc:# The in-place swap rolled the agent back to the old working