TencentCloud/TencentDB-Agent-Memory · error · LlmResolveError

llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL

Error message

llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL

What it means

validateLlmProviderConfig is a startup-time validator invoked by start(); it re-checks proxy requirements before the gateway accepts traffic. Like the runtime resolver, it requires llm.baseUrl when provider=proxy, throwing LlmResolveError at boot if absent.

Source

Thrown at MemoryCore/src/gateway/llm-resolver.ts:112

    ...llm,
    baseUrl: proxyBaseUrl,
    apiKey: effectiveApiKey,
  };
}

/**
 * 只做校验、不返回配置 —— 用于启动期"fail-fast"检查。
 * standalone 模式下 instanceId 一般是 "default",可以直接校验;
 * service 模式下 instanceId 每次请求才知道,启动期只校验 systemUser 是否合法。
 */
export function validateLlmProviderConfig(
  llm: StandaloneLLMConfig,
  metadata: GatewayMetadataConfig,
): void {
  if (llm.provider !== "proxy") return;

  if (!llm.baseUrl) {
    throw new LlmResolveError(
      "llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL",
    );
  }

  const useSystemUserKey = llm.proxy?.useMemorySystemUserKey ?? true;
  if (useSystemUserKey) {
    const memoryUser = resolveMemorySystemUserConfig(metadata);
    if (!memoryUser) {
      throw new LlmResolveError(
        "llm.provider=proxy 且 useMemorySystemUserKey=true 需要 " +
        "metadata.systemUser.memory 完整配置(userId + userKey)",
      );
    }
    if (!isValidMemorySystemUserKey(memoryUser.userKey)) {
      throw new LlmResolveError(
        "metadata.systemUser.memory.userKey 必须匹配 sk-mem-[A-Za-z0-9_-]{32}",
      );
    }

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Add llm.baseUrl pointing at the context_proxy root (e.g. http://127.0.0.1:8096) before starting.
  2. Re-run start() after fixing; the same validation will then proceed to key/instance checks.
  3. If proxy mode is unintentional, set llm.provider to the direct provider and supply its own baseUrl.

Example fix

// before
llm:
  provider: proxy
// after
llm:
  provider: proxy
  baseUrl: http://127.0.0.1:8096
Defensive patterns

Strategy: validation

Validate before calling

function preflightProxyConfig(llm) {
  if (llm.provider === 'proxy' && !llm.baseUrl) {
    throw new Error('Startup preflight: llm.provider=proxy requires llm.baseUrl (context_proxy root URL)');
  }
}

Type guard

function proxyConfigComplete(llm: { provider: string; baseUrl?: string }): boolean {
  return llm.provider !== 'proxy' || Boolean(llm.baseUrl);
}

Try / catch

try {
  await gateway.start();
} catch (err) {
  if (err instanceof LlmResolveError && err.message.includes('context_proxy')) {
    console.error('Add llm.baseUrl (context_proxy root, e.g. http://127.0.0.1:8096) before starting');
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: Starting the gateway (start()) with yaml llm.provider=proxy and no llm.baseUrl — the process fails fast before serving requests.

Common situations: First-time proxy setup with an incomplete yaml; config templating that dropped the baseUrl field; environment-specific overlays (staging/prod) that only override provider without carrying baseUrl over.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/b18db5092f0fba96. Report an issue: GitHub.