microsoft/autogen · error · ValueError
Please provide model_path if ... or provide repo_id and file
Error message
Please provide model_path if ... or provide repo_id and filename if ....
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/llama_cpp/_llama_cpp_completion_client.py:260
if model_info:
validate_model_info(model_info)
self._model_info = model_info
else:
# Default model info.
self._model_info = self.DEFAULT_MODEL_INFO
if "repo_id" in kwargs and "filename" in kwargs and kwargs["repo_id"] and kwargs["filename"]:
repo_id: str = cast(str, kwargs.pop("repo_id"))
filename: str = cast(str, kwargs.pop("filename"))
pretrained = Llama.from_pretrained(repo_id=repo_id, filename=filename, **kwargs) # type: ignore
assert isinstance(pretrained, Llama)
self.llm = pretrained
elif "model_path" in kwargs:
self.llm = Llama(**kwargs) # pyright: ignore[reportUnknownMemberType]
else:
raise ValueError("Please provide model_path if ... or provide repo_id and filename if ....")
self._total_usage = {"prompt_tokens": 0, "completion_tokens": 0}
async def create(
self,
messages: Sequence[LLMMessage],
*,
tools: Sequence[Tool | ToolSchema] = [],
tool_choice: Tool | Literal["auto", "required", "none"] = "auto",
# None means do not override the default
# A value means to override the client default - often specified in the constructor
json_output: Optional[bool | type[BaseModel]] = None,
extra_create_args: Mapping[str, Any] = {},
cancellation_token: Optional[CancellationToken] = None,
) -> CreateResult:
create_args = dict(extra_create_args)
# Convert LLMMessage objects to dictionaries with 'role' and 'content'
# converted_messages: List[Dict[str, str | Image | list[str | Image] | list[FunctionCall]]] = []
converted_messages: list[View on GitHub (pinned to 027ecf0a37)
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
Example fix
# before client = LlamaCppChatCompletionClient(model='my-model.gguf') # wrong kwarg name # after client = LlamaCppChatCompletionClient(model_path='my-model.gguf')
Defensive patterns
Strategy: validation
Validate before calling
def assert_llama_config(kwargs: dict) -> None:
has_path = "model_path" in kwargs
has_repo = bool(kwargs.get("repo_id")) and bool(kwargs.get("filename"))
if not (has_path or has_repo):
raise ValueError("Supply model_path, or both repo_id and filename")
assert_llama_config(client_kwargs)
client = LlamaCppChatCompletionClient(**client_kwargs) Type guard
def has_valid_model_source(kwargs: Mapping[str, Any]) -> bool:
return (
"model_path" in kwargs
or (bool(kwargs.get("repo_id")) and bool(kwargs.get("filename")))
) Try / catch
try:
client = LlamaCppChatCompletionClient(**cfg)
except ValueError as e:
if "model_path" in str(e):
raise SystemExit(f"Bad model config: {e}") from e
raise Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Unsupported config type {config.GetType()}
- Cannot save screenshots without a debug directory. Set it us
- Timeout must be greater than or equal to 1.
- endpoint is required for AzureAIChatCompletionClient
- credential is required for AzureAIChatCompletionClient
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/cb821d2b5039ea90.
Report an issue: GitHub.