{"record":{"id":"0807a848ed974b6c","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"llm-provider-proxy-llm-proxy-usememorysystemuser","errorCode":null,"errorMessage":"llm.provider=proxy 且 llm.proxy.useMemorySystemUserKey=true 需要 metadata.systemUser.memory 完整配置（userId + userKey），当前缺失","messagePattern":"llm\\.provider=proxy 且 llm\\.proxy\\.useMemorySystemUserKey=true 需要 metadata\\.systemUser\\.memory 完整配置（userId \\+ userKey），当前缺失","errorType":"validation","errorClass":"LlmResolveError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/gateway/llm-resolver.ts","lineNumber":70,"sourceCode":"\n  // provider=proxy 的校验\n  if (!llm.baseUrl) {\n    throw new LlmResolveError(\n      \"llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL (如 http://127.0.0.1:8096)\",\n    );\n  }\n  if (!instanceId || !instanceId.trim()) {\n    throw new LlmResolveError(\n      \"llm.provider=proxy 需要 instanceId，但 core 当前 instanceId 为空 —— \" +\n      \"service 模式下确保请求带 x-tdai-service-id，standalone 模式下确保 yaml 有 instanceId\",\n    );\n  }\n\n  const useSystemUserKey = llm.proxy?.useMemorySystemUserKey ?? true;\n  let effectiveApiKey = llm.apiKey;\n  if (useSystemUserKey) {\n    if (!memorySystemUser) {\n      throw new LlmResolveError(\n        \"llm.provider=proxy 且 llm.proxy.useMemorySystemUserKey=true 需要 \" +\n        \"metadata.systemUser.memory 完整配置（userId + userKey），当前缺失\",\n      );\n    }\n    if (!isValidMemorySystemUserKey(memorySystemUser.userKey)) {\n      throw new LlmResolveError(\n        \"metadata.systemUser.memory.userKey 必须匹配 sk-mem-[A-Za-z0-9_-]{32}\",\n      );\n    }\n    effectiveApiKey = memorySystemUser.userKey;\n  }\n\n  if (!effectiveApiKey) {\n    throw new LlmResolveError(\n      \"llm.provider=proxy 且 useMemorySystemUserKey=false 时必须显式配置 llm.apiKey\",\n    );\n  }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/gateway/llm-resolver.ts#L52-L88","documentation":"With provider=proxy, the default behavior (proxy.useMemorySystemUserKey defaults to true) is to authenticate proxy calls using the memory system user credentials from metadata.systemUser.memory. If that config object is absent (resolve found no complete userId + userKey pair), the resolver throws this LlmResolveError instead of sending unauthenticated proxy calls.","triggerScenarios":"provider=proxy (or omitted useMemorySystemUserKey, which defaults true) with metadata.systemUser.memory missing, or present with only userId or only userKey.","commonSituations":"Fresh deployment where the systemUser block was never populated; partially filled yaml (userKey left as placeholder/empty); operator set useMemorySystemUserKey implicitly true assuming llm.apiKey would be used; config refactor removed metadata.systemUser.","solutions":["Fill metadata.systemUser.memory with both userId and userKey (userKey must match sk-mem-[A-Za-z0-9_-]{32}).","Generate a memory system user key if none exists and put it in the metadata config.","If you want to use a direct key instead, explicitly set llm.proxy.useMemorySystemUserKey: false and provide llm.apiKey."],"exampleFix":"// before\nmetadata:\n  systemUser: {}\n// after\nmetadata:\n  systemUser:\n    memory:\n      userId: mem-system\n      userKey: sk-mem-AbCdEf0123456789AbCdEf0123456789","handlingStrategy":"validation","validationCode":"const useSysKey = llm.proxy?.useMemorySystemUserKey ?? true;\nif (llm.provider === 'proxy' && useSysKey) {\n  const m = metadata?.systemUser?.memory;\n  if (!m?.userId || !m?.userKey) {\n    throw new Error('metadata.systemUser.memory requires both userId and userKey when useMemorySystemUserKey=true');\n  }\n}","typeGuard":"function hasMemorySystemUser(m: unknown): m is { userId: string; userKey: string } {\n  const o = m as any;\n  return !!o && typeof o.userId === 'string' && o.userId.length > 0 && typeof o.userKey === 'string' && o.userKey.length > 0;\n}","tryCatchPattern":"try {\n  gateway.start();\n} catch (err) {\n  if (err instanceof LlmResolveError && err.message.includes('systemUser.memory')) {\n    console.error('Configure metadata.systemUser.memory (userId + userKey) or set useMemorySystemUserKey=false with llm.apiKey');\n  }\n  throw err;\n}","preventionTips":["Provision the memory system user as a standard deployment step","Treat useMemorySystemUserKey as defaulting to true — set it explicitly to avoid surprises","Fill BOTH userId and userKey, never only one","Validate the metadata section in CI config checks"],"tags":["configuration","llm-proxy","authentication"],"backgroundTag":"missing-system-user-config","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}