Skip to content
View as agent
Mosaic AI start screen: live datasets, suggested questions and the message composer

Problem

The research team had survey and cost-of-living data in Snowflake. Getting a number out meant waiting on an analyst, and writing it up for publication was a second job. In healthcare you also can’t point an LLM at the warehouse and hope for the best, and the client wouldn’t let the data go to an AI provider like OpenAI or Anthropic at all.

Approach

You ask a question. A lead model works out what it needs and hands each dataset to its own small SQL agent, all running at once. Every query is checked before it reaches Snowflake, and every number in the answer comes from rows a query returned. Adding a dataset goes through a reviewed workflow and needs no code change.

An answer in progress: per-dataset query lanes, then a chart of senior household income by state with its data source

Architecture

Interface
Next.js 16 and assistant-ui, with streamed per-dataset lanes, inline charts and follow-ups
Agents
FastAPI and LangChain; a Claude orchestrator on Sonnet by default, with Haiku and Opus tiers, over Haiku SQL sub-agents on Bedrock
Guardrails
sqlglot AST guard, read-only roles, row, join and time caps, PHI-safe logs
Data
Live read-only Snowflake; Postgres split by schema between app and agent
Workflows
Temporal workflows for dataset exploration, profiling and scheduled re-ingest
Platform
A private cluster in production, built by a teammate; before it, a Terraform estate I planned on GitHub OIDC with no static keys
Observability
Langfuse traces linked to in-app feedback
Delivery
Locked installs, ruff, pyrefly and pytest against a throwaway Postgres in CI, every Action in the API pipeline pinned to a commit SHA, a release-age gate on new packages

Decisions

  • Saying no to most of the wishlistI cut a catalog-search agent, vector routing and extra composer modes from the first release, which only had to give one answer people could trust. File uploads stayed off too, since they’d be a new way in for sensitive data.
  • Keeping the data away from AI providersThe client wouldn’t send data to any model provider’s API, so every call goes through Bedrock in their own AWS account, signed by an IAM role with no API key. We got Claude without the data ever reaching Anthropic.
  • Every dataset gets askedPlain code picks the datasets, since one wrong guess by the model would leave data out. Each gets its own SQL agent, all at once, with a router trimming to six and a hard cap of eight after one busy question fell over.
  • New data without a deployAdding a dataset used to mean YAML and a redeploy. Now a Temporal workflow profiles the table, has the model draft docs, checks each claim against the data, and waits for a person to sign off.
  • Somewhere to run, before there was a clusterUntil a teammate’s cluster was ready, I planned a stopgap and the team built it with agents: 39 Terraform resources, a TLS-only Postgres proxy, scan-on-push images, a fixed egress IP and a budget alarm.
  • Running the build on written plansEvery change started as a short plan I signed off before an agent touched a file. Agents ran in parallel only across separate services, and the work shipped as 42 small reviewed PRs.
Dataset catalog: 793 Snowflake tables, 9 active and 784 waiting, each with its own review and ingest state

Outcome

What started as a prototype over one table now answers across nine datasets for people who have never written a line of SQL, and 784 more tables sit in the catalog ready to onboard. I led a team of three that built it in four and a half weeks, and my two teammates carried as much of the work as I did.

View as agent