MCPcopy Create free account
hub / github.com/google/adk-python / _load_agent_state

Method _load_agent_state

src/google/adk/agents/base_agent.py:178–195  ·  view source on GitHub ↗

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 exists; otherwise, None.

(
      self,
      ctx: InvocationContext,
      state_type: Type[AgentState],
  )

Source from the content-addressed store, hash-verified

176 """
177
178 def _load_agent_state(
179 self,
180 ctx: InvocationContext,
181 state_type: Type[AgentState],
182 ) -> Optional[AgentState]:
183 """Loads the agent state from the invocation context.
184
185 Args:
186 ctx: The invocation context.
187 state_type: The type of the agent state.
188
189 Returns:
190 The current state if exists; otherwise, None.
191 """
192 if ctx.agent_states is None or self.name not in ctx.agent_states:
193 return None
194 else:
195 return state_type.model_validate(ctx.agent_states.get(self.name))
196
197 def _create_agent_state_event(
198 self,

Callers 6

_run_async_implMethod · 0.80
_run_async_implMethod · 0.80
_run_async_implMethod · 0.80
_run_async_implMethod · 0.80

Calls 2

model_validateMethod · 0.80
getMethod · 0.45