LLM Agents for Data Analysis: Capabilities and Practical Methods
This article explains how large language model (LLM) agents move beyond conversational Q&A to execute data analysis tasks, and why reliable results depend on separating language reasoning from deterministic computation. It covers the core differences between agents and ordinary chat mode, the risks of relying on model memory for numbers, how script execution improves reliability, why script-based charting beats image generation for professional reports, a complete workflow from data to report, how to evaluate different agents, and risk-control practices. Readers will learn a practical pattern: let the model plan, let scripts compute, let tools execute, and let humans verify.
As large language models evolve from “conversational Q&A” into “task-executing agents,” their reach is expanding from text generation into data processing, file analysis, web retrieval, chart creation, and document assembly. Unlike ordinary chat mode, an agent does not simply generate an answer from context. It first understands the goal, breaks the task into steps, calls scripts, file-processing components, or retrieval capabilities, and then consolidates the results into a deliverable document.
However, stronger agent capabilities do not guarantee reliable output. When working with tables, computing quantiles, comparing multiple metrics, or producing research reports, relying purely on the model’s language reasoning can still lead to approximate numbers, confused units, missing calculation steps, and charts that do not match the data. A more dependable approach is a workflow in which the model plans, programs compute, tools execute, and humans verify—rather than asking the model to produce the final answer directly.
1. How Agents Differ from Ordinary Q&A
Ordinary Q&A mode relies mainly on the model’s internal parameters and the current conversation context. After a user asks a question, the model predicts the next span of text based on a probability distribution. This works well for explaining concepts, polishing content, and brainstorming options, but it is not suited to work that demands exact calculations.
Agent mode typically involves the following stages:
Understand the task goal
The agent identifies the final deliverable the user wants—for example, a daily report, a trend chart, a statistics table, or an analysis report with conclusions and supporting evidence.Break down the execution steps
It decomposes a complex goal into subtasks such as reading files, identifying fields, cleaning data, computing metrics, retrieving background material, drawing charts, and generating documents.Select the right tools
For structured data, the agent should prioritize a script environment; for external information, it needs retrieval tools; for document output, it needs file-generation and formatting capabilities.Execute and check results
After tools return results, the agent judges whether they are complete, whether fields match, and whether calculations look abnormal, re-running a step when necessary.Assemble the final output
Finally, it combines numbers, charts, written explanations, and data sources into a report that is readable, saveable, and reviewable.
The value of this approach is that it separates “language reasoning” from “deterministic computation.” Models are good at understanding intent and organizing content; programs are good at executing clearly defined calculations. Combining the two significantly improves control over complex tasks.
2. Why Data Analysis Should Not Rely on Model Memory
When handling numbers, large models tend to produce a common problem: the output looks reasonable but does not strictly follow mathematical rules. For example, if a user asks for the quantile of a column, the model may return an approximate value from context instead of reading every row, then sorting, locating, and interpolating.
This risk shows up in four main ways:
- Unstable decimal places: asking the same question repeatedly may change the last digit or even higher digits.
- Wrong sample range: the model may skip null values, misread headers, or treat a total row as an ordinary sample.
- Opaque formula execution: the model gives a conclusion without actually showing the data cleaning and calculation process.
- Context interference: if several similar metrics appear in the conversation, the model may reference the wrong field.
Therefore, in data work the model should be positioned as an “analysis orchestrator,” not a “calculator.” A sounder flow is to have the model generate a script, let the execution environment actually read the file and compute the result, then return the output to the model for explanation.
A schematic flow looks like this:
User states the analysis goal↓Agent identifies files and fields↓Generate a data-processing script↓Run the script and output intermediate results↓Validate outliers, missing values, and sample size↓Generate charts and written conclusions↓Merge into a final report
In this flow, every key number can be traced back to the raw data and the execution record, rather than depending only on a passage of text generated by the model.
3. How Script Execution Improves Analysis Reliability
In data analysis, the advantage of scripts is not just that they “compute faster.” More importantly, the process is repeatable, the rules are inspectable, and the results are reproducible.
For example, given an inventory and basis data table, a script can perform the following steps in order:
- Read the worksheet and identify column names;
- Remove empty rows and invalid records;
- Convert numbers stored as text into numeric types;
- Check for outliers and duplicate records;
- Compute quantiles using a consistent statistical definition;
- Save intermediate results;
- Generate trend, distribution, or comparison charts from the results;
- Embed the data table and charts into the report.
This kind of process has clear inputs and outputs. Even if the final conclusion is wrong, you can pinpoint the specific step instead of only re-asking the model.
Note that scripts are not perfectly reliable either. An agent may generate a wrong field name, an incorrect filter condition, or an inapplicable statistical formula. So after running a script, you still need validation mechanisms, such as:
- Checking whether the number of rows actually read matches expectations;
- Outputting the minimum, maximum, mean, and sample count;
- Manually spot-checking key metrics;
- Comparing results across different calculation methods;
- Recording the statistical definition and data time range in the report.
Only when both the “code execution result” and the “business interpretation” are verified can the final report be highly trustworthy.
4. Why Script-Based Charting Beats Direct Image Generation for Professional Reports
Charts are an important part of a data report, but image generation and data visualization are two entirely different technical paths.
When an image-generation model draws a chart directly, it focuses on whether the picture matches a visual description and cannot guarantee that axes, ticks, data points, and legends match the real data. For trend display, quantity comparison, or research reports, this can be seriously misleading.
A script- and visualization-library-based flow is different. Every line, every bar, and every scatter point comes from an explicit data computation. As long as the input data is unchanged, the chart can be reproduced stably. Common professional charts include:
- Time-series line charts;
- Multi-metric comparison bar charts;
- Data-distribution box plots;
- Variable-relationship scatter plots;
- Quantile-interval band charts;
- Missing-value and outlier charts.
An agent can automatically choose a chart type based on the analysis goal, but it should avoid “drawing for the sake of appearance.” Each chart should answer a clear question—for example, whether inventory is continuously declining, whether differences exist across regions, or whether a metric shows abnormal fluctuation.
You can state constraints like the following in the output requirements:
Read the raw data, then complete field checks and outlier handling first;All values must be computed by script and must not be filled in by estimation;Automatically generate suitable statistical charts based on the analysis conclusions;Titles, units, legends, and data ranges in charts must match the original fields;Finally, merge the analysis text, statistics table, and charts into one printable document.
This way of prompting is more specific than simply asking to “analyze the data and generate a report,” and it makes it easier for the agent to call tools correctly.
5. A Complete Workflow from Data to Report
A qualified automated daily report or research report should include at least the following stages.
1. Data preparation
Confirm the file format, time range, field meanings, and update frequency. For files from complex sources, establish a field description first to avoid the model making wrong guesses based on column names.
2. Data cleaning
Handle missing values, duplicates, outliers, and inconsistent formats. Fields such as dates, percentages, amounts, and quantities especially need a unified format.
3. Metric computation
Define the statistical definition of each metric. For example, which quantile method is used, whether nulls are included, and whether statistics are by calendar day or trading day should all be stated in the report.
4. External information retrieval
If the report needs to incorporate policy, industry trends, or market news, the agent can first retrieve relevant material and then summarize it. But retrieved content must distinguish “conclusions from raw data” from “external background information,” and unverified descriptions must not be treated as facts.
5. Chart generation
Choose charts based on metric type, and unify colors, fonts, units, and the time axis. Charts should serve the conclusions rather than simply stacking visual elements.
6. Document assembly
Lay out the summary, core metrics, charts, anomaly notes, data sources, and conclusions together into a document that is easy to read and archive.
7. Result acceptance
Final acceptance should include at least three things: whether the numbers are correct, whether the charts match the numbers, and whether the written conclusions exceed what the data can support.
6. Understanding Differences Between Agents in Practice
Differences between agents should not be judged only by how fluent the answers are. You should also focus on the following capabilities:
- Whether it proactively creates a task checklist;
- Whether it can correctly identify and read local files;
- Whether it prioritizes scripts for computation;
- Whether it can locate errors after a failed execution;
- Whether it supports multiple rounds of revision and regeneration;
- Whether it retains intermediate results and the execution process;
- Whether it can generate a well-structured final document.
Some agents excel at long-form expression but still depend on an external execution environment for precise computation; others have strong tool-calling ability but may be less mature at report narrative and conclusion organization. When choosing, evaluate by task type rather than by model name or a single conversation.
7. Risk-Control Recommendations When Using Agents
First, do not treat model output as final data. All key values should come from script execution results.
Second, require the calculation definition to be retained in the output. For example, sample size, time range, filter conditions, and statistical method should be included for later review.
Third, do not look only at the final conclusion. Also inspect intermediate tables, anomaly records, and chart data sources.
Fourth, verify the sources of external material. An agent may mix similar events or treat outdated information as the latest.
Fifth, set up a human approval step. Reports involving operational decisions, financial judgments, and external release should not be published fully automatically.
Sixth, save execution logs. Recording the input files, script version, run time, and final output helps locate problems and reproduce results.
Conclusion
The real value of LLM agents is not to replace all analysis work, but to connect requirement understanding, task decomposition, tool calling, and report assembly. For structured data, the most reliable practice is to let the model plan, let scripts compute, let visualization components draw, and let humans do the final review.
In practice, whether an agent can produce a high-quality report depends not on how polished the text is, but on whether the data pipeline is complete, whether the computation is reproducible, whether the charts are真实 accurate, and whether the conclusions are well supported. Only by establishing deterministic execution and human-verification mechanisms can an agent truly evolve from a “model that can chat” into a data analysis assistant usable in production.
