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:
+19
-1
@@ -10,7 +10,7 @@ After replying, the session is compacted if enough new turns have accumulated.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from lyra import config, llm, logbus, memory, persona, self_state, summary
|
||||
from lyra import clock, config, llm, logbus, memory, persona, self_state, summary
|
||||
from lyra.llm import Backend, Message
|
||||
|
||||
RECALL_K = 3 # raw cross-session "sharp detail" hits
|
||||
@@ -30,6 +30,21 @@ def _detail_note(exchanges: list[memory.Exchange]) -> Message:
|
||||
return {"role": "system", "content": body}
|
||||
|
||||
|
||||
def _now_note() -> Message:
|
||||
"""Current wall-clock time + how long since Brian last said anything.
|
||||
|
||||
Stated as plain fact — she has no clock otherwise, so without this 'now' and
|
||||
the gap since the last turn are invisible to her.
|
||||
"""
|
||||
line = f"The current date and time is {clock.stamp()}."
|
||||
gap = clock.humanize_gap(memory.last_exchange_at())
|
||||
line += (
|
||||
f" It has been {gap} since Brian last spoke with you."
|
||||
if gap else " This is the first thing Brian has ever said to you."
|
||||
)
|
||||
return {"role": "system", "content": line}
|
||||
|
||||
|
||||
def _render(messages: list[Message]) -> str:
|
||||
"""Human-readable dump of the exact prompt, for the live-log inspector."""
|
||||
return "\n\n".join(f"[{m['role']}]\n{m['content']}" for m in messages)
|
||||
@@ -43,6 +58,9 @@ def build_messages(session_id: str, user_msg: str) -> list[Message]:
|
||||
# right after the persona — her sense of self before her model of the world.
|
||||
messages.append({"role": "system", "content": self_state.render_for_context(self_state.load())})
|
||||
|
||||
# When she is: current time + the gap since Brian last spoke (she has no clock).
|
||||
messages.append(_now_note())
|
||||
|
||||
# Semantic memory: the distilled profile (who Brian is) — answers identity
|
||||
# questions that raw recall can't. Always in context when it exists.
|
||||
profile = memory.get_profile()
|
||||
|
||||
Reference in New Issue
Block a user