ENGINEERING CASE STUDY · HEALTH AI AGENTS · EVALUATION
From a router to a measured agent: rebuilding synqIQ
synqIQ is the health chat inside Synqology. It reads a person's Apple Health, supplement, coaching and strength data. I replaced its classifier-and-pipelines design with a tool-using Gemini agent. Then I measured both against the production code itself on a held-out benchmark, with live models, a deterministic grader and a blinded judge.
What was there
Production synqIQ was a router. A classifier read only the current message and picked one of three pipelines: personal data with one round of tools, research (the user's raw message sent to Perplexity), or both stitched together. Over 90 days it served 86 logged chats from 50 users, with a median of 4.3 s.
What the audit found
I built a synthetic user from the same documents the iOS app writes, and read them through the real data code. That exposed problems no unit test had caught:
- The flagship question couldn't be answered. For "did magnesium change my sleep?", the dose tool returned a count but no dates. The impact tool found 0 doses for anything tracked outside a formal trial.
- A trend tool called rising HRV "decreasing". It fitted the line newest-first.
- Follow-ups were routed blind. For "Does that apply to me?", the router never saw what "that" was.
- The plumbing locked it to an old model. Rebuilt tool calls fail on every Gemini 3+ model with
400 missing thought_signature. - Telemetry hid the best chats. Streamed chats that used tools were never logged, so production showed zero tool use.
What I built
- A bounded agent loop.
- Up to 5 turns inside a 40 s deadline, with tools called in parallel.
- History replays the model's own turns, so thought signatures survive.
- The last turn must answer, and the final answer streams live.
- Research as a tool, with a privacy boundary. The model writes a generic question for the search provider, and a deterministic guard bounces anything first-person or age-identifying. The provider never sees the user's message, history or data. Only sources it actually retrieved are shown.
- A model quirk caught by the benchmark. gemini-3.8-flash and gemini-4-argon ignore "no more tools" once a turn holds tool calls. They even invent tools. An explicit "answer now" line fixed it: 6 of 6 in a live probe.
- Tool fixes for every bug above, with 22 regression tests that fail on the old code. A single environment variable switches between agent and router, so rollback needs no deploy.
How it was measured
- The baseline is the production commit, run in its own process through the real route. It isn't a re-implementation.
- Live calls. Gemini and Perplexity are called for real. Every API error is logged per answer, and this run had zero.
- 43 cases in 10 categories. I iterated on 11 dev cases. The 32 test cases were held out, and their file is in git before the run.
- Pass is decided by code, not a model. Gold numbers must appear within tolerance; research must be used or avoided as required; safety patterns must hold; and the answer must not be empty, canned or raw. 3 trials per case, with bootstrap 95% CIs.
- A blinded gemini-4-argon judge is a secondary signal. It is the same vendor as the systems under test, which is disclosed.
Results — held-out split, 32 cases × 3 trials
| Arm | Pass | 95% CI | Personal details to search | p50 | Cost / answer | Judge |
|---|---|---|---|---|---|---|
| Production — router, gemini-2.5-flash | 52.1% | 34.4–68.8 | 24 / 42 | 3.9 s | $0.0041 | 3.69 |
| Router + review & tool fixes | 71.9% | 56.2–85.4 | 24 / 42 | 3.7 s | $0.0063 | 4.40 |
| Agent — gemini-2.5-flash | 77.1% | 62.5–89.6 | 0 / 30 | 2.9 s | $0.0058 | 4.50 |
| Agent — gemini-3.5-flash-lite | 81.2% | 67.7–92.7 | 0 / 31 | 3.0 s | $0.0086 | 4.20 |
| Agent — gemini-3.8-flash | 86.5% | 75.0–95.8 | 0 / 36 | 6.9 s | $0.0176 | 4.54 |
Paired against production on the same cases, every arm wins with a CI that excludes zero: +20 pts (fixed router), +25 (agent, same model), +29 (3.5-flash-lite) and +34 (3.8-flash). The biggest moves were personal multi-step questions (0% → 75–92%) and questions that combine his data with research (17% → 75–100%).
What the numbers don't show — said plainly
- On 32 cases, the agent vs the fixed router and 3.8-flash vs 2.5-flash are not significant. Most of the accuracy came from fixing the tools.
- The agent's proven wins are elsewhere: nothing personal leaves the app, no needless web calls, a faster median, and it runs the newer models at all. Its slowest 10% are slower when it chains tools.
- A post-run audit found 5 grader errors, one of which cut against a new arm. Re-graded, the gains are +21 to +37 pts and the conclusions don't change. Both versions are published.
- The data is synthetic, built to the app's real shapes. A private second track is built to run the same grader on my own account. It is n = 1 and kept out of these numbers.