Skip to content

Commit 48681cb

Browse files
google-genai-botcopybara-github
authored andcommitted
chore: Returns agent state regardless if ctx.is_resumable
This allows state to be passing across agents PiperOrigin-RevId: 828665491
1 parent 59d422c commit 48681cb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/google/adk/agents/base_agent.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,19 @@ def _load_agent_state(
164164
ctx: InvocationContext,
165165
state_type: Type[AgentState],
166166
) -> Optional[AgentState]:
167-
"""Loads the agent state from the invocation context.
167+
"""Loads the agent state from the invocation context, handling resumption.
168168
169169
Args:
170170
ctx: The invocation context.
171171
state_type: The type of the agent state.
172172
173173
Returns:
174-
The current state if exists, otherwise None.
174+
The current state if resuming, otherwise None.
175175
"""
176-
if ctx.agent_states is None or self.name not in ctx.agent_states:
176+
if not ctx.is_resumable:
177+
return None
178+
179+
if self.name not in ctx.agent_states:
177180
return None
178181
else:
179182
return state_type.model_validate(ctx.agent_states.get(self.name))

0 commit comments

Comments
 (0)