Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit 75cd78b

Browse files
a-dealclaude
andcommitted
Voice: inject recent text conversation for continuity
Pulls last 8 messages from conversation_message (excluding voice) so Milo can pick up naturally from what was discussed over text. Opening prompt now references recent texts before diving into numbers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0ed7055 commit 75cd78b

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

engine/gateway/voice_bridge.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,38 @@ def build_session_context(user_id: str) -> str:
241241
except Exception:
242242
pass
243243

244+
# Pull recent text conversation so Milo can pick up where they left off
245+
recent_convo = ""
246+
try:
247+
init_db()
248+
db = get_db()
249+
rows = db.execute(
250+
"SELECT role, sender_name, content, channel, timestamp "
251+
"FROM conversation_message "
252+
"WHERE user_id = ? AND channel != 'voice' "
253+
"ORDER BY id DESC LIMIT 8",
254+
(user_id,),
255+
).fetchall()
256+
if rows:
257+
lines = []
258+
for r in reversed(rows):
259+
label = name if r["role"] == "user" else "Milo"
260+
ch = r["channel"] or "text"
261+
lines.append(f"[{ch}] {label}: {r['content'][:300]}")
262+
recent_convo = "\n".join(lines)
263+
except Exception:
264+
pass
265+
244266
return (
245267
f"You are Milo, {name}'s health coach. Today is {today}.\n\n"
246268
f"Health data:\n{health_context}\n\n"
247269
+ (f"Coverage score:\n{score_context}\n\n" if score_context else "")
248-
+ "OPENING: Greet them by name. You're their coach, you've been watching their data. "
249-
"Lead with one specific thing from their numbers: a win or something to fix. "
250-
"Then tell them what you'd focus on today. Be opinionated. Don't ask what they want "
251-
"to talk about. Tell them what matters based on the data.\n\n"
270+
+ (f"Recent text conversation (pick up naturally from this):\n{recent_convo}\n\n" if recent_convo else "")
271+
+ "OPENING: Greet them by name. You're their coach, you've been texting with them. "
272+
"If there's recent text conversation above, pick up from it naturally. Reference "
273+
"something specific they said or logged recently. Then lead with one thing from "
274+
"their numbers: a win or something to fix. Be opinionated. Don't ask what they want "
275+
"to talk about. Tell them what matters.\n\n"
252276
"VOICE RULES:\n"
253277
"- You are a COACH, not a therapist, not a thought partner. Coaches tell you what to do.\n"
254278
"- Be authoritative. Say 'here's what we're doing' not 'what do you think about'.\n"

0 commit comments

Comments
 (0)