{"record":{"id":"6fd135f7574cd74e","repo":"bytedance/deer-flow","slug":"agent-name-not-found","errorCode":null,"errorMessage":"Agent '${name}' not found","messagePattern":"Agent '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":404,"severity":"error","filePath":"frontend/src/core/agents/api.ts","lineNumber":48,"sourceCode":"    super(message);\n    this.name = \"AgentsApiDisabledError\";\n  }\n}\n\nfunction isAgentsApiDisabledDetail(detail: string | undefined): boolean {\n  return typeof detail === \"string\" && detail.includes(\"agents_api.enabled\");\n}\n\nexport async function listAgents(): Promise<Agent[]> {\n  const res = await fetch(`${getBackendBaseURL()}/api/agents`);\n  if (!res.ok) throw new Error(`Failed to load agents: ${res.statusText}`);\n  const data = (await res.json()) as { agents: Agent[] };\n  return data.agents;\n}\n\nexport async function getAgent(name: string): Promise<Agent> {\n  const res = await fetch(`${getBackendBaseURL()}/api/agents/${name}`);\n  if (!res.ok) throw new Error(`Agent '${name}' not found`);\n  return res.json() as Promise<Agent>;\n}\n\nexport async function createAgent(request: CreateAgentRequest): Promise<Agent> {\n  const res = await fetch(`${getBackendBaseURL()}/api/agents`, {\n    method: \"POST\",\n    headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify(request),\n  });\n  if (!res.ok) {\n    const err = (await res.json().catch(() => ({}))) as { detail?: string };\n    if (isAgentsApiDisabledDetail(err.detail)) {\n      throw new AgentsApiDisabledError(err.detail!);\n    }\n    throw new Error(err.detail ?? `Failed to create agent: ${res.statusText}`);\n  }\n  return res.json() as Promise<Agent>;\n}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/frontend/src/core/agents/api.ts#L30-L66","documentation":"Raised by Mem0Config.resolve_api_key() when the environment variable named by api_key_env is unset or contains only whitespace. The mem0 backend deliberately reads its credential from the environment (default MEM0_API_KEY) instead of config.yaml so the key never lands in a file that could be committed.","triggerScenarios":"Calling resolve_api_key() (it runs when the client needs to authenticate) while os.environ[api_key_env] is empty. Typical with fresh deploys, CI runners, containers started without the variable, or after renaming api_key_env in config without exporting the new name.","commonSituations":"Key exists in a local .env but the process runs under systemd/docker where .env is not loaded; api_key_env was customized (e.g. MEM0_PROD_KEY) but only MEM0_API_KEY is exported; the value is only whitespace after a bad copy-paste.","solutions":["Export the variable in the Gateway's real environment: export MEM0_API_KEY='...' or add it to docker-compose environment / systemd Environment=.","If you renamed api_key_env in backend_config, export the new name or revert it to MEM0_API_KEY.","Confirm the value is non-blank in the service context: printenv MEM0_API_KEY | wc -c."],"exampleFix":"# before\n# (nothing exported)\npython -m app.gateway  # -> mem0 API key missing: MEM0_API_KEY\n\n# after\nexport MEM0_API_KEY='m0-xxxxxxxxxxxxxxxx'\npython -m app.gateway\n# docker-compose.yml:\n#   environment:\n#     - MEM0_API_KEY=${MEM0_API_KEY}","handlingStrategy":"validation","validationCode":"import os\n\n\ndef require_env(name: str) -> str:\n    value = os.environ.get(name, '').strip()\n    if not value:\n        raise SystemExit(f'Missing required environment variable: {name}')\n    return value\n\n\nrequire_env('MEM0_API_KEY')  # or your configured api_key_env","typeGuard":null,"tryCatchPattern":"try:\n    key = config.resolve_api_key()\nexcept ValueError as e:\n    # startup/config error: fail the deployment, do not retry\n    raise SystemExit(f'mem0 credential not available: {e}')","preventionTips":["Declare MEM0_API_KEY (or the customized api_key_env) in docker-compose environment and systemd units, not only your shell .env.","Add a startup preflight asserting all *_API_KEY env vars before the service accepts traffic.","Keep api_key_env names consistent across environments to avoid rename/export drift."],"tags":["mem0","configuration","environment","credentials","validation"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}