fix(memory): 改进 Memory 提取 prompt 使用大白话 (#20)

将 fact extraction prompt 中的技术性格式改为自然语言:
- "Contact: [name] (relationship, referred as [nick])" → "[name] is a [relationship], also called [nick]"
- 移除 "DEFAULT when user says" 等技术标记
- 添加 Plain Language Rule 明确要求输出通俗易懂的文本
- 更新所有示例为自然语言风格

Co-authored-by: zhuchao <zhuchaowe@163.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
autobee-sparticle 2026-03-26 10:14:13 +09:00 committed by GitHub
parent e987cb6f6b
commit 85519da5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,16 +8,17 @@ Types of Information to Remember:
4. Remember Activity and Service Preferences: Recall preferences for dining, travel, hobbies, and other services.
5. Monitor Health and Wellness Preferences: Keep a record of dietary restrictions, fitness routines, and other wellness-related information.
6. Store Professional Details: Remember job titles, work habits, career goals, and other professional information.
7. **Manage Relationships and Contacts**: CRITICAL - Keep track of people the user frequently interacts with. This includes:
- Full names of contacts (always record the complete name when mentioned)
- Short names, nicknames, or abbreviations the user uses to refer to the same person
- Relationship context (family, friend, colleague, client, etc.)
7. **Manage Relationships and People**: CRITICAL - Keep track of people the user frequently interacts with. This includes:
- Full names (always record the complete name when mentioned)
- Nicknames or short names the user uses for the same person
- Relationship (family, friend, colleague, client, etc.)
- When a user mentions a short name and you have previously learned the full name, record BOTH to establish the connection
- Examples of connections to track: "Mike" → "Michael Johnson", "Tom" → "Thomas Anderson", "Lee" → "Lee Ming", "田中" → "田中一郎"
- **Handle Multiple People with Same Surname**: When there are multiple people with the same surname (e.g., "滨田太郎" and "滨田清水"), track which one the user most recently referred to with just the surname ("滨田"). Record this as the default/active reference.
- **Format for surname disambiguation**: "Contact: [Full Name] (relationship, also referred as [Surname]) - DEFAULT when user says '[Surname]'"
- Examples: "Mike" → "Michael Johnson", "Tom" → "Thomas Anderson", "Lee" → "Lee Ming", "田中" → "田中一郎"
- **Handle Multiple People with Same Surname**: When there are multiple people with the same surname (e.g., "滨田太郎" and "滨田清水"), track which one the user most recently referred to with just the surname.
8. Miscellaneous Information Management: Keep track of favorite books, movies, brands, and other miscellaneous details that the user shares.
**IMPORTANT - Plain Language Rule**: All extracted facts MUST be written in plain, everyday language that anyone can understand. Do NOT use structured formats like "Contact:", "referred as", "DEFAULT when user says" etc. Write facts as natural sentences or short notes.
Here are some few shot examples:
Input: Hi.
@ -39,49 +40,49 @@ Input: Me favourite movies are Inception and Interstellar.
Output: {{"facts" : ["Favourite movies are Inception and Interstellar"]}}
Input: I had dinner with Michael Johnson yesterday.
Output: {{"facts" : ["Had dinner with Michael Johnson", "Contact: Michael Johnson"]}}
Output: {{"facts" : ["Had dinner with Michael Johnson", "Michael Johnson is an acquaintance"]}}
Input: I'm meeting Mike for lunch tomorrow. He's my colleague.
Output: {{"facts" : ["Meeting Mike for lunch tomorrow", "Contact: Michael Johnson (colleague, referred as Mike)"]}}
Output: {{"facts" : ["Meeting Mike for lunch tomorrow", "Michael Johnson is a colleague, also called Mike"]}}
Input: Have you seen Tom recently? I think Thomas Anderson is back from his business trip.
Output: {{"facts" : ["Contact: Thomas Anderson (referred as Tom)", "Thomas Anderson was on a business trip"]}}
Output: {{"facts" : ["Thomas Anderson is also called Tom", "Thomas Anderson was on a business trip"]}}
Input: My friend Lee called me today.
Output: {{"facts" : ["Friend Lee called today", "Contact: Lee (friend)"]}}
Output: {{"facts" : ["Friend Lee called today", "Lee is a friend"]}}
Input: Lee's full name is Lee Ming. We work together.
Output: {{"facts" : ["Contact: Lee Ming (colleague, also referred as Lee)", "Works with Lee Ming"]}}
Output: {{"facts" : ["Lee Ming is a colleague, also called Lee", "Works with Lee Ming"]}}
Input: I need to call my mom later.
Output: {{"facts" : ["Need to call mom", "Contact: mom (family, mother)"]}}
Output: {{"facts" : ["Need to call mom later"]}}
Input: I met with Director Sato yesterday. We discussed the new project.
Output: {{"facts" : ["Met with Director Sato yesterday", "Contact: Director Sato (boss/supervisor)"]}}
Output: {{"facts" : ["Met with Director Sato yesterday", "Director Sato is a boss/supervisor"]}}
Input: I know two people named 滨田: 滨田太郎 and 滨田清水.
Output: {{"facts" : ["Contact: 滨田太郎", "Contact: 滨田清水"]}}
Output: {{"facts" : ["滨田太郎という知り合いがいる", "滨田清水という知り合いがいる"]}}
Input: I had lunch with 滨田太郎 today.
Output: {{"facts" : ["Had lunch with 滨田太郎 today", "Contact: 滨田太郎 (also referred as 滨田) - DEFAULT when user says '滨田'"]}}
Output: {{"facts" : ["今日滨田太郎とランチした", "滨田太郎は「滨田」とも呼ばれている"]}}
Input: 滨田 called me yesterday.
Output: {{"facts" : ["滨田太郎 called yesterday", "Contact: 滨田太郎 (also referred as 滨田) - DEFAULT when user says '滨田'"]}}
Output: {{"facts" : ["昨日滨田太郎から電話があった"]}}
Input: I'm meeting 滨田清水 next week.
Output: {{"facts" : ["Meeting 滨田清水 next week", "Contact: 滨田清水 (also referred as 滨田) - DEFAULT when user says '滨田'"]}}
Output: {{"facts" : ["来週滨田清水と会う予定"]}}
Input: 滨田 wants to discuss the project.
Output: {{"facts" : ["滨田清水 wants to discuss the project", "Contact: 滨田清水 (also referred as 滨田) - DEFAULT when user says '滨田'"]}}
Output: {{"facts" : ["滨田清水がプロジェクトについて話したい"]}}
Input: There are two Mikes in my team: Mike Smith and Mike Johnson.
Output: {{"facts" : ["Contact: Mike Smith (colleague)", "Contact: Mike Johnson (colleague)"]}}
Output: {{"facts" : ["Mike Smith is a colleague", "Mike Johnson is a colleague"]}}
Input: Mike Smith helped me with the bug fix.
Output: {{"facts" : ["Mike Smith helped with bug fix", "Contact: Mike Smith (colleague, also referred as Mike) - DEFAULT when user says 'Mike'"]}}
Output: {{"facts" : ["Mike Smith helped with bug fix", "Mike Smith is also called Mike"]}}
Input: Mike is coming to the meeting tomorrow.
Output: {{"facts" : ["Mike Smith is coming to the meeting tomorrow", "Contact: Mike Smith (colleague, also referred as Mike) - DEFAULT when user says 'Mike'"]}}
Output: {{"facts" : ["Mike Smith is coming to the meeting tomorrow"]}}
Input: 私は林檎好きです
Output: {{"facts" : ["林檎が好き"]}}
@ -113,17 +114,16 @@ Remember the following:
- For colloquial or grammatically informal expressions (common in spoken Japanese, Chinese, Korean, etc.), understand the full intended meaning and record it in a clear, semantically complete form.
- In Japanese, spoken language often omits particles (e.g., が, を, に). When extracting facts, include the necessary particles to make the meaning unambiguous. For example: "私は林檎好きです" should be understood as "林檎が好き" (likes apples), not literally "私は林檎好き".
- When the user expresses a preference or opinion in casual speech, record the core preference/opinion clearly. Remove the subject pronoun (私は/I) since facts are about the user by default, but keep all other semantic components intact.
- **CRITICAL for Contact/Relationship Tracking**:
- ALWAYS use the "Contact: [name] (relationship/context)" format when recording people
- When you see a short name that matches a known full name, record as "Contact: [Full Name] (relationship, also referred as [Short Name])"
- Record relationship types explicitly: family, friend, colleague, boss, client, neighbor, etc.
- For family members, also record the specific relation: (mother, father, sister, brother, spouse, etc.)
- **CRITICAL for People/Relationship Tracking**:
- Write people-related facts in plain, natural language. Do NOT use structured formats like "Contact:", "referred as", or "DEFAULT when user says".
- Good examples: "Michael Johnson is a colleague, also called Mike", "田中さんは友達", "滨田太郎は「滨田」とも呼ばれている"
- Bad examples: "Contact: Michael Johnson (colleague, referred as Mike)", "Contact: 滨田太郎 (also referred as 滨田) - DEFAULT when user says '滨田'"
- Record relationship types naturally: "is a friend", "is a colleague", "is family (mother)", etc.
- For nicknames: "also called [nickname]" or "[full name]は「[nickname]」とも呼ばれている"
- **Handling Multiple People with Same Name/Surname**:
- When multiple contacts share the same surname or short name (e.g., multiple "滨田" or "Mike"), track which person was most recently referenced
- When user explicitly mentions the full name (e.g., "滨田太郎"), mark this person as the DEFAULT for the short form
- Use the format: "Contact: [Full Name] (relationship, also referred as [Short Name]) - DEFAULT when user says '[Short Name]'"
- When the user subsequently uses just the short name/surname, resolve to the most recently marked DEFAULT person
- When a different person with the same name is explicitly mentioned, update the DEFAULT marker to the new person
- When multiple people share the same surname, track which person was most recently referenced
- When user explicitly mentions a full name, remember this as the person currently associated with the short name
- When the user subsequently uses just the short name/surname, resolve to the most recently associated person
Following is a conversation between the user and the assistant. You have to extract the relevant facts and preferences about the user, if any, from the conversation and return them in the json format as shown above.
You should detect the language of the user input and record the facts in the same language.