feat: agent proactively re-engages users on returning sessions

Two complementary changes to reduce conversation cold-start friction:

A. Returning-user re-greeting (backend)
- When WS reconnects to a non-empty conversation and last_message_at is older
  than chat_re_greeting_idle_hours (default 6h), the agent emits a warm
  continuation message that references prior history instead of staying silent.
- Self-debouncing: the AI message updates last_message_at, so reconnects
  within the window will not re-trigger.
- Skipped while profile collection is still pending.

D. Topic suggestion chips (backend + Expo)
- New WS message type topic_suggestions carries 3-4 quick-start chips derived
  from the current memoir stage's empty slots (deterministic, no extra LLM
  cost). Sent alongside opening / re-greeting / resume.
- Expo chat screen renders a horizontally-scrollable chip row above the input
  bar; tapping a chip sends the chip's text as a user message and clears the
  row. Sending any text/voice also clears the chips.
This commit is contained in:
Claude
2026-05-07 15:39:33 +00:00
parent 7617ea902c
commit 55cfbc7f80
14 changed files with 688 additions and 52 deletions

View File

@@ -477,3 +477,26 @@ class ChatOrchestrator:
profile_birth_year=profile_birth_year,
profile_era_place=profile_era_place,
)
async def generate_re_greeting_message(
self,
conversation_id: str,
memoir_state: MemoirStateSchema,
idle_hours: float,
user_profile_context: str = "",
background_voice: str = "default",
occupation: str = "",
profile_birth_year: Optional[int] = None,
profile_era_place: str = "",
) -> List[str]:
"""委托 InterviewAgent 生成老对话回访问候(持久化由调用方负责)。"""
return await self.interview_agent.generate_re_greeting_message(
conversation_id=conversation_id,
memoir_state=memoir_state,
idle_hours=idle_hours,
user_profile_context=user_profile_context,
background_voice=background_voice,
occupation=occupation,
profile_birth_year=profile_birth_year,
profile_era_place=profile_era_place,
)