HERMES-GIELIE/api
nesquena-hermes 2ca220eec0 fix(config): PR #1970 lmstudio branch must honor cfg.model.base_url fallback
PR #1970 added a dedicated `elif pid == "lmstudio":` branch in
`get_available_models()` that fetches the live /v1/models list when the
hermes_cli helper doesn't have ids cached. The fallback path inside that
branch only looked at `cfg["providers"]["lmstudio"]["base_url"]`, missing
the historical config shape where the URL lives under `cfg["model"]`:

  model:
    provider: lmstudio
    base_url: http://192.168.1.22:1234/v1   ← here, not under providers.lmstudio
  providers:
    lmstudio:
      api_key: local-key

3 pre-existing tests in tests/test_issue1527_lmstudio_base_url_classification
broke on stage-337 because of this — they passed on master, failed after
the PR #1970 merge.

The simpler fix is to enhance the already-introduced `_get_provider_base_url()`
helper so it falls back to `cfg["model"]["base_url"]` when
`cfg["model"]["provider"] == provider_id`, then use the helper inside the
lmstudio branch instead of a direct lookup. This keeps the previous
behaviour (where the generic configured-provider branch handled lmstudio
via the model block) while preserving PR #1970's live-discovery additions.

Belt-and-suspenders: `_get_provider_base_url()` explicitly does NOT inherit
model.base_url for providers other than the active one — if a user's config
says `model.provider: anthropic` and they have `providers.openai` configured
without a base_url, openai must still resolve to None (use SDK default),
not to the anthropic proxy URL.

6 new regression tests in tests/test_pr1970_lmstudio_base_url_fallback.py
lock the two-location lookup, the precedence rule (explicit providers entry
wins over model fallback), trailing-slash stripping, and the negative case
(model.base_url MUST NOT leak to non-active providers).

All 51 tests in the existing model-resolver + custom-provider banks still
pass.

Caught by maintainer review on stage-337 (full pytest with the new network
isolation in place surfaced the regression that the fork-CI mock-server path
would have hidden).
2026-05-11 05:59:59 +00:00
..
__init__.py
agent_health.py Mute stale stopped gateway heartbeat 2026-05-09 14:53:42 +08:00
agent_sessions.py feat: add read-only session lineage report 2026-05-10 23:28:14 +08:00
auth.py fix(stage-326): preserve SESSION_TTL constant + reconcile #1957 tests 2026-05-09 18:33:28 +00:00
background.py
clarify.py
commands.py
config.py fix(config): PR #1970 lmstudio branch must honor cfg.model.base_url fallback 2026-05-11 05:59:59 +00:00
dashboard_probe.py
extensions.py
gateway_watcher.py
goals.py fix(i18n): localize /goal runtime status strings 2026-05-10 15:21:24 +08:00
helpers.py fix: add cdn.jsdelivr.net to CSP connect-src to allow xterm source map fetches 2026-05-07 20:42:55 +00:00
kanban_bridge.py stage-315 absorb: document handle_kanban_* three-valued return contract 2026-05-07 18:52:01 +00:00
metering.py
models.py Add worktree-backed session creation 2026-05-11 12:12:40 +08:00
oauth.py
onboarding.py Fix Xiaomi API key env detection 2026-05-11 07:33:52 +08:00
profiles.py refactor(profiles): relocate _profiles_match to api/profiles.py (#1895 review) 2026-05-08 17:12:01 +00:00
providers.py Merge PR #1970: feat: LM Studio provider with live model discovery 2026-05-11 05:12:04 +00:00
request_diagnostics.py fix: add request wedge diagnostics 2026-05-08 15:37:08 +00:00
rollback.py
routes.py Merge PR #2053: feat: worktree-backed session creation 2026-05-11 05:12:00 +00:00
session_ops.py
session_recovery.py fix(recovery): close concurrency hazards in state.db sidecar reconciliation 2026-05-11 02:44:38 +00:00
startup.py
state_sync.py
streaming.py Fix duplicate assistant transcript merge 2026-05-11 13:09:16 +08:00
system_health.py
terminal.py
updates.py
upload.py
workspace.py
worktrees.py Add worktree-backed session creation 2026-05-11 12:12:40 +08:00