TencentCloud/TencentDB-Agent-Memory · error · LlmResolveError
llm.provider=proxy 需要 instanceId,但 core 当前 instanceId 为空 ——
Error message
llm.provider=proxy 需要 instanceId,但 core 当前 instanceId 为空 —— service 模式下确保请求带 x-tdai-service-id,standalone 模式下确保 yaml 有 instanceId
What it means
With llm.provider=proxy, the gateway needs an instanceId to build the per-instance proxy path /proxy/<iid>/v1. When the current instanceId is empty — i.e. no x-tdai-service-id header in service mode and no instanceId in standalone yaml — resolveEffectiveLlmConfig throws this LlmResolveError before any LLM call.
Source
Thrown at MemoryCore/src/gateway/llm-resolver.ts:60
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),当前缺失",
);
}
if (!isValidMemorySystemUserKey(memorySystemUser.userKey)) {
throw new LlmResolveError(
"metadata.systemUser.memory.userKey 必须匹配 sk-mem-[A-Za-z0-9_-]{32}",
);View on GitHub (pinned to 3efcd317b8)
Solutions
- In service mode, send the x-tdai-service-id header on every request to the gateway (with the registered service instance id).
- In standalone mode, set instanceId in the gateway yaml so the core has a non-empty id.
- Check for ingress/load-balancer rules that strip x-tdai-service-id before it reaches MemoryCore.
- Verify which config file is actually loaded (startup logs) — instanceId may be set in a different yaml than the active one.
Example fix
// before (standalone yaml) llm: provider: proxy baseUrl: http://127.0.0.1:8096 // after instanceId: my-core-instance llm: provider: proxy baseUrl: http://127.0.0.1:8096 // service mode: curl -H "x-tdai-service-id: my-core-instance" ...
Defensive patterns
Strategy: validation
Validate before calling
const iid = process.env.INSTANCE_ID ?? yamlConfig.instanceId;
if (llmConfig.provider === 'proxy' && !(iid && iid.trim())) {
throw new Error('provider=proxy requires a non-empty instanceId (yaml instanceId or x-tdai-service-id header)');
} Type guard
function hasInstanceId(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await gateway.start();
} catch (err) {
if (err instanceof LlmResolveError && err.message.includes('instanceId')) {
console.error('Set yaml instanceId (standalone) or ensure x-tdai-service-id header (service mode)');
}
throw err;
} Prevention
- Always send x-tdai-service-id on gateway requests in service mode
- Verify ingress rules do not strip x-tdai-service-id
- Set instanceId in standalone yaml as part of the deployment checklist
- Log the effective instanceId at startup to catch empty values early
When it happens
Trigger: provider=proxy with a valid baseUrl, but instanceId is empty: service-mode requests missing the x-tdai-service-id header, or standalone deployments whose yaml has no instanceId field (or it is whitespace).
Common situations: Calling the gateway directly via curl/SDK without the x-tdai-service-id header; new standalone deployment where the instanceId section was never filled; header stripped by an ingress/proxy; instanceId set only in a different config file than the one loaded.
Related errors
- llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL (如
- llm.provider=proxy 且 llm.proxy.useMemorySystemUserKey=true 需
- llm.provider=proxy 且 useMemorySystemUserKey=false 时必须显式配置 ll
- llm.provider=proxy 需要 llm.baseUrl 指向 context_proxy 根 URL
- llm.provider=proxy 且 useMemorySystemUserKey=true 需要 metadata
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/5351c37064ebbcf9.
Report an issue: GitHub.