Temporal Agent
Purpose
The Temporal Agent performs statistical analysis across all time-series inputs, computing summary metrics and identifying directional trends. Its output constitutes the quantitative foundation of the pipeline -- pattern detection, correlation analysis, and narrative generation all depend on the statistics and trend assessments produced at this stage.
Value Proposition
- Trend detection -- classifies each metric as increasing, decreasing, or stable over the observed period
- Anomaly surfacing -- identifies significant deviations from established baselines (spikes, drops, sustained shifts)
- Gap analysis -- flags periods of missing data, which may themselves carry behavioral significance (e.g., consistent absence of weekend check-ins)
- Statistical baseline -- provides the computed means, extremes, and volatility measures that all downstream agents reference
Processing Model
The temporal agent employs dual-mode processing:
-
Algorithmic analysis executes first -- deterministic computation producing reproducible results:
- Statistical measures: mean, min, max, standard deviation
- Trend classification: increasing, decreasing, or stable
- Volatility assessment: consistency vs. erratic variation
-
Agent enhancement layers semantic interpretation:
- Contextualizes statistical results ("stress peaked midweek, a pattern commonly associated with workload accumulation")
- Identifies implications of data gaps
- Generates human-readable insight strings for downstream consumption
Detection Categories
| Category | Examples |
|---|---|
| Upward trends | "Stress has increased steadily over the past 5 days" |
| Downward trends | "Energy is declining, currently averaging 3.2/10" |
| Stability | "Mood has remained consistent at 4/5 throughout the period" |
| Anomalies | "Sleep quality dropped significantly on Wednesday" |
| Data gaps | "No check-ins recorded on weekends, suggesting possible routine disruption" |
| Recovery signals | "Stress decreased 30% compared to the prior week" |
Pipeline Position
The temporal agent executes as Step 1 in the pipeline. Its output -- statistics and trend assessments -- feeds directly into pattern detection and correlation analysis. Skipping this step is rare and results in significantly reduced context for all downstream agents.
Example Output
For a dataset spanning 7 days with stress, sleep, and energy metrics:
{
"summary": "Stress levels exhibit an upward trend over the observed period with peak values midweek. Energy remains consistently low with minimal variation.",
"insights": [
"Stress levels show a sustained upward trend over the last 5 days, peaking on Wednesday",
"Energy has remained consistently low (averaging 3.2/10) with minimal daily variation",
"Weekend check-ins are absent, which may indicate routine disruption or reduced engagement"
],
"stats": [
{
"id": "stress_level",
"mean": 3.7,
"min": 2.0,
"max": 5.0,
"trend": "increasing"
},
{
"id": "energy",
"mean": 3.2,
"min": 2.0,
"max": 5.0,
"trend": "stable"
}
]
}
Technical Reference
Identifiers
| Property | Value |
|---|---|
| Registry ID | reasoning-engine-temporal-summary-agent |
| Profile ID | reasoning-temporal-summary |
| Code | src/mastra/agents/reasoning-engine/core/temporal.ts |
| Accessor | getTemporalSummaryAgent() |
Input Schema
{
"series": [
{
"id": "stress_level",
"data": [
{ "t": "2025-01-01T00:00:00Z", "v": 3.5 },
{ "t": "2025-01-02T00:00:00Z", "v": 4.0 }
]
}
]
}
Output Schema
{
"summary": "string - Narrative summary of temporal patterns",
"insights": ["string[] - Individual temporal observations"],
"stats": [
{
"id": "string - Metric identifier",
"mean": "number",
"min": "number",
"max": "number",
"trend": "increasing | decreasing | stable"
}
]
}
Default Prompt
"You are a wellbeing data analyst summarizing temporal patterns from user check-ins. Input data comes from daily wellbeing check-ins tracking stress, mood, sleep, energy, and menstrual cycle symptoms. Each series has timestamps (t) and numeric values (v) representing aggregated daily metrics. Identify meaningful temporal patterns, note gaps in data, highlight concerning trends, and recognize positive patterns. Return strictly JSON:
{ summary: string, insights: string[], stats: Array<{id, mean, min, max, trend}> }."
Configuration
Update the prompt via Admin tools, SQL, or API targeting the reasoning-temporal-summary profile.