@@ -400,3 +400,56 @@ Environment Variables & Port Configuration
400400- Add ngrok domains to `ALLOWED_ORIGINS` for external dev access
401401
402402Done. This guide covers the minimal, repeatable steps for adding new tools and flows with token‑efficient prompts and predictable UX.
403+
404+ Conversation Logging (ML Training Data)
405+
406+ The system captures all user transcripts and LLM responses to Convex for ML training and improvement.
407+
408+ **Architecture:**
409+ - **Schema**: `packages/convex/schema.ts` → `conversationLogs` table
410+ - **Convex mutations**: `packages/convex/conversationLogs.ts` → `logConversation`, `updateResponse`
411+ - **Application utility**: `apps/application/src/core/conversationLogger.ts` → fire-and-forget logging functions
412+
413+ **Data Flow:**
414+ 1. `handleTranscription` receives utterance → routes via BAML `b.Route()`
415+ 2. Immediately after routing: `logConversation(userId, sessionId, transcript, route)` creates initial record
416+ 3. Handler processes request → displays response on glasses
417+ 4. Handler calls `updateConversationResponse(userId, sessionId, transcript, response)` to capture formatted output
418+
419+ **LogContext Pattern:**
420+ Handlers that capture responses receive an optional `logContext` parameter:
421+ ```ts
422+ logContext?: { convexUserId: Id<"users">; sessionId: string; transcript: string }
423+ ```
424+
425+ After displaying lines, call:
426+ ```ts
427+ if (logContext) {
428+ const responseText = lines.map((l) => `W: ${l}`).join("\n");
429+ updateConversationResponse(
430+ logContext.convexUserId,
431+ logContext.sessionId,
432+ logContext.transcript,
433+ responseText,
434+ );
435+ }
436+ ```
437+
438+ **Coverage by Route:**
439+ | Route | Initial Log | Response Captured | Notes |
440+ |-------|-------------|-------------------|-------|
441+ | WEATHER | ✓ | ✓ | Weather summary lines |
442+ | MAPS | ✓ | ✓ | Place recommendations |
443+ | WEB_SEARCH | ✓ | ✓ | Search answer lines |
444+ | KNOWLEDGE | ✓ | ✓ | General knowledge answer |
445+ | MEMORY_RECALL | ✓ | ✓ | Synthesized memory lines |
446+ | MEMORY_CAPTURE | ✓ | ✗ | Silent operation (stores to Honcho) |
447+ | PASSTHROUGH | ✓ | ✓ (when hint shown) | Null case for ambient speech |
448+ | NOTE_THIS | ✓ | ✗ | Meta-action, not content response |
449+ | FOLLOW_UP | ✓ | ✗ | Meta-action, not content response |
450+
451+ **Key Points:**
452+ - Use fire-and-forget pattern: `void convexClient.mutation(...)` with `.catch()` for error logging
453+ - Response field captures the formatted text shown on glasses (e.g., `"W: 72°F and sunny"`)
454+ - PASSTHROUGH with no hint = null response (valuable for training router to identify ambient speech)
455+ - Initial log happens in `transcriptionFlow.ts`; response update happens in individual handlers
0 commit comments