Skip to content

fix(auth): kimi-coding pool base_url seeding + PKCE endpoint fallback#5669

Closed
teknium1 wants to merge 1 commit into
mainfrom
hermes/hermes-694ff34e
Closed

fix(auth): kimi-coding pool base_url seeding + PKCE endpoint fallback#5669
teknium1 wants to merge 1 commit into
mainfrom
hermes/hermes-694ff34e

Conversation

@teknium1

@teknium1 teknium1 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Two auth reliability fixes:

1. kimi-coding credential pool seeds correct base_url (fixes #5561)

_seed_from_env() in credential_pool.py now calls _resolve_kimi_base_url() for kimi-coding, matching the runtime resolver logic in auth.py. Previously, sk-kimi- prefixed keys were seeded with the default api.moonshot.ai/v1 URL (from pconfig.inference_base_url), causing HTTP 401 on the first request. The pool would mark the entry exhausted, and the second request would bypass the pool and succeed via the runtime resolver.

2. PKCE OAuth token exchange uses endpoint fallback

The Hermes-native PKCE login flow (run_hermes_oauth_login_pure) now tries platform.claude.com first with console.anthropic.com fallback for the token exchange, consistent with refresh_anthropic_oauth_pure() which was fixed in PR #3246. The old _OAUTH_TOKEN_URL constant hardcoded only console.anthropic.com.

Test plan

  • tests/test_credential_pool.py — 145 passed
  • tests/test_api_key_providers.py — all passed
  • tests/test_anthropic_adapter.py — 107 passed
  • E2E verified: sk-kimi- key routes to api.kimi.com/coding/v1, legacy key stays on moonshot, env override wins
  • E2E verified: _OAUTH_TOKEN_URLS list has platform.claude.com first, old constant removed

Related issues closed

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Supply Chain Risk Detected

This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.

⚠️ WARNING: Outbound network calls (POST/PUT)

Outbound POST/PUT requests in new code could be data exfiltration. Verify the destination URLs are legitimate.

Matches (first 10):

46:+                with urllib.request.urlopen(req, timeout=15) as resp:

Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.

1. credential_pool._seed_from_env() now calls _resolve_kimi_base_url()
   for kimi-coding provider, matching the runtime resolver logic.
   Previously, sk-kimi- prefixed keys were seeded with the default
   moonshot.ai URL, causing 401 on first request. Fixes #5561.

2. Hermes-native PKCE OAuth login (run_hermes_oauth_login_pure) now
   tries platform.claude.com first with console.anthropic.com fallback,
   consistent with refresh_anthropic_oauth_pure(). The old _OAUTH_TOKEN_URL
   constant hardcoded console.anthropic.com only.
@teknium1

Copy link
Copy Markdown
Contributor Author

Closing during PR triage — not pursuing this approach.

@teknium1 teknium1 closed this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kimi-coding credential pool seeds wrong base_url for sk-kimi- keys, causing 401 on first request

1 participant