{"record":{"id":"cb821d2b5039ea90","repo":"microsoft/autogen","slug":"please-provide-model-path-if-or-provide-repo-i","errorCode":null,"errorMessage":"Please provide model_path if ... or provide repo_id and filename if ....","messagePattern":"Please provide model_path if \\.\\.\\. or provide repo_id and filename if \\.\\.\\.\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/_llama_cpp_completion_client.py","lineNumber":260,"sourceCode":"\n        if model_info:\n            validate_model_info(model_info)\n            self._model_info = model_info\n        else:\n            # Default model info.\n            self._model_info = self.DEFAULT_MODEL_INFO\n\n        if \"repo_id\" in kwargs and \"filename\" in kwargs and kwargs[\"repo_id\"] and kwargs[\"filename\"]:\n            repo_id: str = cast(str, kwargs.pop(\"repo_id\"))\n            filename: str = cast(str, kwargs.pop(\"filename\"))\n            pretrained = Llama.from_pretrained(repo_id=repo_id, filename=filename, **kwargs)  # type: ignore\n            assert isinstance(pretrained, Llama)\n            self.llm = pretrained\n\n        elif \"model_path\" in kwargs:\n            self.llm = Llama(**kwargs)  # pyright: ignore[reportUnknownMemberType]\n        else:\n            raise ValueError(\"Please provide model_path if ... or provide repo_id and filename if ....\")\n        self._total_usage = {\"prompt_tokens\": 0, \"completion_tokens\": 0}\n\n    async def create(\n        self,\n        messages: Sequence[LLMMessage],\n        *,\n        tools: Sequence[Tool | ToolSchema] = [],\n        tool_choice: Tool | Literal[\"auto\", \"required\", \"none\"] = \"auto\",\n        # None means do not override the default\n        # A value means to override the client default - often specified in the constructor\n        json_output: Optional[bool | type[BaseModel]] = None,\n        extra_create_args: Mapping[str, Any] = {},\n        cancellation_token: Optional[CancellationToken] = None,\n    ) -> CreateResult:\n        create_args = dict(extra_create_args)\n        # Convert LLMMessage objects to dictionaries with 'role' and 'content'\n        # converted_messages: List[Dict[str, str | Image | list[str | Image] | list[FunctionCall]]] = []\n        converted_messages: list[","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/_llama_cpp_completion_client.py#L242-L278","documentation":"LlamaCppChatCompletionClient's constructor requires exactly one way to locate a model: either a model_path kwarg passed straight to Llama(...), or both repo_id and filename (both non-empty) passed to Llama.from_pretrained(...). If kwargs contain none of these, the final else branch raises this ValueError. It is a configuration-validation error fired at client construction time.","triggerScenarios":"Calling LlamaCppChatCompletionClient() with no model_path, repo_id, or filename; passing repo_id alone or filename alone (the branch requires both keys present AND truthy); passing model_path=None or empty string only if the key is absent — note only key presence is checked for model_path ('model_path' in kwargs).","commonSituations":"Copied an example for a different model client and forgot the local GGUF path; typo like modelpath='...' or path_to_model=... so the key never reaches kwargs; assumed repo_id alone is enough to pull from Hugging Face; env var for the model path empty so the key was never set.","solutions":["Pass a local GGUF file path: LlamaCppChatCompletionClient(model_path='/path/to/model.gguf')","Or pull from Hugging Face with BOTH arguments: LlamaCppChatCompletionClient(repo_id='Qwen/Qwen2-0.5B-Instruct-GGUF', filename='qwen2-0_5b-instruct-q4_k_m.gguf')","Check spelling and case of the kwarg — it must be exactly model_path (or the pair repo_id/filename); any extra misspelled keys are silently forwarded to Llama() as unused kwargs","If building kwargs dynamically, assert 'model_path' in kwargs or ('repo_id' in kwargs and 'filename' in kwargs) before constructing the client"],"exampleFix":"# before\nclient = LlamaCppChatCompletionClient(model='my-model.gguf')  # wrong kwarg name\n\n# after\nclient = LlamaCppChatCompletionClient(model_path='my-model.gguf')","handlingStrategy":"validation","validationCode":"def assert_llama_config(kwargs: dict) -> None:\n    has_path = \"model_path\" in kwargs\n    has_repo = bool(kwargs.get(\"repo_id\")) and bool(kwargs.get(\"filename\"))\n    if not (has_path or has_repo):\n        raise ValueError(\"Supply model_path, or both repo_id and filename\")\n\nassert_llama_config(client_kwargs)\nclient = LlamaCppChatCompletionClient(**client_kwargs)","typeGuard":"def has_valid_model_source(kwargs: Mapping[str, Any]) -> bool:\n    return (\n        \"model_path\" in kwargs\n        or (bool(kwargs.get(\"repo_id\")) and bool(kwargs.get(\"filename\")))\n    )","tryCatchPattern":"try:\n    client = LlamaCppChatCompletionClient(**cfg)\nexcept ValueError as e:\n    if \"model_path\" in str(e):\n        raise SystemExit(f\"Bad model config: {e}\") from e\n    raise","preventionTips":["Centralize llama.cpp client construction in one factory that always sets model_path or repo_id+filename","Log the exact kwargs keys (not values) before construction when debugging config loading","Add a startup config check that fails fast before the agent runtime starts"],"tags":["llama-cpp","configuration","constructor","model-loading"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}