Skip to content

context-offload local-llm 无法使用 OpenClaw auth-profiles 密钥管理机制 #90

@arlen8411

Description

@arlen8411

问题描述

当配置 offload.model = "provider/model" 格式时,context-offload 的 local-llm 模块从 api.config?.models?.providers?.[providerKey]?.apiKey 获取密钥。

但 OpenClaw 的 auth-profiles 机制不会将 apiKey 注入到运行时的 models.providers 中,导致报错:

[context-offload] Local LLM mode failed: provider "deepseek" not found or missing baseUrl/apiKey in models.providers. L1/L1.5/L2 disabled.

环境

  • OpenClaw: 2026.5.22
  • memory-tencentdb: 0.3.5
  • 配置: offload.model = "deepseek/deepseek-v4-flash"

根因分析

OpenClaw 有两种密钥管理方式:

  1. auth-profiles.json — 用于 agent → model 调用链,密钥不注入到 models.providers 运行时配置
  2. models.providers[provider].apiKey — 直接配置,插件可以读取

tencentdb 的 local-llm 代码(dist/index.mjs 第 5068 行附近):

const providerCfg = (api.config?.models)?.providers?.[providerKey];
const baseUrl = providerCfg?.baseUrl ?? providerCfg?.baseURL;
const apiKey = providerCfg?.apiKey;
if (baseUrl && apiKey) backendClient = new LocalLlmClient({...});

这段代码无法访问 auth-profiles 的密钥。

建议方案

  1. local-llm 应支持 OpenClaw 的 auth-profiles 机制(通过 api.getAuthProviderCredential 或类似 API)
  2. 或者文档明确说明:使用 offload 功能需要在 models.providers 配置 apiKey

当前 workaround

openclaw.jsonmodels.providers[provider] 中手动配置 apiKey:

{
  "models": {
    "providers": {
      "deepseek": {
        "baseUrl": "https://api.deepseek.com",
        "apiKey": "sk-xxx",
        ...
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions