@@ -38,16 +38,16 @@ async def _on_activate(self) -> None:
3838 if not has_state :
3939 # Initialize state with default values if it doesn't exist
4040 logger .info (f"Initializing state for { self .actor_id } " )
41- self .state = AgentActorState (overall_status = AgentStatus .IDLE )
41+ self .agent_state = AgentActorState (status = AgentStatus .IDLE )
4242 await self ._state_manager .set_state (
43- self .agent_state_key , self .state .model_dump ()
43+ self .agent_state_key , self .agent_state .model_dump ()
4444 )
4545 await self ._state_manager .save_state ()
4646 else :
4747 # Load existing state
4848 logger .info (f"Loading existing state for { self .actor_id } " )
4949 logger .debug (f"Existing state for { self .actor_id } : { state_data } " )
50- self .state = AgentActorState (** state_data )
50+ self .agent_state = AgentActorState (** state_data )
5151
5252 async def _on_deactivate (self ) -> None :
5353 """
@@ -61,9 +61,9 @@ async def set_status(self, status: AgentStatus) -> None:
6161 """
6262 Sets the current operational status of the agent and saves the state.
6363 """
64- self .state . overall_status = status
64+ self .agent_state . status = status
6565 await self ._state_manager .set_state (
66- self .agent_state_key , self .state .model_dump ()
66+ self .agent_state_key , self .agent_state .model_dump ()
6767 )
6868 await self ._state_manager .save_state ()
6969
@@ -101,11 +101,11 @@ async def invoke_task(self, task: Optional[str] = None) -> str:
101101 input = task_entry_input ,
102102 status = AgentTaskStatus .IN_PROGRESS ,
103103 )
104- self .state .task_history .append (task_entry )
104+ self .agent_state .task_history .append (task_entry )
105105
106106 # Save initial task state with IN_PROGRESS status
107107 await self ._state_manager .set_state (
108- self .agent_state_key , self .state .model_dump ()
108+ self .agent_state_key , self .agent_state .model_dump ()
109109 )
110110 await self ._state_manager .save_state ()
111111
@@ -134,7 +134,7 @@ async def invoke_task(self, task: Optional[str] = None) -> str:
134134 finally :
135135 # Ensure the final state of the task is saved
136136 await self ._state_manager .set_state (
137- self .agent_state_key , self .state .model_dump ()
137+ self .agent_state_key , self .agent_state .model_dump ()
138138 )
139139 await self ._state_manager .save_state ()
140140 # Revert the agent's status to idle
@@ -152,12 +152,12 @@ async def add_message(self, message: Union[AgentActorMessage, dict]) -> None:
152152 message = AgentActorMessage (** message )
153153
154154 # Add the new message to the state
155- self .state .messages .append (message )
156- self .state .message_count += 1
155+ self .agent_state .messages .append (message )
156+ self .agent_state .message_count += 1
157157
158158 # Save state back to Dapr
159159 await self ._state_manager .set_state (
160- self .agent_state_key , self .state .model_dump ()
160+ self .agent_state_key , self .agent_state .model_dump ()
161161 )
162162 await self ._state_manager .save_state ()
163163
@@ -178,7 +178,6 @@ async def get_messages(self) -> List[dict]:
178178 # Return the list of messages as dictionaries (timestamp will be automatically serialized to ISO format)
179179 return [message .model_dump () for message in state .messages ]
180180 except ValidationError as e :
181- # Handle validation errors
182181 print (f"Validation error: { e } " )
183182 return []
184183 return []
0 commit comments