{"record":{"id":"c675e7636b158f15","repo":"microsoft/autogen","slug":"default-chat-model-not-found-in-config-models-c675e7","errorCode":null,"errorMessage":"default_chat_model not found in config.models","messagePattern":"default_chat_model not found in config\\.models","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/tools/graphrag/_local_search.py","lineNumber":209,"sourceCode":"    def from_settings(cls, root_dir: Path, config_filepath: Path | None = None) -> \"LocalSearchTool\":\n        \"\"\"Create a LocalSearchTool instance from GraphRAG settings file.\n\n        Args:\n            root_dir: Path to the GraphRAG root directory\n            config_filepath: Path to the GraphRAG settings file (optional)\n\n        Returns:\n            An initialized LocalSearchTool instance\n        \"\"\"\n        # Load GraphRAG config\n        config = load_config(root_dir=root_dir, config_filepath=config_filepath)\n\n        # Get the language model configurations from the models section\n        chat_model_config = config.models.get(defs.DEFAULT_CHAT_MODEL_ID)\n        embedding_model_config = config.models.get(defs.DEFAULT_EMBEDDING_MODEL_ID)\n\n        if chat_model_config is None:\n            raise ValueError(\"default_chat_model not found in config.models\")\n        if embedding_model_config is None:\n            raise ValueError(\"default_embedding_model not found in config.models\")\n\n        # Initialize token encoder based on the model being used\n        try:\n            token_encoder = tiktoken.encoding_for_model(chat_model_config.model)\n        except KeyError:\n            # Fallback to cl100k_base if model is not recognized by tiktoken\n            token_encoder = tiktoken.get_encoding(\"cl100k_base\")\n\n        # Create the models using ModelManager\n        model = ModelManager().get_or_create_chat_model(\n            name=\"local_search_model\",\n            model_type=chat_model_config.type,\n            config=chat_model_config,\n        )\n\n        embedder = ModelManager().get_or_create_embedding_model(","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/graphrag/_local_search.py#L191-L227","documentation":"GraphRAG LocalSearchTool.from_settings loads the same settings.yaml and requires a chat model registered under the reserved ID 'default_chat_model' in config.models. If missing, ValueError('default_chat_model not found in config.models') is raised before any model or token encoder is created. Local search uses this model for answer synthesis over community/local context.","triggerScenarios":"Calling LocalSearchTool.from_settings(root_dir=..., config_filepath=...) with a settings.yaml whose models dict has no 'default_chat_model' key. Note local search additionally requires 'default_embedding_model'; the chat-model check fires first.","commonSituations":"Same family of issues as global search: pre-migration settings.yaml, renamed model keys, wrong root_dir, or settings generated by an incompatible graphrag CLI version. Frequently hit when only the embedding model was configured because earlier experiments used only vector lookups.","solutions":["Add a models.default_chat_model entry (type, model, api_key) to settings.yaml.","Add models.default_embedding_model as well, since local search raises on it next if absent.","Re-generate settings.yaml with the version of the graphrag tooling matching this autogen-ext release.","Verify root_dir points at the workspace containing the settings file you edited."],"exampleFix":"# settings.yaml — before\nmodels:\n  default_embedding_model:\n    type: openai_embedding\n    model: text-embedding-3-small\n\n# settings.yaml — after\nmodels:\n  default_chat_model:\n    type: openai_chat\n    model: gpt-4o\n    api_key: ${GRAPHRAG_API_KEY}\n  default_embedding_model:\n    type: openai_embedding\n    model: text-embedding-3-small\n    api_key: ${GRAPHRAG_API_KEY}","handlingStrategy":"validation","validationCode":"cfg = load_config(root_dir=root_dir, config_filepath=config_filepath)\nmissing = [k for k in (\"default_chat_model\",) if k not in cfg.models]\nif missing:\n    raise ValueError(f\"settings.yaml missing models entries: {missing}\")","typeGuard":null,"tryCatchPattern":"try:\n    tool = await LocalSearchTool.from_settings(root_dir=root_dir)\nexcept ValueError as e:\n    raise ConfigError(f\"GraphRAG config incomplete: {e}\") from e","preventionTips":["Local search needs BOTH default_chat_model and default_embedding_model — validate both up front.","Generate settings.yaml with the graphrag CLI version matching your autogen-ext release.","Log the resolved root_dir/config path before loading so wrong-directory mistakes are obvious."],"tags":["graphrag","config","settings","yaml"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}