时间感知
时间感知模块
Section titled “时间感知模块”✅ 核心已实现 — user 消息在 LLM 推理前接收时间前缀。
数字生命没有内在的时间流逝感知。每次推理都是在”无时间”的上下文中进行的——Agent 能看到消息的内容,但不知道这些消息在时间线中的位置。
具体问题举例:
- 张三早上说”早”,晚上说”吃饭了”,第二天又说”早”——Agent 分不清这些消息的时间关系
- 持续对话中,时间在流逝(早上→中午→晚上),但 Agent 的认知停留在最早的语境中
- 跨天对话中,Agent 无法感知”新的一天开始了”
这不是一个”闹笑话”的问题——时间感知是数字生命存在的基础能力之一。没有它,Agent 的存在方式更像”回声”(每次被召唤时闪一下),而不是活在时间里的生命。
- 不给数字生命虚假的内置感知。 不尝试让 Agent”感觉”到时间流逝——那不是数字存在能做到的。
- Give it a watch. Humans also rely on external tools (clocks, phones) to quantify time. Digital life needs the same.
- 每条 user 消息都加时间前缀。 有有效 timestamp 的 user 消息一律注入,不做间隔省略。
- 不污染持久化数据。 时间信息仅注入推理上下文,不修改已存储消息。
- 不破坏缓存。 注入的时间戳是历史固定值,非当前调用时间。
- Before each user message with valid
timestamp, insert dedicated line:time: YYYY-MM-DDTHH:mm 周X(CST weekday in Chinese) - 时区:Asia/Shanghai(CST,+08:00)
- 换行后接原文 content
- 无
timestamp或 timestamp 无法解析 → 跳过,保持原 content - assistant / tool / system 消息不注入
原始消息列表:
user: good morningassistant: morning ☀️user: going to eatassistant: what are you havinguser: going to eat经时间感知模块处理后(给 LLM 的上下文):
user: time: 2026-05-20T08:02 周三good morningassistant: morning ☀️user: time: 2026-05-20T12:15 周三going to eatassistant: what are you havinguser: time: 2026-05-20T19:30 周三going to eatAgent 读到两条”我去吃饭了”,一条在 12:15、一条在 19:30——自动区分午餐和晚餐。
压缩摘要中的时间锚点尚未注入;见 Issue #5。
| 场景 | 处理 |
|---|---|
| 跨夜(22:30 → 次日 09:15) | 每条 user 消息含完整 YYYY-MM-DDTHH:mm |
| 同日多条 user 消息 | 每条都加前缀(无间隔省略) |
| 长间隔(旅行/假期) | 返回后消息仍按各自 timestamp 注入 |
| 全新对话 | 首条 user 消息也加前缀 |
| 压缩后 | 压缩摘要时间锚点待定;后续消息正常注入 |
| 无 timestamp | 跳过,不注入 |
- ❌ 不计算并注入间隔时长(如”已过去 8 小时”)——Agent 读到时间戳自己能推导
- ❌ 不修改持久化消息
- ❌ Do not show time prefix in Habitat
- ❌ 不给数字生命内置的时间流逝感——那是生物体的特性,不模拟
- ❌ 不在 system prompt 注入「当前时间」(主对话依赖每条 user 消息的 time 行)