{"record":{"id":"741e5549bd8ee2f5","repo":"microsoft/autogen","slug":"model-capabilities-and-model-info-are-mutually-exc","errorCode":null,"errorMessage":"model_capabilities and model_info are mutually exclusive","messagePattern":"model_capabilities and model_info are mutually exclusive","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py","lineNumber":475,"sourceCode":"\nclass BaseOllamaChatCompletionClient(ChatCompletionClient):\n    def __init__(\n        self,\n        client: AsyncClient,\n        *,\n        create_args: Dict[str, Any],\n        model_capabilities: Optional[ModelCapabilities] = None,  # type: ignore\n        model_info: Optional[ModelInfo] = None,\n    ):\n        self._client = client\n        self._model_name = create_args[\"model\"]\n        if model_capabilities is None and model_info is None:\n            try:\n                self._model_info = _model_info.get_info(create_args[\"model\"])\n            except KeyError as err:\n                raise ValueError(\"model_info is required when model name is not a valid OpenAI model\") from err\n        elif model_capabilities is not None and model_info is not None:\n            raise ValueError(\"model_capabilities and model_info are mutually exclusive\")\n        elif model_capabilities is not None and model_info is None:\n            warnings.warn(\"model_capabilities is deprecated, use model_info instead\", DeprecationWarning, stacklevel=2)\n            info = cast(ModelInfo, model_capabilities)\n            info[\"family\"] = ModelFamily.UNKNOWN\n            self._model_info = info\n        elif model_capabilities is None and model_info is not None:\n            self._model_info = model_info\n\n        self._resolved_model: Optional[str] = None\n        self._model_class: Optional[str] = None\n        if \"model\" in create_args:\n            self._resolved_model = create_args[\"model\"]\n            self._model_class = _model_info.resolve_model_class(create_args[\"model\"])\n\n        if (\n            not self._model_info[\"json_output\"]\n            and \"response_format\" in create_args\n            and (","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/ollama/_ollama_client.py#L457-L493","documentation":"The Ollama client's constructor accepts both the deprecated model_capabilities and the current model_info, but they are mutually exclusive — passing both raises this ValueError so there is no ambiguity about which one takes effect. The four-branch validation also shows model_capabilities alone still works but emits a DeprecationWarning.","triggerScenarios":"OllamaChatCompletionClient(model=..., model_capabilities={...}, model_info={...}) — both keyword arguments non-None; config merging (defaults + overrides) that accumulates both keys.","commonSituations":"Upgrading old code: adding model_info while the legacy model_capabilities is still in the config dict; shared config templates carrying deprecated keys.","solutions":["Delete model_capabilities and keep only model_info","If merging configs, pop the deprecated key: cfg.pop('model_capabilities', None) before construction","Audit for other deprecated-capabilities usages since the whole parameter is being phased out"],"exampleFix":"# before\nclient = OllamaChatCompletionClient(model=\"llama3\", model_capabilities={\"vision\": False}, model_info={\"vision\": False, \"family\": ModelFamily.UNKNOWN})\n\n# after\nclient = OllamaChatCompletionClient(model=\"llama3\", model_info={\"vision\": False, \"function_calling\": True, \"json_output\": True, \"structured_output\": True, \"family\": ModelFamily.UNKNOWN})","handlingStrategy":"validation","validationCode":"cfg.pop(\"model_capabilities\", None)  # drop deprecated key before construction\nclient = OllamaChatCompletionClient(**cfg)","typeGuard":null,"tryCatchPattern":"try:\n    client = OllamaChatCompletionClient(**cfg)\nexcept ValueError as e:\n    if \"mutually exclusive\" in str(e):\n        cfg.pop(\"model_capabilities\", None)\n        client = OllamaChatCompletionClient(**cfg)\n    else:\n        raise","preventionTips":["Migrate configs off model_capabilities entirely; keep only model_info","Treat DeprecationWarnings from model_capabilities as fix-now signals","Validate config dicts against a schema that forbids both keys simultaneously"],"tags":["ollama","configuration","deprecation","constructor"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}