Skip to content

fix: prevent stale base_url after provider switch - #47533

Open
timrichardson wants to merge 4 commits into
NousResearch:mainfrom
timrichardson:fix/47521-ollama-cloud-stale-base-url
Open

fix: prevent stale base_url after provider switch#47533
timrichardson wants to merge 4 commits into
NousResearch:mainfrom
timrichardson:fix/47521-ollama-cloud-stale-base-url

Conversation

@timrichardson

@timrichardson timrichardson commented Jun 17, 2026

Copy link
Copy Markdown

Fixes #47521

Summary

  • Prevents a stale model.base_url from a previous built-in provider from hijacking a newly selected built-in provider runtime.
  • Covers the reported ollama-cloud + deepseek-v4-pro case where model.base_url remained https://chatgpt.com/backend-api/codex after switching away from Codex.
  • Persists the resolved endpoint (or clears it) when CLI global model switches save model.default / model.provider, so stale endpoints are not left behind for the next process.
  • Retains current main's existing gateway behavior, which already clears non-custom endpoints.

Reproduction on current main

Without the fix, runtime resolution accepts the stale Codex URL solely because the persisted provider now matches Ollama Cloud. The regression exercises both the normal API-key path and a real credential-pool selection path.

Implementation notes

  • Adds _provider_supports_config_base_url_override() to reject config base URLs that point at another known provider's stock endpoint.
  • Keeps existing provider-specific proxy behavior intact, including MiniMax CN and TokenHub overrides.
  • Applies the guard in both the credential-pool layering path and the normal API-key provider runtime path.
  • Updates both CLI global-switch persistence paths on current main.
  • Drops the stale gateway delta identified in review.

Tests

scripts/run_tests.sh \
  tests/hermes_cli/test_runtime_provider_resolution.py \
  tests/hermes_cli/test_model_switch_persistence.py \
  tests/hermes_cli/test_apply_model_switch_result_context.py \
  tests/gateway/test_model_switch_persistence.py -q

# 169 passed

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels Jun 17, 2026
@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the stale-endpoint path. The runtime premise remains valid on current main: hermes_cli/runtime_provider.py:2028-2032 still accepts model.base_url solely because model.provider matches, and the credential-pool counterpart at hermes_cli/runtime_provider.py:480-491 does the same.

Problems

  • The gateway hunk is stale. Current gateway/slash_commands.py:1671-1674 already clears non-custom base_url through clear_model_endpoint_credentials(..., clear_base_url=True), added in f6deabca0d8010d485d4d3a8744d0ceb797eacb9.
  • The supplied Ollama regression uses a pool with has_credentials() == False, so it does not cover the changed credential-pool branch.

Suggested changes

  • Port the runtime guard to both current resolution branches and retain the existing gateway clear behavior.
  • Add a pooled Ollama Cloud stale-Codex URL regression plus a CLI global-switch persistence test.

Automated hermes-sweeper review.

…d-stale-base-url

# Conflicts:
#	cli.py
#	gateway/slash_commands.py
#	scripts/release.py
@timrichardson

Copy link
Copy Markdown
Author

Updated against current main per the sweeper review: retained the existing gateway clear behavior, ported the runtime guard to both resolution branches, added a credential-pool Ollama Cloud regression, and added real CLI config-persistence coverage. Targeted suite: 169 passed via scripts/run_tests.sh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression: Ollama Cloud model switch keeps stale Codex base_url and sends deepseek-v4-pro to chatgpt.com endpoint

3 participants