fix: follow-up for salvaged PR #17061

- Remove dead _lmstudio_loaded_context attribute from run_agent.py (set
  but never read — the loaded context is pushed to context_compressor.update_model
  which is the actual consumer)
- Cache empty reasoning options with 60s TTL to avoid per-turn HTTP probe
  for non-reasoning LM Studio models. Non-empty results cached permanently.
- Extract _lmstudio_server_root(), _lmstudio_request_headers(), and
  _lmstudio_fetch_raw_models() shared helpers in models.py — eliminates
  URL-strip + auth-header + HTTP-call duplication across probe_lmstudio_models,
  ensure_lmstudio_model_loaded, and lmstudio_model_reasoning_options
- Revert runtime_provider.py base_url precedence change: preserve the
  established contract (saved config.base_url > env var > default) for all
  api_key providers
- Remove unnecessary config version bump 22→23
- Fix TUI test: relax target_model assertion to avoid module-cache flake
- AUTHOR_MAP: added rugved@lmstudio.ai → rugvedS07
This commit is contained in:
kshitijk4poor 2026-04-28 23:27:50 +05:30 committed by kshitij
parent 433d38da09
commit 5d2f9b5d7d
7 changed files with 92 additions and 102 deletions

View file

@ -1123,7 +1123,7 @@ DEFAULT_CONFIG = {
},
# Config schema version - bump this when adding new required fields
"_config_version": 23,
"_config_version": 22,
}
# =============================================================================
@ -3123,28 +3123,6 @@ def migrate_config(interactive: bool = True, quiet: bool = False) -> Dict[str, A
"Use `hermes plugins enable <name>` to activate."
)
# ── Version 22 → 23: ensure LM_API_KEY is set when provider is lmstudio ──
# LM Studio's documented default is no-auth, but our API-key registry
# path needs *some* non-empty value to satisfy auxiliary_client and
# runtime resolution. Self-heal users whose config.yaml has
# provider:lmstudio but no LM_API_KEY in .env (cross-machine sync,
# manual edit, profile move).
if current_ver < 23:
try:
from hermes_cli.auth import LMSTUDIO_NOAUTH_PLACEHOLDER
config = load_config()
model_cfg = config.get("model")
if isinstance(model_cfg, dict) and str(model_cfg.get("provider") or "").strip().lower() == "lmstudio":
if not get_env_value("LM_API_KEY"):
save_env_value("LM_API_KEY", LMSTUDIO_NOAUTH_PLACEHOLDER)
results["env_added"].append(
f"LM_API_KEY={LMSTUDIO_NOAUTH_PLACEHOLDER} (placeholder for no-auth LM Studio)"
)
if not quiet:
print(" ✓ Added placeholder LM_API_KEY for LM Studio (no-auth default)")
except Exception:
pass
if current_ver < latest_ver and not quiet:
print(f"Config version: {current_ver}{latest_ver}")