Skip to content

fix(agent): ignore stale local base_url for direct providers - #30034

Open
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/direct-provider-stale-local-base-url
Open

fix(agent): ignore stale local base_url for direct providers#30034
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/direct-provider-stale-local-base-url

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

Summary

  • Ignore stale loopback model.base_url values when a direct API-key provider from PROVIDER_REGISTRY is selected.
  • Clear the stale local override before client construction so resolve_provider_client() uses the provider's canonical endpoint.
  • Add a regression test for migrating to deepseek with an old http://localhost:8081/v1 base URL.

Fixes #30033

Test plan

  • python -m pytest tests/run_agent/test_run_agent.py::test_direct_provider_ignores_stale_local_base_url -q -o addopts=
  • python -m pytest tests/run_agent/test_run_agent.py -q -o addopts=
  • python -m py_compile agent/agent_init.py tests/run_agent/test_run_agent.py

Notes

This is intentionally narrow: it only handles loopback URLs (localhost, 127.0.0.1, ::1) for direct registry providers, and leaves custom/aggregator routing behavior unchanged.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/config Config system, migrations, profiles labels May 21, 2026
@Tranquil-Flow
Tranquil-Flow force-pushed the fix/direct-provider-stale-local-base-url branch from 8522096 to a19702e Compare May 25, 2026 08:23
@talwayh1

Copy link
Copy Markdown

CI Fix: test_auth_remove_copilot_suppresses_all_variants

Root Cause: load_pool() prunes the gh_cli borrowed credential entry because resolve_copilot_token() returns empty in CI/test environment (pitfall #13 — borrowed-source entries silently removed by _prune_stale_seeded_entries).

Fix: Monkeypatch copilot token resolution before auth_remove_command call so the gh_cli entry survives pruning.

monkeypatch.setattr(
    "hermes_cli.copilot_auth.resolve_copilot_token",
    lambda: ("ghp_fake", "gh auth token"),
)
monkeypatch.setattr(
    "hermes_cli.copilot_auth.get_copilot_api_token",
    lambda token: token,
)

Fix available at talwayh1/hermes-agent:ci-fix/test-auth-remove-copilot-monkeypatch:

git fetch https://github.com/talwayh1/hermes-agent.git ci-fix/test-auth-remove-copilot-monkeypatch
git cherry-pick 9e4801376

@Tranquil-Flow
Tranquil-Flow force-pushed the fix/direct-provider-stale-local-base-url branch from a19702e to 183e54d Compare May 25, 2026 11:03

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the migration scenario. The current-main issue is still present, but this implementation needs to move to the runtime resolver.

Problems

  • agent/agent_init.py:981-987 re-invokes resolve_provider_client() after clearing only local variables. The resolver then rereads matching model.base_url and prefers it at hermes_cli/runtime_provider.py:2028-2032, so the stale configured loopback URL returns.
  • The proposed registry-and-loopback predicate also includes LM Studio: hermes_cli/auth.py:212-219 declares its canonical 127.0.0.1 endpoint, and tests/hermes_cli/test_runtime_provider_resolution.py:415-453 requires saved LM Studio URLs to be preserved.
  • The new test mocks resolve_provider_client, so it does not execute the config-resolution behavior above.

Suggested changes

  • Put the stale-route guard at hermes_cli/runtime_provider.py:2028-2032, with an explicit local-provider exclusion/capability, and add a resolver-level DeepSeek regression that uses the persisted config.

Automated hermes-sweeper review.

Comment thread agent/agent_init.py
agent.base_url,
agent.provider,
)
agent.base_url = ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the init-local value here does not prevent the later resolve_provider_client() call from rereading the same matching model.base_url (hermes_cli/runtime_provider.py:2028-2032). Please enforce the stale-route rule in the runtime resolver instead, and exclude local-serving registry providers such as LM Studio.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 13, 2026
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/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users 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.

Direct API-key providers can inherit stale local base_url after provider migration

4 participants