""" longitudinal_demo.py — demo longitudinal journey from baseline to expert agent support. """ import sys, os; sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from agent.memory import LifeStackMemory from core.life_state import LifeMetrics from intake.simperson import SimPerson class LongitudinalDemo: def __init__(self): self.memory = LifeStackMemory(silent=True) # Pre-loaded persona: startup-lead demo profile self.person = SimPerson( name="Jordan", openness=0.4, conscientiousness=0.9, extraversion=0.7, agreeableness=0.25, neuroticism=0.8 ) def pre_seed_arjun(self): """Pre-seeds demo high-reward precedents into ChromaDB.""" # Note: Session 1 (0.41) isn't stored as it's below the 0.5 reward threshold # defined in memory.py, which is correct (we only learn from SUCCESS). # Memory from Week 2 (Relationship success) self.memory.store_trajectory( conflict_title="Partner upset about dinner", route_taken="communicate(relationships)", total_reward=0.68, metrics_diff_str="romantic:+10.0, stress_level:-5.0", reasoning="This profile responds better to upfront communication about work delays than reactive apologies." ) # Memory from a general work win self.memory.store_trajectory( conflict_title="Project Overload", route_taken="negotiate(career) -> delegate(career)", total_reward=0.75, metrics_diff_str="workload:-20.0, stress_level:-15.0", reasoning="For startup executives, aggressive negotiation of deliverables works better than resting alone, which leaves work pending." ) def show_longitudinal_comparison(self) -> str: """Returns the HTML for the longitudinal journey tab.""" return """

STARTUP LEAD LIFESTACK JOURNEY

3 weeks of self-improving AI support
WEEK 1 — BASELINE GENERIC AGENT
Crisis: 3 new startup projects assigned
Agent suggested: Rest (Breather)
Result: Reward 0.41 — stress down, but career crisis unresolved
Agent learned: Rest alone doesn't fix mission-critical career crises for this profile.
WEEK 2 — PATTERN RECOGNITION 1 PRECEDENT
Crisis: Partner upset about cancelled dinner
Agent suggested: Communicate (warm tone)
Result: Reward 0.68 — relationship preserved
Agent learned: this profile needs proactive communication, not reactive apologies.
WEEK 3 — PERSONALISED SUPPORT EXPERT AGENT
Crisis: Friday 6PM Compound Crisis
Agent suggested: Negotiate + Communicate FIRST
Result: Reward 0.87 — best performance yet
Agent Quote: "Last time you cancelled plans without warning, it took 4 days to recover. This time, communicate first."
Longitudinal Growth
0.41 → 0.87
(+112% Performance increase)
Same conflict scenario. Same agent. 3 weeks of context-aware learning.
""" def main(): demo = LongitudinalDemo() demo.pre_seed_arjun() print("✅ Demo precedents pre-seeded into ChromaDB.") if __name__ == "__main__": main()