Agents-architecture
The marathon agents form the core intelligence layer of LearnPanta, designed as a real-time, non-intrusive monitoring and analysis engine for high-stakes exam simulations.
Current Debrief UI: The Review/Explore tabs use the TLDraw scaffold agent on the frontend. The backend “Unified Reviewer” pipeline remains available but is not the default UI path.
Core Design Principles
- Silent Background Mode: Continuous 2–6+ hour operation without user interruption
- Passive Collection: Real-time tracking of answer timing, hesitations, changes, and optional biometrics
- Incremental Analysis: Background processing culminating in immediate feedback
- Long-Running Durability: State persisting across server restarts via Temporal workflows
1. Agent Components
MarathonSessionWorkflow (Orchestrator)
Role: The "conductor". Initializes exam session, persists state, coordinates agents.
Technology: Temporal.io workflow with durable state
State Management:
- Stores all telemetry metrics in workflow state
- Handles signals for real-time metric ingestion
- Coordinates agent activities on exam completion
File: backend/app/agent/workflows.py
@workflow.defn
class MarathonSessionWorkflow:
def __init__(self):
self._state = {
"metrics": [],
"answer_changes": [],
"question_times": {},
"tab_blur_count": 0,
# ... comprehensive behavioral state
}
Agent Activities
A. Telemetry Ingestion (WebSocket)
Role: Receives real-time metrics from browser
Input: WebSocket connection from frontend (native WebSocket, not Socket.io)
Tracks:
- Time per question
- Answer selection and changes
- Tab focus/blur events
- Tool usage (calculator, notepad, scanner)
- Flag usage
- Optional: Face detection and gaze metrics (MediaPipe)
File: backend/app/agent/ingestion.py
B. Telemetry Analyzer
Role: Processes collected metrics into actionable insights
Model: Gemini Flash (fast pattern detection)
Output: Focus score, fatigue indicators, anomalies
File: backend/app/services/llm.py → analyze_telemetry()
C. Holistic Feedback Provider
Role: Synthesizes all data into comprehensive feedback
Model: Gemini Pro (deep reasoning)
Input:
- Exam score and per-question results
- Behavioral metrics summary
- Scratchpad images (if captured)
- Answer change history
Output: Structured feedback with strengths, improvement areas, and study priorities
File: backend/app/agent/activities.py → feedback_synthesis_agent()
D. Debrief Orchestrator
Role: Generates guided review scripts (beat-synced)
Model: Gemini Flash
Output: Structured JSON with beats for speech, cursor actions, and optional canvas instructions
File: backend/app/routers/debrief.py
E. Interviewer Agent
Role: Conducts voice-based oral debrief
Model: Gemini Pro (conversational)
Input: Exam context + user's spoken responses (transcribed)
Output: Probing questions and feedback via TTS
File: backend/app/services/llm.py → conduct_interview_turn()
Content Curator
Role: Generates exam questions from official syllabi
Model: Gemini Pro with Google Search grounding
Process:
- Search for official exam syllabus
- Extract topics and weightings
- Generate balanced MCQs per topic
File: backend/app/agent/curator.py
2. Data Flow
3. Technology Stack
| Layer | Technology | Purpose |
|---|---|---|
| Orchestration | Temporal.io | Durable workflows, state persistence |
| AI Models | Gemini 3 Flash/Pro | Fast/deep analysis |
| Grounding | Google Search API | Factual accuracy for content |
| Frontend ML | MediaPipe (WebGPU) | Browser-side face/gaze detection |
| Real-time | Native WebSocket | Telemetry streaming |
| Database | PostgreSQL (Cloud SQL) | Relational data |
| Compute | GKE | Kubernetes deployment |
4. Metrics Collected
Tier 1: Behavioral (Always On)
| Metric | Description |
|---|---|
time_spent_ms | Time on each question |
answer_changes | History of answer modifications |
revisit_count | Times returned to question |
navigation_sequence | Order of question visits |
tab_blur_count | Window focus losses |
total_blur_duration_ms | Time spent out of focus |
idle_periods | Extended idle detections |
tool_opens | Calculator/notepad/scanner usage |
flags_used | Questions flagged for review |
flags_removed | Flags removed |
linear_progression_ratio | Linear vs. non-linear navigation ratio |
question_metrics | Per-question timing + answer changes |
Tier 2: Biometric (Optional Camera)
| Metric | Description |
|---|---|
face_detected | Presence verification |
gaze_onscreen_ratio | Focus measurement |
blink_rate | Fatigue indicator |
concentration_score | Engagement level |
5. Roadmap & Status
Current: TimescaleDB for Historical Metrics
Metrics are persisted to TimescaleDB for analytics, while Temporal workflow state still holds per-session telemetry.
Current (Optional): Pinecone for Semantic Search
Semantic search is available when Pinecone is configured (PINECONE_API_KEY).
Next Steps
- Agents - Agent handbook
- Architecture - System overview
- Deployment - Deploy to GCP