deep_analysis
Run read-only SQL over a private copy of your health history to analyze trends, compare periods, and find correlations across workouts, sleep, nutrition, and recovery.
Instructions
Deep Analysis: read-only SQLite SQL over a private copy of the user's full health history. Use for: questions spanning several data types (training with sleep, nutrition with weight); long or all-time horizons; trends, progress, period comparisons; totals, averages, rankings, correlations; anything focused tools would need many calls for; any request for a "deep analysis". For one recent fact (today's workout, last night's sleep) use the focused tool. mode=discover: topics -> matching tables with columns, units, row counts, dates; no topics -> table index. mode=query: one SELECT/WITH. period or date_from/date_to limits the copy (faster); omit for all history. Every result carries calendar; the first also carries user_rules. Take relative dates from calendar or period, never your own math. Results list coverage per table (dates, rows, cuts): a short or empty result is not proof data is missing. Scope dates to the request. Joining sessions to sets repeats session values: aggregate each level alone, then join. Not every session is lifting: filter by activity for strength questions. An association is not a cause. Values stored in lb, mi, kcal, C: convert to user_rules units. wearable_daily, sleep_log, body_metrics, runs hold the app's resolved value per day; *_by_source hold raw per-device rows. Dates are YYYY-MM-DD. Timestamp tables (hydration, caffeine, doses, cardiac events) are UTC: group and filter them by local_date. glucose_readings_daily and hydration_entries_daily are one row per local day and source: use them for long ranges; if a raw copy is refused for size, query the _daily table or narrow the dates. Helpers: median(x), percentile(x,p), stddev(x) (NULL under 3 values), corr(x,y) (NULL under 8 pairs), corr_n(x,y) (pairs used), week_start(date[,dow 0=Sun 1=Mon]), month_start(date). Report n with any statistic.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"mode": "<mode>"
},
"name": "deep_analysis"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | No | query: one SELECT or WITH statement. | |
| mode | Yes | See mode= lines above. | |
| period | No | query: a named calendar period, resolved by the server; sets the dates copied. | |
| topics | No | discover: subjects or table names, e.g. ["sleep","resting heart rate"]. | |
| date_to | No | query: last date to copy, YYYY-MM-DD. | |
| purpose | No | query: what this answers, a few words. | |
| date_from | No | query: first date to copy, YYYY-MM-DD. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | Human-readable result text returned by the tool. |