{"record":{"id":"d21565eb035224f2","repo":"mem0ai/mem0","slug":"one-of-user-id-agent-id-run-id-must-be-provided","errorCode":null,"errorMessage":"One of user_id, agent_id, run_id must be provided","messagePattern":"One of user_id, agent_id, run_id must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/proxy/main.py","lineNumber":98,"sourceCode":"        tool_choice: Optional[Union[str, dict]] = None,\n        logprobs: Optional[bool] = None,\n        top_logprobs: Optional[int] = None,\n        parallel_tool_calls: Optional[bool] = None,\n        deployment_id=None,\n        extra_headers: Optional[dict] = None,\n        # soon to be deprecated params by OpenAI\n        functions: Optional[List] = None,\n        function_call: Optional[str] = None,\n        # set api_base, api_version, api_key\n        base_url: Optional[str] = None,\n        api_version: Optional[str] = None,\n        api_key: Optional[str] = None,\n        model_list: Optional[list] = None,  # pass in a list of api_base,keys, etc.\n    ):\n        if messages is None:\n            messages = []\n        if not any([user_id, agent_id, run_id]):\n            raise ValueError(\"One of user_id, agent_id, run_id must be provided\")\n\n        if not litellm.supports_function_calling(model):\n            raise ValueError(\n                f\"Model '{model}' does not support function calling. Please use a model that supports function calling.\"\n            )\n\n        prepared_messages = self._prepare_messages(messages)\n        if prepared_messages[-1][\"role\"] == \"user\":\n            self._async_add_to_memory(messages, user_id, agent_id, run_id, metadata, filters)\n            relevant_memories = self._fetch_relevant_memories(messages, user_id, agent_id, run_id, filters, top_k)\n            logger.debug(f\"Retrieved {len(relevant_memories)} relevant memories\")\n            prepared_messages[-1][\"content\"] = self._format_query_with_memories(messages, relevant_memories)\n\n        response = litellm.completion(\n            model=model,\n            messages=prepared_messages,\n            temperature=temperature,\n            top_p=top_p,","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/proxy/main.py#L80-L116","documentation":"Mem0Proxy.completion()/the proxy's chat entry point requires exactly this: at least one of user_id, agent_id, or run_id so it knows which memory scope to read and write. Without a scope it cannot store or retrieve memories, so it refuses immediately with ValueError. All three parameters must not be simultaneously falsy.","triggerScenarios":"Calling mem0_proxy.completion(messages=..., model=...) without any of user_id/agent_id/run_id; passing them under wrong kwarg names (e.g. 'user' instead of 'user_id'); building a thin wrapper that forwards **kwargs but drops the scope arguments; per-user deployments where the caller assumed the proxy remembered the ID from init.","commonSituations":"Migrating code from direct litellm/openai calls (which need no user scope) to the Mem0 proxy and forgetting the new required arg; multi-user API gateways where the user_id is extracted from auth and is None for unauthenticated test requests.","solutions":["Pass a scope explicitly: completion(messages=..., model=..., user_id='alice') (or agent_id/run_id for agent/session scoped memory)","If wrapping the proxy, forward and validate user_id/agent_id/run_id before calling","For per-user apps, derive user_id from your auth context and fail loudly upstream when it is missing"],"exampleFix":"# before\nresp = mem0_proxy.completion(messages=messages, model=\"gpt-4o-mini\")\n\n# after\nresp = mem0_proxy.completion(messages=messages, model=\"gpt-4o-mini\", user_id=user_id)","handlingStrategy":"validation","validationCode":"if not any([user_id, agent_id, run_id]):\n    raise ValueError(\"user_id/agent_id/run_id required before calling proxy completion\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive user_id from auth context and reject unauthenticated calls early","Forward **kwargs carefully in wrappers; list scope args explicitly","Add a unit test asserting scope args reach the proxy call"],"tags":["proxy","litellm","validation","required-parameter"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}