microsoft/autogen · error · ValueError
default_chat_model not found in config.models
Error message
default_chat_model not found in config.models
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/tools/graphrag/_global_search.py:206
Args:
root_dir: Path to the GraphRAG root directory
config_filepath: Path to the GraphRAG settings file (optional)
Returns:
An initialized GlobalSearchTool instance
"""
# Load GraphRAG config
if isinstance(root_dir, str):
root_dir = Path(root_dir)
if isinstance(config_filepath, str):
config_filepath = Path(config_filepath)
config = load_config(root_dir=root_dir, config_filepath=config_filepath)
# Get the language model configuration from the models section
chat_model_config = config.models.get(defs.DEFAULT_CHAT_MODEL_ID)
if chat_model_config is None:
raise ValueError("default_chat_model not found in config.models")
# Initialize token encoder based on the model being used
try:
token_encoder = tiktoken.encoding_for_model(chat_model_config.model)
except KeyError:
# Fallback to cl100k_base if model is not recognized by tiktoken
token_encoder = tiktoken.get_encoding("cl100k_base")
# Create the LLM using ModelManager
model = ModelManager().get_or_create_chat_model(
name="global_search_model",
model_type=chat_model_config.type,
config=chat_model_config,
)
# Create data config from storage paths
data_config = DataConfig(
input_dir=str(config.output.base_dir),View on GitHub (pinned to 027ecf0a37)
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.
Example fix
# settings.yaml — before
model:
type: openai_chat
model: gpt-4o
# settings.yaml — after
models:
default_chat_model:
type: openai_chat
model: gpt-4o
api_key: ${GRAPHRAG_API_KEY} Defensive patterns
Strategy: validation
Validate before calling
from autogen_ext.tools.graphrag._config_loader import load_config
cfg = load_config(root_dir=root_dir, config_filepath=config_filepath)
if "default_chat_model" not in cfg.models:
raise ValueError("settings.yaml missing models.default_chat_model") Type guard
def has_default_chat_model(cfg) -> TypeGuard[type("GraphRAGConfig")]:
return isinstance(cfg.models, dict) and "default_chat_model" in cfg.models Try / catch
try:
tool = await GlobalSearchTool.from_settings_dir(root_dir)
except ValueError as e:
if "default_chat_model" in str(e):
raise ConfigError("Add models.default_chat_model to settings.yaml") from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- default_chat_model not found in config.models
- default_embedding_model not found in config.models
- Failed to fetch settings
- Failed to update settings
- modelName is a required property for LMStudioConfig and cann
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/185aaf772632aba7.
Report an issue: GitHub.