chat-memory

对话历史长期记忆查询工具。当用户询问之前/上次/以前谈过的内容,或需要调取特定时间段的对话记录时使用。提供时序查询(按今天/本周/本月/全部)和结果筛选能力。此技能不主动注入历史——Agent 通过此技能的工具描述自行判断调用时机。

SKILL.md

GitHub

Chat Memory — 对话长期记忆

功能定位

查询本公司(company_id)下的历史对话记录。

工具

chat_memory_list

描述:查询历史对话记录。当用户提到"之前""上次""以前"等时间相关词汇, 或询问过去讨论过的内容时使用此工具。

参数:

  • company_id (必填): 当前会话的公司 ID。从 system prompt 的 Trade Context 段读取;不要让用户输入。
  • time_range: 时间范围枚举值(与 recent_days/recent_months 互斥)
    • "today" — 今天(00:00 → 现在)
    • "yesterday" — 昨天(昨天 00:00 → 今天 00:00)
    • "this_week" — 本周(本周一 00:00 → 现在)
    • "last_week" — 上周(上周一 00:00 → 本周一 00:00)
    • "this_month" — 本月(本月 1 号 00:00 → 现在)
    • "last_month" — 上月(上月 1 号 00:00 → 本月 1 号 00:00)
    • "this_year" — 今年(今年 1 月 1 日 00:00 → 现在)
    • "last_year" — 去年(去年 1 月 1 日 00:00 → 今年 1 月 1 日 00:00)
    • "all" — 全部历史(默认)
  • recent_days: 可选,过去 N 天(含今天)。用于枚举表达不了的相对区间("上上周三" → 14)。
  • recent_months: 可选,过去 N 个月(含本月)。用于 "前几个月" 这类模糊词。
  • limit: 最大返回消息数,默认 20

返回值:

{
  "company_id": 1,
  "time_range": "last_week",
  "recent_days": null,
  "recent_months": null,
  "count": 5,
  "rows": [
    {"id": 123, "query": "...", "response": "...", "created_at": "2026-05-10T14:32:00"}
  ]
}

使用示例

用户:"你上次推荐的那个供应商叫什么名字?"

→ 调用 chat_memory_list(company_id=1, time_range="all", limit=20) → 从结果中找到与供应商相关的对话 → 回答用户问题

用户:"我们这周谈过哪些客户?"

→ 调用 chat_memory_list(company_id=1, time_range="this_week", limit=20) → 汇总结果中涉及客户的对话 → 回答用户问题

用户:"上礼拜三跟你说过那个德国客户叫什么来着?"

→ 枚举表达不了,用 recent_days=14(覆盖"上上周三"到今天): → chat_memory_list(company_id=1, recent_days=14, limit=20)

用户:"前几个月有没有谈到 XXX?"

→ 模糊时间词,用 recent_months=3: → chat_memory_list(company_id=1, recent_months=3, limit=20)