fix(cli): log instead of swallow preflight-warning errors; consistent TUI warning field

Follow-up to the salvaged preflight-compression warning:
- Replace silent `except Exception: pass` at all 5 guard call sites
  (cli.py x2, gateway/slash_commands.py x2, tui_gateway/server.py) with
  `logger.debug(...)` so signature drift in the guard helper isn't hidden.
- tui_gateway/server.py: set the confirm dict's `warning` field to the
  merged message (was bare expensive-model text) so it matches
  `confirm_message` for any future consumer reading `warning`.
- Add trailing newlines to the two new files.
This commit is contained in:
kshitijk4poor
2026-06-21 16:31:56 +05:30
parent 04730f32e7
commit 1ca29723f0
5 changed files with 13 additions and 13 deletions

8
cli.py
View File

@@ -6946,8 +6946,8 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin):
messages=list(self.conversation_history or []),
config_context_length=getattr(self.agent, "_config_context_length", None),
)
except Exception:
pass
except Exception as exc:
logger.debug("preflight-compression switch warning failed: %s", exc)
old_model = self.model
self.model = result.new_model
@@ -7225,8 +7225,8 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin):
messages=list(self.conversation_history or []),
config_context_length=getattr(self.agent, "_config_context_length", None),
)
except Exception:
pass
except Exception as exc:
logger.debug("preflight-compression switch warning failed: %s", exc)
if not self._confirm_expensive_model_switch(result):
_cprint(" Model switch cancelled.")

View File

@@ -1173,8 +1173,8 @@ class GatewaySlashCommandsMixin:
custom_providers=custom_provs,
load_gateway_config=_load_gateway_config,
)
except Exception:
pass
except Exception as exc:
logger.debug("preflight-compression switch warning failed: %s", exc)
# Update cached agent in-place
cached_entry = None
@@ -1376,8 +1376,8 @@ class GatewaySlashCommandsMixin:
custom_providers=custom_provs,
load_gateway_config=_load_gateway_config,
)
except Exception:
pass
except Exception as exc:
logger.debug("preflight-compression switch warning failed: %s", exc)
async def _finish_switch() -> str:
"""Apply the resolved switch (agent, session, config) and build the reply."""

View File

@@ -166,4 +166,4 @@ def enrich_model_switch_warnings_for_gateway(
messages=messages,
custom_providers=custom_providers,
config_context_length=cfg_ctx,
)
)

View File

@@ -102,4 +102,4 @@ def test_merge_appends_to_existing_warning(monkeypatch):
result.warning_message = "expensive"
merge_preflight_compression_warning(result, agent=agent)
assert "expensive" in result.warning_message
assert "preflight compression" in result.warning_message
assert "preflight compression" in result.warning_message

View File

@@ -2264,8 +2264,8 @@ def _apply_model_switch(
custom_providers=custom_provs,
config_context_length=_cfg_ctx,
)
except Exception:
pass
except Exception as exc:
logger.debug("preflight-compression switch warning failed: %s", exc)
if not confirm_expensive_model:
try:
@@ -2286,7 +2286,7 @@ def _apply_model_switch(
confirm_msg = f"{confirm_msg}\n\n{result.warning_message}"
return {
"value": result.new_model,
"warning": warning.message,
"warning": confirm_msg,
"confirm_required": True,
"confirm_message": confirm_msg,
}