Repository navigation
[Bug] Resume can populate BaseAgentState for SequentialAgent and fail with ValidationError #5102
Description
Required Information
Describe the Bug:
When resuming a resumable workflow that contains a built-in SequentialAgent, ADK can restore a placeholder BaseAgentState() for the workflow agent instead of a SequentialAgentState. The subsequent resume path then fails with a pydantic ValidationError when SequentialAgent tries to load its state.
Steps to Reproduce:
- Install
google-adk==1.28.0 - Run the following minimal reproduction snippet:
from types import SimpleNamespace
from google.adk.agents import SequentialAgent
from google.adk.agents.invocation_context import InvocationContext
from google.adk.agents.sequential_agent import SequentialAgentState
workflow_agent = SequentialAgent(name="workflow_agent", sub_agents=[])
root_agent = SequentialAgent(name="root_agent", sub_agents=[workflow_agent])
ctx = SimpleNamespace(
is_resumable=True,
agent=root_agent,
agent_states={},
end_of_agents={},
_get_events=lambda **_: [
SimpleNamespace(
author="workflow_agent",
content=None,
actions=SimpleNamespace(end_of_agent=True, agent_state=None),
),
SimpleNamespace(
author="workflow_agent",
content=object(),
actions=SimpleNamespace(end_of_agent=False, agent_state=None),
),
],
)
InvocationContext.populate_invocation_agent_states(ctx)
print("agent_states after populate:", ctx.agent_states)
print("end_of_agents after populate:", ctx.end_of_agents)
workflow_agent._load_agent_state(ctx, SequentialAgentState)- Observe that
InvocationContext.populate_invocation_agent_states()storesBaseAgentState()forworkflow_agent - Observe that
_load_agent_state(..., SequentialAgentState)fails with a validation error
Expected Behavior:
Resuming a workflow with a built-in SequentialAgent should not fail with a state type mismatch. ADK should either:
- avoid synthesizing placeholder
BaseAgentStatefor workflow agents, or - synthesize the correct workflow-specific state type, or
- safely ignore placeholder state for workflow agents during resume.
Observed Behavior:
SequentialAgent resume fails with:
pydantic_core._pydantic_core.ValidationError: 1 validation error for SequentialAgentState
Input should be a valid dictionary or instance of SequentialAgentState [type=model_type, input_value=BaseAgentState(), input_type=BaseAgentState]
Environment Details:
- ADK Library Version (pip show google-adk):
1.28.0 - Desktop OS: macOS
- Python Version (python -V):
Python 3.13.7
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A, this failure occurs before any model call
Optional Information
Regression:
Yes. I also reproduced the same behavior on google-adk==1.27.3.
Logs:
agent_states after populate: {'workflow_agent': BaseAgentState()}
end_of_agents after populate: {'workflow_agent': False}
Traceback (most recent call last):
File "<stdin>", line 34, in <module>
File ".../site-packages/google/adk/agents/base_agent.py", line 185, in _load_agent_state
return state_type.model_validate(ctx.agent_states.get(self.name))
File ".../site-packages/pydantic/main.py", line 716, in model_validate
return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 1 validation error for SequentialAgentState
Input should be a valid dictionary or instance of SequentialAgentState [type=model_type, input_value=BaseAgentState(), input_type=BaseAgentState]
Screenshots / Video:
N/A
Additional Context:
According to the resume docs, SequentialAgent should resume by reading its saved current_sub_agent state. However, in the installed package, InvocationContext.populate_invocation_agent_states() can synthesize BaseAgentState() for an agent that has content in event history but no explicit agent_state. If that agent is a built-in workflow agent such as SequentialAgent, the later resume path fails because _load_agent_state(..., SequentialAgentState) expects a workflow-specific state object.
This looks like an internal type mismatch between the synthesized placeholder state and the workflow-specific state expected during resume.
Minimal Reproduction Code:
See the snippet above.
How often has this issue occurred?:
- Always (100%)
Activity
surajksharma07 commentedon Apr 7, 2026
@kazuki1213 The root cause is in _load_agent_state (base_agent.py:185) — it calls state_type.model_validate() on the placeholder BaseAgentState() that populate_invocation_agent_states synthesizes for agents that have content but no saved state, which is what triggers the ValidationError.
As a potential workaround, try adding a guard before the model_validate call: if type(stored) is BaseAgentState, return None instead of validating it.
Could you give that a try and see if it clears the error on your end?
PR #5126 is already heading in this direction, so if you get a chance to test it thoroughly, it'd be great to share your findings over there before it lands!
surajksharma07 commentedon May 19, 2026
Going ahead and closing this out since we haven't heard back in a while — the fix for this landed in v2.0.0!
populate_invocation_agent_states() now serializes the placeholder as BaseAgentState().model_dump(mode="json") (a dict) instead of a raw object, so model_validate() no longer chokes when a SequentialAgent reads it back on resume.
PR #5126 was the fix — huge thanks to @pandego for turning that around so quickly after the report.
Feel free to reopen if you're still seeing the ValidationError on v2.0.0 — happy to dig in further!