Every developer building a data agent has hit the same wall. You prompt your agent to calculate monthly recurring revenue, and it spends three turns and two thousand tokens simply trying to remember which table holds the subscription dates. Then, it finally generates a query, but it hallucinates a column name or applies a filter that contradicts your company's internal business logic. This cycle of schema discovery and correction is not a prompting failure; it is a structural gap in how LLMs interact with structured data warehouses.
The Architecture of Actionable Context
Anthropic is addressing this friction by open-sourcing ktx, an internal analysis engine designed to serve as an actionable context layer for data and analysis agents. Rather than forcing an agent to rediscover the database schema with every new session, ktx provides a standardized path for agents to access data warehouses and generate queries with high precision. The engine is built for broad compatibility, supporting a wide array of database environments including PostgreSQL, Snowflake, BigQuery, ClickHouse, MySQL, SQL Server, and SQLite.
Beyond raw database support, ktx integrates with the existing ecosystem of analysis tools and semantic layers. It connects with dbt for data transformation, as well as MetricFlow, LookML, Looker, Metabase, and Notion. By bridging these tools, ktx ensures that the agent is not guessing the meaning of a column but is instead pulling from a source of truth. The system focuses on building and maintaining a repository of approved metric definitions, joinable columns, and institutional business knowledge. This transforms the agent's role from a blind query writer into a guided analyst that operates within the guardrails of the organization's specific data definitions.
From Static Semantic Layers to Self-Improving Context
To understand why ktx matters, one must look at the failure of the traditional semantic layer. For years, enterprises have relied on manual semantic layers where engineers painstakingly define every metric and relationship in a static file. These systems are brittle; the moment a table schema changes or a business definition evolves, the semantic layer breaks, requiring manual intervention. When a general-purpose AI agent is dropped into this environment, it often ignores the static definitions in favor of its own probabilistic guesses, leading to the inconsistent results and "hallucinated metrics" that plague current AI data pipelines.
ktx shifts the paradigm from manual maintenance to a self-improving context layer. Instead of relying on a human to update a YAML file every time a column is renamed, ktx allows the agent to refine its understanding of the warehouse through interaction. It creates a feedback loop where the agent learns the correct paths to data and stores that knowledge, reducing the need for repetitive schema exploration. This eliminates the token waste associated with constant metadata retrieval and ensures that the output remains consistent across different sessions.
This flexibility extends to the agent environment itself. ktx is not a locked-in feature of a single platform but is designed to integrate with the tools developers already use. It works seamlessly with Claude Code, Codex, Cursor, and OpenCode. Users can execute ktx by providing their own LLM API keys, utilizing a Claude Pro or Max subscription via Claude Code, or using local Codex authentication. By decoupling the context layer from the specific LLM provider, Anthropic allows teams to inject high-precision data handling into their existing IDEs and agentic workflows without migrating their entire stack.
The Economics of Open Infrastructure
One of the primary barriers to adopting enterprise data tools is the complexity of the pricing model. Anthropic has removed this friction by releasing ktx without a separate licensing fee. The tool does not charge for its own operation; instead, it operates using the user's existing LLM API keys or subscriptions. This means the only cost associated with running ktx is the standard token cost charged by the LLM provider. By eliminating fixed licensing costs, the tool moves the financial burden from a capital expenditure to a variable operational cost based on actual usage.
This accessibility is reinforced by the choice of the Apache License, Version 2.0. This license allows for the modification, distribution, and commercial use of the source code without restrictive royalties. For an enterprise, this means they can optimize ktx to fit their specific internal data security requirements or integrate it directly into a proprietary commercial product without fear of vendor lock-in. The ability to control the code directly is critical for companies handling sensitive financial or user data who cannot rely on a black-box middleware.
Ultimately, the struggle to make AI agents reliable in data analysis cannot be solved by simply increasing the context window or refining the system prompt. The problem is the lack of a persistent, evolving memory of the data's meaning. By replacing the manual, static semantic layer with a self-improving context layer, ktx provides the physical infrastructure necessary to move AI data agents from experimental prototypes to production-ready tools. The efficiency of a data agent is no longer measured by how well it can write SQL, but by how effectively it can navigate the context of the data it is querying.




