{"record":{"id":"185aaf772632aba7","repo":"microsoft/autogen","slug":"default-chat-model-not-found-in-config-models","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/_global_search.py","lineNumber":206,"sourceCode":"        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 GlobalSearchTool instance\n        \"\"\"\n        # Load GraphRAG config\n        if isinstance(root_dir, str):\n            root_dir = Path(root_dir)\n        if isinstance(config_filepath, str):\n            config_filepath = Path(config_filepath)\n        config = load_config(root_dir=root_dir, config_filepath=config_filepath)\n\n        # Get the language model configuration from the models section\n        chat_model_config = config.models.get(defs.DEFAULT_CHAT_MODEL_ID)\n\n        if chat_model_config is None:\n            raise ValueError(\"default_chat_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 LLM using ModelManager\n        model = ModelManager().get_or_create_chat_model(\n            name=\"global_search_model\",\n            model_type=chat_model_config.type,\n            config=chat_model_config,\n        )\n\n        # Create data config from storage paths\n        data_config = DataConfig(\n            input_dir=str(config.output.base_dir),","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/tools/graphrag/_global_search.py#L188-L224","documentation":"GraphRAG GlobalSearchTool.from_settingsDir loads settings.yaml via load_config and looks up config.models['default_chat_model']. If that key is absent (models dict missing or renamed), it raises ValueError('default_chat_model not found in config.models'). The global search indexer/querier requires a chat model under that exact reserved ID to build its internal ModelManager model.","triggerScenarios":"Calling GraphRAG GlobalSearchTool.from_settings_dir(root_dir, config_filepath) where the loaded settings.yaml has no models section, or a models section without the key 'default_chat_model'. The lookup is config.models.get(defs.DEFAULT_CHAT_MODEL_ID) and raises when it returns None.","commonSituations":"Using an old GraphRAG settings.yaml from before the models-migration (model config lived at top level); hand-editing settings.yaml and renaming the model entry; running the newer AutoGen GraphRAG tools against a workspace generated by the graphrag CLI of a different version; pointing root_dir at the wrong directory so a stale/empty settings.yaml is found.","solutions":["Open settings.yaml under root_dir and ensure a models: section contains a default_chat_model entry with type, model, and credentials (api_key etc.).","If your settings predate the models schema, regenerate or migrate it: move the chat model block under models with key default_chat_model.","Confirm root_dir/config_filepath actually resolve to the settings file you edited (log the resolved path).","Verify load_config did not silently fall back to defaults because the yaml filename is non-standard."],"exampleFix":"# settings.yaml — before\nmodel:\n  type: openai_chat\n  model: gpt-4o\n\n# settings.yaml — after\nmodels:\n  default_chat_model:\n    type: openai_chat\n    model: gpt-4o\n    api_key: ${GRAPHRAG_API_KEY}","handlingStrategy":"validation","validationCode":"from autogen_ext.tools.graphrag._config_loader import load_config\n\ncfg = load_config(root_dir=root_dir, config_filepath=config_filepath)\nif \"default_chat_model\" not in cfg.models:\n    raise ValueError(\"settings.yaml missing models.default_chat_model\")","typeGuard":"def has_default_chat_model(cfg) -> TypeGuard[type(\"GraphRAGConfig\")]:\n    return isinstance(cfg.models, dict) and \"default_chat_model\" in cfg.models","tryCatchPattern":"try:\n    tool = await GlobalSearchTool.from_settings_dir(root_dir)\nexcept ValueError as e:\n    if \"default_chat_model\" in str(e):\n        raise ConfigError(\"Add models.default_chat_model to settings.yaml\") from e\n    raise","preventionTips":["Check settings.yaml schema in CI with a YAML schema validator.","Pin the graphrag settings schema version alongside your autogen-ext version.","Write a smoke test that constructs both search tools from the checked-in settings.yaml."],"tags":["graphrag","config","settings","yaml"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}