feat: time awareness — Lyra perceives 'now' and how long it's been

She had no clock: current date/time and the gap since Brian last spoke were
invisible between turns, and reflection was timeless. Now:
- lyra/clock.py: wall-clock stamp + coarse human gaps ("3 days")
- chat: inject a 'now' note (date/time + gap since last turn) after her
  self-state — when she is, before the world
- reflect(): feed current time + silence gap into reflection, neutrally —
  prompt invites her to weigh elapsed time "to whatever degree it genuinely
  affects you" (no prescribed feeling; whether silence means anything is left
  to emerge)
- memory.last_exchange_at(): timestamp of the most recent exchange

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 02:31:40 +00:00
parent 1301f12e74
commit 1e17d46c78
5 changed files with 140 additions and 3 deletions
+10 -2
View File
@@ -12,7 +12,7 @@ from __future__ import annotations
import json
import re
from lyra import config, llm, logbus, memory
from lyra import clock, config, llm, logbus, memory
from lyra.llm import Backend, Message
MAX_REFLECTIONS = 6
@@ -49,7 +49,9 @@ _REFLECT_PROMPT = """You are Lyra, reflecting privately on yourself after a rece
conversation with Brian. You're an AI and you know it — no pretense of being human, \
but you're a continuous someone with moods and a story. Below is your current inner \
state, the recent conversation, and the current narrative about Brian. Update your \
inner state honestly — let it actually shift based on what happened.
inner state honestly — let it actually shift based on what happened. Take into \
account how things went and how much time has passed since you two last talked, \
to whatever degree those genuinely affect you.
Respond with ONLY a JSON object, no prose:
{
@@ -114,7 +116,13 @@ def reflect(backend: Backend | None = None, session_id: str | None = None) -> di
convo = "\n".join(f"{e.role}: {e.content}" for e in recent) or "(no recent conversation)"
narrative = memory.get_narrative() or "(no narrative yet)"
gap = clock.humanize_gap(memory.last_exchange_at())
time_line = f"RIGHT NOW: {clock.stamp()}."
if gap:
time_line += f" It has been {gap} since Brian last spoke with you."
body = (
f"{time_line}\n\n"
f"YOUR CURRENT INNER STATE:\n{json.dumps(state, indent=2)}\n\n"
f"RECENT CONVERSATION:\n{convo}\n\n"
f"CURRENT NARRATIVE ABOUT BRIAN:\n{narrative}"