From d2b092a77e4e130c9090eb22eed4193212149727 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Mon, 6 Apr 2026 22:32:33 +0800 Subject: [PATCH] fix: clear error messages for missing llm_type/executor_type --- .../src/crewai/agents/agent_builder/base_agent.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/agents/agent_builder/base_agent.py b/lib/crewai/src/crewai/agents/agent_builder/base_agent.py index 90f352619..cfa08bbc3 100644 --- a/lib/crewai/src/crewai/agents/agent_builder/base_agent.py +++ b/lib/crewai/src/crewai/agents/agent_builder/base_agent.py @@ -79,7 +79,12 @@ def _validate_llm_ref(value: Any) -> Any: if isinstance(value, dict): import importlib - llm_type = value["llm_type"] + llm_type = value.get("llm_type") + if not llm_type or llm_type not in _LLM_TYPE_REGISTRY: + raise ValueError( + f"Unknown or missing llm_type: {llm_type!r}. " + f"Expected one of {list(_LLM_TYPE_REGISTRY)}" + ) dotted = _LLM_TYPE_REGISTRY[llm_type] mod_path, cls_name = dotted.rsplit(".", 1) cls = getattr(importlib.import_module(mod_path), cls_name) @@ -106,7 +111,12 @@ def _validate_executor_ref(value: Any) -> Any: if isinstance(value, dict): import importlib - executor_type = value["executor_type"] + executor_type = value.get("executor_type") + if not executor_type or executor_type not in _EXECUTOR_TYPE_REGISTRY: + raise ValueError( + f"Unknown or missing executor_type: {executor_type!r}. " + f"Expected one of {list(_EXECUTOR_TYPE_REGISTRY)}" + ) dotted = _EXECUTOR_TYPE_REGISTRY[executor_type] mod_path, cls_name = dotted.rsplit(".", 1) cls = getattr(importlib.import_module(mod_path), cls_name)