Skip to content

Agent Observability Dashboard

Pageapp/(dashboard)/parent-insights/page.tsx → Pipeline tab
APIapp/api/agent-stats/route.ts
Route/parent-insights → Pipeline tab
AccessParent Insights page, fourth tab

What it does

Shows parents a live view of all 9 agents that powered their child's stories — how many times each agent ran, average duration, last used date, and the child's average quiz score. Designed to demonstrate the multi-agent pipeline in a user-facing UI.

Screenshot: Parent-insights-pipelineparent-insights-pipeline


Data source

The GET /api/agent-stats?userId=... endpoint reads from Firestore:

  • users/{uid}/stories — last 50 stories (for SafetyGuardian, StoryWriter, IllustratorAgent, NarratorAgent stats)
  • users/{uid}/adaptations — last 20 adaptations (for StoryAdaptationAgent stats)

Stats for LearningAdvisor, ParentInsights, QuizMaster, and QuizFeedback are derived from story and quiz activity counts.


Response shape

typescript
interface AgentStat {
  agent: string; // e.g. "StoryWriter"
  avgDurationMs: number; // average call duration in ms
  totalCalls: number; // total times this agent ran
  avgScore: number | null; // only set for StoryWriter (avg quiz score)
  totalCost: number; // reserved (always 0 currently)
  lastUsed: string; // ISO timestamp of most recent call
}

interface ObservabilityStats {
  agents: AgentStat[];
  totalStoriesGenerated: number;
  totalQuizzesCompleted: number;
  totalAdaptations: number;
  avgStoryScore: number | null;
}

Agents shown

AgentMetric source
SafetyGuardianStory creation count
StoryWriterStory creation count + avg quiz score
IllustratorAgentStory creation count
NarratorAgentStory creation count
StoryAdaptationAgentAdaptations collection — real durationMs per run

UI

The Pipeline tab renders a card per agent with:

  • Agent name and icon
  • Total calls badge
  • Avg duration (shown in seconds)
  • Last used date (relative, e.g. "2 days ago")
  • Summary totals: total stories, quizzes, adaptations, avg score

Dark/light theme matches the rest of Parent Insights.

Released under the MIT License.