Enterprise analytics agents need to work through a multi-step investigation with a human, rather than answer isolated natural-language-to-SQL questions.
2
Carefully structured documents with short trigger messages let agents retrieve domain knowledge when it becomes relevant instead of loading everything into the initial context.
3
Intermediate tables should remain as backend artifacts with schemas, metadata, lineage, and tools, while the agent sees only a compact description.
Summary
Dirk Petzoldt argues that enterprise analytics requires context engineering rather than ever larger prompts. An analyst does more than write SQL: the work involves forming a question, checking whether the data can answer it, interpreting signals, asking follow-up questions, and deciding what to do next. Agents need support for that process. Petzoldt describes three tactics from explai.com's work. First, reverse retrieval by putting a short trigger in the context and giving the agent a structured document it can pull when needed. Second, write intermediate results as table artifacts in a backend, exposing schemas, summaries, lineage, and read and write tools instead of placing thousands of rows into the context window. Third, let the agent write full code in a sandbox for low-risk tasks such as plotting. These primitives allow a system to move from fixed workflows toward more autonomous reasoning while keeping sensitive operations constrained.
Analytics is a multi-step investigation, not a single query
Petzoldt says a useful analytics question often starts before the question is fully phrased, and the data or pattern may not exist. A single answer such as this week's customer count has little value if it produces no follow-up. A signal creates more questions about trends, comparisons, causes, and possible actions. He describes the agent as a companion or consultant in a human-led process, rather than as a natural-language interface to reports.
The agent needs help with tabular data and workplace context
Petzoldt challenges the idea that the user is the problem when an agent fails at analytics. A business user may lack SQL, Python, or formal statistics while carrying detailed knowledge about the business and workplace. The agent may have read the internet yet still struggle with a few numbers. His first shift was to focus on teaching the agent to handle tabular data and use the user's latent context.
Preloading every possible source made the context worse
In explai.com's first year, the team put domain knowledge, data science process guidance, table information, business documents, and intermediate results into the agent context. They used previews, sampling, trimming, and summarization to control long outputs. This approach degraded once real enterprise data and multiple analytical disciplines were involved. Petzoldt says the data was still too large, and the accumulated context reduced the quality of the instructions.
Reverse retrieval lets the agent pull structured knowledge when needed
Instead of preloading a full document about a metric, the team keeps a short trigger message in the context. The agent can pull the complete, version-controlled document when the trigger is relevant. The document contains prerequisites, related guidance, and examples. For instance, if a metric requires two date ranges or is unsuitable for consecutive years, the document directs the agent toward a better metric. Petzoldt says agents learn better from examples than from abstract instructions.
The system does not put full intermediate tables into the agent context. It materializes them as backend artifacts, such as a Postgres table or a pandas DataFrame, and exposes a compact table name and schema to the agent. Tools let the agent inspect heads and tails, metadata, summary statistics, column scales, SQL, and lineage. The front end can page through the artifact separately, so a user can inspect many rows without consuming the agent's context.
Full code is useful when the task is safe to sandbox
For plotting, the team moved from a constrained JSON declaration for Plotly to letting the agent write full code. The code can pre-aggregate data, inspect the resulting plot, and rerun it when labels overlap or the chart is too crowded. Petzoldt says this is more flexible than a fixed grammar and remains low risk inside a sandbox. He contrasts this with freestyle SQL, where the team keeps stronger controls because of data protection and personally identifiable information.
Better primitives allow a gradual increase in agent autonomy
Petzoldt connects context tactics to system design. With stronger infrastructure for retrieval, artifacts, tools, and code execution, a system can begin with explicit workflows, move toward a ReAct-style setup, and eventually let the agent write code. He says the choice should follow the job to be done. Once the primitives were in place, his team found that reacting and coding worked well.