Flatfile · AI transformations · Draft · 2 min read
A transformation is a hypothesis. Validation is the feedback.
What AI-assisted data transformation taught me about giving an agent a representation it can reason over—and a way to find out it was wrong.
The sheet is not the prompt.
At Flatfile, I worked on AI transformations that cleaned and reshaped sheet data through prompts and an agent. The obvious context source was the sheet itself. The useful context source was a representation of what was in the sheet and what was wrong with it.
A model rarely needs every row to understand that a column has inconsistent values or that a validation rule is being violated. It needs the schema, the relevant constraints, and representative examples of the failure. Building that representation was as important as asking the model for a transformation.
Retrieval should answer a specific question.
I built JSON specifications from schemas, validation issues, and representative malformed values, then used Turbopuffer-backed retrieval with reranking to ground the agent. The goal was not simply to add a vector search to the stack. It was to let a particular transformation request find the part of the data description that mattered.
The distinction matters because a sample is not the full dataset. Retrieval can make a problem understandable without making every unseen value predictable. The generated transformation still needs a separate source of feedback when it runs against the real data.
Generated code needs an observation loop.
The transformations were JavaScript functions applied to sheet data. An agent could propose a function; execution and validation could reveal whether the result matched the intended constraints. The useful system was not the function in isolation, but the path from an instruction to a transformation to inspectable feedback.
At Obvious, I also built validation tooling that surfaced errors and warnings after sheet changes. Those signals could feed back into the agent's next decision. This is the same pattern I now care about in coding agents: a generated action is a hypothesis, and an external observation has to test the hypothesis.
Reusable work needs a stable contract.
Saved transforms and runbooks made successful work reusable. Instead of asking an agent to reinvent a transformation for each new file, an established sequence could be applied again when the input schema matched.
But reuse should not erase assumptions. A transformation that made sense for one schema is not automatically valid for another. The system needs to preserve the relationship between the procedure and the data it was designed to handle. Otherwise, a convenience feature becomes a very repeatable way to make the same mistake.
This is an agent-systems problem in disguise.
The work included background jobs, context assembly, generated functions, validation signals, and saved execution paths. Moving execution into a sandbox-backed environment made the connection even clearer: the model needed an environment in which it could do work, not just describe work.
What stayed with me was not a particular prompt. It was the architecture of the feedback loop. Make the problem legible, let the agent act within a clear boundary, and return an observation that can change its next decision. That pattern keeps showing up in different clothes.
The generated function is only one step. The useful system is the loop that can tell whether the function helped.