Your analytics agent needs a state contract—not just better SQL prompts
Cube’s production notes show why zero rows, truncated results and failed saves must be different machine-readable outcomes.
An analytics agent can generate valid SQL and still give the wrong answer because it misunderstood what happened after the query ran. Cube’s production notes identify a less glamorous control surface: every tool response must tell the model whether the result is complete, partial, empty or failed—and what can safely happen next.[^1]
“The query ran” is not one state
Cube says a successful query, a successful edit and a completed analysis are different outcomes. A query may execute while a requested save fails. A zero-row result may be legitimate, or it may signal that the agent chose the wrong member or filter. A partial result may be enough for inspection but not for a total or ranking.[^1]
That distinction should become an explicit state contract. At minimum, an analytics tool should return separate fields for execution status, persistence status, result completeness and a supported recovery action. Otherwise the model must infer hidden state from prose, and a plausible inference can silently become a business answer.
Cube’s pagination example makes the risk concrete. Its query tool returns the first 100 rows, the total row count, a query ID for fetching another page and an explicit truncation notice. Without that notice, an agent could calculate a ranking from the sample and present it as though it covered the full result.[^1]
Recovery instructions are part of the API
The company also describes linting known-invalid Semantic SQL before execution. Its example rejects SUM(MEASURE(revenue)) and explains that MEASURE() cannot sit inside another aggregate. Runtime errors carry targeted retry guidance: an unquoted reserved identifier can trigger a quoting hint, while a timeout can recommend retrying the same SQL with a larger timeout.[^1]
This is more than friendlier error text. It turns failures into bounded next actions. A generic “query failed” response invites the model to rewrite unrelated parts of the request, consume more context and possibly change the question it is answering.
Context retrieval has to enforce identity too
Cube does not preload its entire semantic model. Its searchDataModel operation refreshes and searches on demand, filters candidates against the caller’s access, and returns a compact set of likely measures and dimensions. Cube accepts the extra read-time work because stale search can fail quietly by hiding a new measure or surfacing one that was removed.[^1]
The implementation test is straightforward: run the same request as two users with different permissions, force a result larger than one page, and simulate a failed save after successful execution. The agent should not discover unauthorized members, should label the sample as incomplete, and should report the persistence failure without claiming the edit succeeded.
Better prompting cannot repair an ambiguous tool protocol. For production analytics, correctness depends on making state—and the next safe action—impossible to guess.
[^1]: Cube, “Building an Agentic Analytics Harness,” September 3, 2026.
sources
comments · 0