fix(offload): resolve local-LLM api key via OpenClaw auth-profiles#136
Closed
YOMXXX wants to merge 1 commit into
Closed
fix(offload): resolve local-LLM api key via OpenClaw auth-profiles#136YOMXXX wants to merge 1 commit into
YOMXXX wants to merge 1 commit into
Conversation
`context-offload`'s local-LLM backend only looked at `models.providers[provider].apiKey`, so users who manage credentials through OpenClaw auth-profiles saw the key get masked out of the runtime config and the offload pipeline shut down with `provider "<x>" not found or missing baseUrl/apiKey in models.providers`. Try `api.resolveProviderAuth(providerKey)` first; it covers api-key profiles, env-var fallbacks, and the OAuth path the host already uses for agent → model calls. If the host doesn't expose it (older OpenClaw) or auth-profiles has no key for that provider, fall back to the existing `models.providers[*].apiKey` read so existing setups keep working unchanged. Side-touches: - baseUrl is still sourced exclusively from `models.providers` because auth-profiles intentionally does not carry endpoint info. - The "missing config" error now spells out which field is missing and where to set it (auth-profile vs `models.providers[*].apiKey`), shortening the next round of triage. - Log the apiKey source at debug level so users running with `--debug` can confirm whether auth-profiles actually fired. Fixes TencentCloud#90 Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
Collaborator
|
Thank you for your interest in our project! We noticed you've opened several PRs against our Good First Issues at once. These issues are specifically intended for first-time contributors to get familiar with the project in a low-pressure way. To keep this spirit, we ask that contributors work on 1–2 issues at a time. We're keeping your PRs for #69 and #68 and will review them soon. The other PRs will be closed for now so others can pick them up. After your current PRs are merged, feel free to claim more! Thanks for understanding and hope to see more of your contributions. 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #90 — when
offload.modelis set inprovider/modelform, the local-LLM backend only readsmodels.providers[providerKey].apiKeyfrom the runtime config. OpenClaw's auth-profiles deliberately doesn't propagate the key into that map (the host injects it into the model call out-of-band instead), so users on auth-profiles see:…and the L1 / L1.5 / L2 layers stay disabled even though the model works fine for agent calls.
Change
src/offload/index.ts— resolve the key in two ordered steps:api.resolveProviderAuth(providerKey)if exposed by the host (verified against the OpenClaw 2026.5.12 SDK — covers api-key profiles, env-var fallbacks, and the OAuth mode the host already uses for agent → model calls). Feature-detected viatypeof === \"function\"so older hosts still load.models.providers[providerKey].apiKeyif step 1 returns nothing — keeps existing inline-config setups working unchanged.baseUrlis still read exclusively frommodels.providers.resolveProviderAuthintentionally doesn't carry endpoint info (auth-profiles is for credentials, not routing).Side-touches kept tight:
auth-profile for \"<provider>\"vsmodels.providers[*].apiKey/.baseUrl), so triage doesn't need a second round-trip.apiKey source=auth-profile:api_key) so--debugusers can confirm which path fired.What's intentionally NOT in this PR
LLMRunnerand don't hit this code path, so they were never broken in the same way. Filing as a follow-up if it turns out other modules duplicate the inline-only pattern.Test plan
npm run build(tsdown) clean — verified locally.offload.model: \"deepseek/deepseek-v4-flash\"and the deepseek key registered only as an auth-profile (nomodels.providers.deepseek.apiKey): offload pipeline starts, debug log showsapiKey source=auth-profile:*, L1/L1.5/L2 fire normally.models.providers.deepseek.apiKey(no auth-profile): still works, debug log showsapiKey source=models.providers.models.providers.deepseek.baseUrlset: error message now readsprovider \"deepseek\" is missing baseUrl (set models.providers[\"deepseek\"].baseUrl).resolveProviderAuth: plugin still loads, falls through to the inline-config path, no exception.