PATTERN Cited by 1 source
Metric semantic layer as AI knowledge base¶
Pattern¶
Expose a structured, code-friendly metric semantic layer (YAML configurations with deterministic SQL definitions) as the grounding knowledge base for AI agents, enabling natural-language metric queries with reduced hallucination.
Mechanism¶
Because metric definitions are stored as clean, machine-parseable YAML with precise SQL logic, they naturally serve as context for AI agents:
- An MCP (Model Context Protocol) server wraps the metric library with tools to browse, search, and query metric definitions
- Users ask natural-language questions ("what's rides_completed by region last month?")
- The AI agent resolves the question against the authoritative YAML definitions, generating SQL from the governed template โ not from the LLM's parametric memory
- Guardrails use ground-truth evaluation and LLM-as-a-judge techniques to validate outputs
(Source: sources/2026-06-10-lyft-metric-semantic-layer)
Why this works better than unstructured docs¶
- Deterministic SQL generation eliminates hallucinated metric logic
- Structured YAML provides unambiguous context (dimension names, types, allowed granularities)
- Governed ownership metadata lets the agent surface who to contact for clarification
- Works across multiple AI surfaces: Claude, Cursor, Hex BI tool, custom agents
Relationship to headless BI¶
This pattern is the AI-consumption extension of concepts/headless-bi-semantic-layer โ the same "define once, consume everywhere" principle applied to LLM consumers alongside human consumers and dashboards.
Seen in¶
- sources/2026-06-10-lyft-metric-semantic-layer โ Lyft's MSL + MCP integration for AI agents