The Data Agent Stack - Part 4: Meaning Lives in Code
Summary
Data agents often fail to provide accurate answers despite correct SQL due to a lack of understanding of data's true meaning, which extends beyond mere schema definitions. While schemas describe data shape and query history shows usage patterns, neither fully captures critical context like data grain, exclusions, freshness, or business rules. The article argues that pipeline code is the highest-authority source for this "hidden contract," revealing executable behavior such as deduplication rules, update cadences, and implemented business logic. It proposes building a comprehensive "table context card" that integrates schema metadata, trusted query usage, owner annotations, semantic definitions, lineage, orchestration state, and pipeline-derived facts. This approach, exemplified by systems like OpenAI's in-house data agent and Spotify's data assistant, ensures agents reason over governed, reliable context rather than anonymous or potentially misleading information.
Key takeaway
For Data Engineers or AI Engineers building data agents, relying solely on table schemas or query history will lead to inaccurate results. You must integrate pipeline code as a high-authority source to capture the true meaning, grain, and freshness of your data. Implement a robust "table context card" system that extracts and refreshes code-derived facts, ensuring your agent reasons over governed, validated context. This approach prevents common failure modes like grain mismatches or stale logic, making your data agent reliable and trustworthy.
Key insights
Data agents require code-derived context to understand true data meaning, beyond schemas and query history, for reliable answers.
Principles
- Pipeline code reveals executable data behavior and hidden contracts.
- Data meaning encompasses grain, exclusions, freshness, and business rules.
- Context sources must be ranked by authority and reconciled.
Method
Build a "table context card" by extracting and refreshing table-centered facts from pipeline code, integrating schema, query history, annotations, lineage, and orchestration state.
In practice
- Create a table context card schema with key attributes.
- Extract executable behavior from dbt models, Spark jobs, SQL files.
- Validate context changes with golden questions.
Topics
- Data Agents
- Pipeline Code
- Data Context
- Data Governance
- Data Lineage
- Semantic Layer
Best for: AI Engineer, Data Engineer, Data Scientist
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by The Agent Stack.