@@ -531,6 +531,13 @@ async def _run_agent_cycle_inner(self, agent: AgentState, suffering: SufferingSt
531531 await self ._hooks .emit (
532532 "goal_abandoned" , agent_id = agent .agent_id , goal_id = active_goal ["goal_id" ]
533533 )
534+ # D1: abandonment is part of the agent's story too (success path
535+ # already records narrative; this closes the gap).
536+ self ._identity .update_narrative (
537+ agent .agent_id ,
538+ active_goal ["objective" ],
539+ f"Abandoned: { outcome .summary } " ,
540+ )
534541 if persona is not None :
535542 persona .update_from_event ("goal_abandoned" , outcome .summary )
536543 self ._specialization .record (
@@ -567,6 +574,9 @@ async def _run_agent_cycle_inner(self, agent: AgentState, suffering: SufferingSt
567574 if self ._economy_enabled and self ._ctx .world is not None :
568575 world_status = self ._ctx .world .get_status (agent .agent_id )
569576
577+ # D1: feed structured stats into goal generation (economy-gated).
578+ agent_stats = self ._stats .get (agent .agent_id ) if self ._stats else None
579+
570580 notepad_content = self ._notepad .get_tail (agent .agent_id )
571581
572582 pending_a2a = await self ._a2a_store .get_pending_requests (agent .agent_id , limit = 3 )
@@ -593,6 +603,7 @@ async def _run_agent_cycle_inner(self, agent: AgentState, suffering: SufferingSt
593603 world_status = world_status ,
594604 notepad_content = notepad_content ,
595605 economy_enabled = self ._economy_enabled ,
606+ agent_stats = agent_stats ,
596607 )
597608 result_goal = await self ._goal_strategy .generate_goal (ctx )
598609 if result_goal is not None :
@@ -621,6 +632,7 @@ async def _run_agent_cycle_inner(self, agent: AgentState, suffering: SufferingSt
621632 world_status = world_status ,
622633 notepad_content = notepad_content ,
623634 persona = persona ,
635+ stats = agent_stats ,
624636 )
625637 goal = await existence .generate_goal (suffering , peers , nudges )
626638
@@ -733,6 +745,30 @@ async def _process_life_events(self, agents: list[AgentState]) -> None:
733745 self ._cycle_count ,
734746 )
735747
748+ # D1: feed the chosen outcome back into the suffering system.
749+ suffering = self ._get_suffering (agent .agent_id )
750+ if outcome .stressor_added :
751+ chosen = next ((c for c in event .choices if c .id == outcome .choice_id ), None )
752+ severity = chosen .stressor_severity if chosen else None
753+ suffering .add_stressor (
754+ outcome .stressor_added ,
755+ description = f"Triggered by life event: { event .name } " ,
756+ observable_condition = "Resolved by a positive life event or recovery" ,
757+ initial_severity = severity ,
758+ )
759+ if outcome .stressor_resolved :
760+ suffering .resolve (
761+ outcome .stressor_resolved ,
762+ note = f"Relieved by life event: { event .name } " ,
763+ )
764+
765+ # D1: record the event in the agent's narrative (not just memory).
766+ self ._identity .update_narrative (
767+ agent .agent_id ,
768+ f"Life event: { event .name } " ,
769+ outcome .choice_description ,
770+ )
771+
736772 session_id = f"sess-{ agent .agent_id } "
737773 await self ._emit (
738774 agent .agent_id ,
@@ -743,6 +779,8 @@ async def _process_life_events(self, agents: list[AgentState]) -> None:
743779 "choice" : outcome .choice_description ,
744780 "stat_changes" : outcome .stat_changes ,
745781 "follow_ups" : outcome .follow_ups_triggered ,
782+ "stressor_added" : outcome .stressor_added ,
783+ "stressor_resolved" : outcome .stressor_resolved ,
746784 },
747785 )
748786
0 commit comments