YouOS Architecture

Overview

YouOS is a retrieval-augmented generation (RAG) system that drafts email replies in the user's personal style. It combines full-text search, semantic embeddings, persona modeling, an on-device fine-tuned model, and continuous learning.

Components

Ingestion (app/ingestion/)

Each source produces: - documents — the raw source material - chunks — retrieval-sized text segments - reply_pairs — inbound message + user's reply pairs

Retrieval (app/retrieval/)

Generation (app/generation/)

Warm model server (app/core/model_server.py)

Evaluation (app/evaluation/)

Autoresearch (app/autoresearch/)

Autonomous triage (app/agent/) — opt-in

Background loop that sweeps unread inbox, filters noise, and queues drafts for review. Never auto-sends.

The /triage page shows the pending queue (Save edits, Push to Gmail Drafts, Copy, Mark sent, Dismiss with optional categorical reason, Save as training pair), surface-for-review collapsibles, and Recent activity. Push to Gmail Drafts (app/ingestion/gmail_write.py) creates a real Gmail Draft on the original thread via the configured backend — all three implemented: gog (Phase 2.1, shells out to gog CLI), gws (Phase 2.2, shells out to Google's gws CLI), native (Phase 2.3, googleapiclient + gmail.compose scope). Dismissals carry an optional categorical reason (noise / wrong_sender / wrong_content / already_handled / other) aggregated by GET /api/agent/dismissal_stats. noise dismissals feed agent.skip_senders (manual via /api/agent/skip_senders/promote or automatic via agent.auto_promote_skip_senders); wrong_content dismissals can be saved as feedback pairs (POST /api/agent/pending/{id}/save_as_feedback_pair) that flow into the LoRA training pipeline.

All seven agent.* flags (enabled, interval_minutes, accounts, window, limit, threshold, notify_macos, standing_instructions, skip_senders, daily_draft_cap, strict_local) are toggleable via /settings or youos config set.

Web UI (templates/)

Data flow

Gmail / Docs / WhatsApp ─► Ingestion ─► SQLite DB
   (gog / gws / native)                    │
                                  FTS5 + Embeddings
                                           │
Inbound email ─► Retrieval ─► Generation ─► Draft
                              (local model,    │
                               warm server)    │
                                       User edits draft
                                           │
                                   Feedback pair saved
                                           │
                            Export JSONL ─► LoRA fine-tune
                                           │
                            Autoresearch ─► Config optimization

Database

SQLite with FTS5 virtual tables for full-text search. Schema in docs/schema.sql.

Key tables: documents, chunks, reply_pairs, feedback_pairs, benchmark_cases, eval_runs, sender_profiles, ingest_runs, facts, agent_pending_drafts, agent_audit.