Returns an event with current agent state set in the invocation context. Args: ctx: The invocation context. Returns: An event with the current agent state set in the invocation context.
(
self,
ctx: InvocationContext,
)
| 195 | return state_type.model_validate(ctx.agent_states.get(self.name)) |
| 196 | |
| 197 | def _create_agent_state_event( |
| 198 | self, |
| 199 | ctx: InvocationContext, |
| 200 | ) -> Event: |
| 201 | """Returns an event with current agent state set in the invocation context. |
| 202 | |
| 203 | Args: |
| 204 | ctx: The invocation context. |
| 205 | |
| 206 | Returns: |
| 207 | An event with the current agent state set in the invocation context. |
| 208 | """ |
| 209 | event_actions = EventActions() |
| 210 | if (agent_state := ctx.agent_states.get(self.name)) is not None: |
| 211 | event_actions.agent_state = agent_state |
| 212 | if ctx.end_of_agents.get(self.name): |
| 213 | event_actions.end_of_agent = True |
| 214 | return Event( |
| 215 | invocation_id=ctx.invocation_id, |
| 216 | author=self.name, |
| 217 | branch=ctx.branch, |
| 218 | actions=event_actions, |
| 219 | ) |
| 220 | |
| 221 | def clone( |
| 222 | self: SelfAgent, update: Mapping[str, Any] | None = None |