TencentCloud/TencentDB-Agent-Memory · error · LlmResolveError
llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL (如
Error message
llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL (如 http://127.0.0.1:8096)
What it means
When llm.provider is set to "proxy", resolveEffectiveLlmConfig requires llm.baseUrl to point at the context_proxy root URL, because all LLM calls are rewritten to <baseUrl>/proxy/<iid>/v1. If baseUrl is missing/empty, the gateway cannot build the proxy endpoint and throws LlmResolveError.
Source
Thrown at MemoryCore/src/gateway/llm-resolver.ts:55
* @param memorySystemUser 已解析的 memory 系统用户配置(可选,仅 provider=proxy 且
* useMemorySystemUserKey=true 时使用)
*
* @throws {LlmResolveError} provider=proxy 但缺失必要配置时
*/
export function resolveEffectiveLlmConfig(
llm: StandaloneLLMConfig,
instanceId: string | undefined,
memorySystemUser: MemorySystemUserConfig | undefined,
): StandaloneLLMConfig {
const provider = llm.provider ?? "openai";
if (provider !== "proxy") {
// 默认路径:原样返回,行为完全等价改造前
return llm;
}
// provider=proxy 的校验
if (!llm.baseUrl) {
throw new LlmResolveError(
"llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL (如 http://127.0.0.1:8096)",
);
}
if (!instanceId || !instanceId.trim()) {
throw new LlmResolveError(
"llm.provider=proxy 需要 instanceId,但 core 当前 instanceId 为空 —— " +
"service 模式下确保请求带 x-tdai-service-id,standalone 模式下确保 yaml 有 instanceId",
);
}
const useSystemUserKey = llm.proxy?.useMemorySystemUserKey ?? true;
let effectiveApiKey = llm.apiKey;
if (useSystemUserKey) {
if (!memorySystemUser) {
throw new LlmResolveError(
"llm.provider=proxy 且 llm.proxy.useMemorySystemUserKey=true 需要 " +
"metadata.systemUser.memory 完整配置(userId + userKey),当前缺失",
);View on GitHub (pinned to 3efcd317b8)
Solutions
- Set llm.baseUrl to the context_proxy root, e.g. baseUrl: http://127.0.0.1:8096 (no trailing path like /v1 — the resolver appends /proxy/<iid>/v1).
- Ensure the context_proxy service is deployed and its address is reachable from MemoryCore.
- If you don't intend to use the proxy, set llm.provider back to the direct provider (e.g. openai) with its own baseUrl/apiKey.
Example fix
// before llm: provider: proxy apiKey: sk-... // after llm: provider: proxy baseUrl: http://127.0.0.1:8096 apiKey: sk-...
Defensive patterns
Strategy: validation
Validate before calling
if (llmConfig.provider === 'proxy' && (!llmConfig.baseUrl || !llmConfig.baseUrl.trim())) {
throw new Error('llm.provider=proxy requires llm.baseUrl, e.g. http://127.0.0.1:8096');
} Type guard
function hasProxyBaseUrl(llm: { provider: string; baseUrl?: string }): llm is typeof llm & { baseUrl: string } {
return llm.provider !== 'proxy' || (typeof llm.baseUrl === 'string' && llm.baseUrl.length > 0);
} Try / catch
try {
gateway.start();
} catch (err) {
if (err instanceof LlmResolveError && err.message.includes('llm.baseUrl')) {
console.error('Set llm.baseUrl to the context_proxy root URL');
}
throw err;
} Prevention
- Keep a config template with baseUrl present whenever provider: proxy
- Remember baseUrl is the proxy ROOT (no /v1 suffix); the resolver appends /proxy/<iid>/v1
- Validate the full llm block before deploying config overlays
- Smoke-test gateway startup in staging after provider changes
When it happens
Trigger: Configuring llm: { provider: proxy } in the gateway yaml (or runtime LLM config) without llm.baseUrl, or with baseUrl: "" after a migration from direct provider mode.
Common situations: Switching provider from "openai"/direct to "proxy" but deleting the old baseUrl; copying a config snippet that omitted baseUrl; forgetting that provider=proxy ignores provider-specific hosts and requires the context_proxy service address (e.g. http://127.0.0.1:8096).
Related errors
- llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL
- llm.provider=proxy 且 useMemorySystemUserKey=true 需要 metadata
- cos.generationLogRetentionDays must be a non-negative intege
- llm.provider=proxy 需要 instanceId,但 core 当前 instanceId 为空 ——
- llm.provider=proxy 且 llm.proxy.useMemorySystemUserKey=true 需
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/56a1cc8f1fafdf35.
Report an issue: GitHub.