mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Returns agent state regardless if ctx.is_resumable
This allows state to be passing across agents Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 828557989
This commit is contained in:
committed by
Copybara-Service
parent
744f94f0c8
commit
d6b928bdf7
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user