From d6b928bdf7cdbf8f1925d4c5227c7d580093348e Mon Sep 17 00:00:00 2001 From: Shangjie Chen Date: Wed, 5 Nov 2025 11:30:48 -0800 Subject: [PATCH] chore: Returns agent state regardless if ctx.is_resumable This allows state to be passing across agents Co-authored-by: Shangjie Chen PiperOrigin-RevId: 828557989 --- src/google/adk/agents/base_agent.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/google/adk/agents/base_agent.py b/src/google/adk/agents/base_agent.py index 09eef908..b13001c9 100644 --- a/src/google/adk/agents/base_agent.py +++ b/src/google/adk/agents/base_agent.py @@ -164,19 +164,16 @@ class BaseAgent(BaseModel): ctx: InvocationContext, state_type: Type[AgentState], ) -> Optional[AgentState]: - """Loads the agent state from the invocation context, handling resumption. + """Loads the agent state from the invocation context. Args: ctx: The invocation context. state_type: The type of the agent state. Returns: - The current state if resuming, otherwise None. + The current state if exists, otherwise None. """ - if not ctx.is_resumable: - return None - - if self.name not in ctx.agent_states: + if ctx.agent_states is None or self.name not in ctx.agent_states: return None else: return state_type.model_validate(ctx.agent_states.get(self.name))