Lesson 5: Conversation & AI

Goal of this lesson

Walk through the message pipeline step by step, list the intent types and the three routes, and explain review cards, the Chat agent, and Memory.

The pipeline in one picture

1. Save the student's message Shown right away. Not saved in Temporary Chat
2. Shortcuts Answer to an open review card ("yes", "make it 5")? Skill request ("start a pomodoro")? Memory command ("what do you remember?")?
3. Understand the intent Fast-path rules → on-device model → DeepSeek (online)
4. Multiple actions? Points back to earlier messages? "Add A and B" → batch. "Book the first one" → Chat agent
5. Route the intent
change
Reviewed change Review card. Low-risk actions apply now with Undo
question
Read only Answer from local data
chat
Conversation DeepSeek online / local reply offline
6. Save LAFINA's reply With card, sources, and receipts in metadata
7. Speak it (optional) Phone TTS / online voice
Simplified from the chat orchestrator. Each step can finish the turn early with a reply.

Step 3 in detail: understanding the intent

Fast-path parser Deterministic rules. Instant
Scheduling intent, confidence ≥ 0.85, clean title, not Taglish or casual?
yes
Use the rule result
no
Ask the on-device model GGUF via llama.cpp, with a time limit
Online Mode + planner command? DeepSeek structured extraction. Keeps the local result if it fails
validateIntent() Bad output → "chat", which never writes
  • Offline, the installed model reads every scheduling request, not only unclear ones.
  • During a live call, a confident rule result is trusted immediately so the student isn’t kept waiting.
  • Non-scheduling intents (queries, updates, deletes, notes, call replies) never go to the model’s title extractor.

The intent types

GroupIntents
Createcreate_task, create_time_block, create_reminder, create_note, create_alarm
Updateupdate_task, update_time_block, update_note, update_alarm, toggle_alarm, reschedule
Deletedelete_task, delete_time_block, delete_note, delete_alarm
Reminder repliesacknowledge, snooze
Read onlyquery_schedule, query_notes, list_alarms
Conversationchat, out_of_scope

An intent carries slots: title, date, time, endTime, durationMinutes, category, details, snoozeMinutes, confidence, and source.

Step 5 in detail: the three routes

RouteWrites?Which intentsNotes
reviewed_mutationOnly after ConfirmAll create, update, and delete intents, plus acknowledge and snoozeLow-risk ones apply immediately with Undo
read_onlyNeverquery_schedule, query_notes, list_alarmsAnswered from SQLite
conversationNeverchat, out_of_scopeDeepSeek or a local reply
call_context_immediateYesacknowledge, snoozeOnly while a reminder call is ringing, using that call’s identity

Exhaustive by design

The route table is a typed map in code (INTENT_ROUTES). Adding a new intent fails to compile until someone chooses its route, so no intent can accidentally write without review. An unknown value falls back to conversation, which never writes.

Review cards: the lifecycle

Proposal prepared Interpreted fields + any schedule conflict + free-time choices
Student response Tap or say it in chat
edit
Revise "Make it 5 PM instead". Card updates (revision number)
cancel
Cancel Nothing saved
confirm
Confirm Saved in one transaction + operation receipt
  • Revision checks: confirming an outdated version of a card is refused, so you always save what you saw.
  • Receipts: every confirmed operation is recorded in assistant_operation_receipts.
  • Low-risk actions skip the card and offer Undo: completing a task, acknowledging or snoozing a reminder, and pinning or re-categorizing a note.
  • Multi-action: “Add my quiz on Monday and a study block on Sunday” becomes a batch with Confirm All.
  • Conflicts are shown on the card, with free times offered as one-tap choices.
  • Deletes are never prepared from the model’s words alone.

Conversation replies: online vs. offline

OfflineOnline Mode
Small talk (hi, thanks, who made you, what can you do)✅ Varied local replies✅ DeepSeek
Trivia and general knowledge❌ “That question needs Online Mode”✅ DeepSeek, streamed word by word
Questions about your plans✅ From SQLite✅ Chat agent can look things up
If DeepSeek failsn/aLocal reply, labeled “Offline reply”

Privacy rule: the planner snapshot is sent only when the question is about the student’s own plans, notes, or time. A general study question never sends the planner.

The Chat agent (online)

Student asks about their plans "Find me a free hour tomorrow and book review time"
DeepSeek decides to call a tool
Tool runs ON THE PHONE Reads the planner / finds free time / prepares a card. The server only relays
Result goes back to DeepSeek Repeat up to 4 steps
Final answer + at most one review card Saving still needs Confirm
Bounded: at most 4 model steps and 5 tool calls per step.

Memory

ItemDetail
WhatFacts the student shares: preferred name, study hours (“night owl”), goals
Tierscore, preference, episodic
Commands”What do you remember about me?”, “Forget that I’m a morning person”, with Undo
Used forOnline replies, study scheduling, Morning Briefing
GuardPasswords, PINs, OTPs, card numbers, and bank or GCash numbers are never saved
Off switchMemory can be turned off. Temporary Chat saves nothing

Other chat features

  • Temporary Chat: messages and memories are not saved.
  • Ask USTP mode: a dedicated chat that goes straight to handbook Q&A (Lesson 9).
  • Quick Chat / Floating LAFINA: the same rules in a small window over other apps.
  • Chat history sync: chats sync with an account, up to 20 chats per account.

Check yourself

  • List the pipeline steps in order. Where can a turn end early?
  • When does the on-device model run, and when is it skipped?
  • What are the three routes? Which intents become immediate during a ringing call?
  • What prevents confirming an outdated review card?
  • What does the Chat agent’s tool actually run on, and what are its limits?
  • What happens if you ask a trivia question offline?