Description
Describe the bug
When running an ADK agent using google-adk==1.2.1 with pydantic==2.11.5, an internal exception handling block in agent_loader.py attempts to access e.msg, which does not exist in modern Python exceptions (specifically pydantic_core._pydantic_core.ValidationError). This leads to a crash, masking the actual root cause.
To Reproduce
Steps to reproduce the behavior:
Create a simple ADK agent using the SequentialAgent class.
Pass an invalid input or missing state variable (e.g. forget to pass "user_input").
adk run --input='{"wrong_key": "some topic"}'
You’ll see:
AttributeError: 'ValidationError' object has no attribute 'msg'
Expected behavior
The error should cleanly show the validation problem (e.g., missing input key) without crashing on .msg. ADK should not assume .msg exists and should use str(e) instead.
Desktop (please complete the following information):
OS: Windows 10
Python version: 3.12.3
ADK version: 1.2.1
Pydantic version: 2.11.5
Additional context
This is caused by this line in agent_loader.py:
e.msg = f"Fail to load '{agent_name}' module. " + e.msg
Since e.msg is not a valid attribute of ValidationError in Pydantic v2, this breaks.
Suggested Fix
Replace:
e.msg = f"Fail to load '{agent_name}' module. " + e.msg
With:
raise RuntimeError(f"Fail to load '{agent_name}' module. {str(e)}") from e
This works across both Pydantic v1 and v2, and provides a proper traceback.