# Agent Mode for LLMs in Practice: Automated Data Analysis and Research Report Generation
Agent mode upgrades large language models from one-shot answerers into tool-calling, autonomously planning executors, a shift that matters most for data analysis and research report generation. This article explains why a reliable analysis agent should write and execute code to compute results instead of relying on the model's statistical memory, and how a standard agent workflow moves from task planning to data parsing, web research, visualization, and report export. It also compares programmatic plotting with generative image models on data fidelity, axes and scales, reproducibility, and domain fit, discusses the model's inherent limits as a computation engine, and offers engineering recommendations covering enforced code calculation, structured intermediate artifacts, programmatic-first visualization, cloud infrastructure, and human review.
Introduction: Why Agent Mode Is Becoming the New Paradigm for Data Analysis
Nearly every mainstream LLM has added an agentic mode over the past year. At its core, this mode upgrades the model from answering a single question to acting as an executor that can call tools and plan autonomously.
This shift has a clear payoff in high-frequency workflows such as data analysis and research report generation. Faced with a complex quantitative factor table, a news lead that needs online verification, or a research report that has to combine text and visuals, the model no longer just “generates a passage.” Instead, it decides which tools to call, in what order to run them, and how to link intermediate results into a final deliverable.
Understanding this paradigm starts with a fundamental question: in data-heavy work, why is “let AI write code to compute” more trustworthy than “let AI answer directly”? Answering it leads to the design premise behind agent mode.
Core Principle: Have the Model Write Code to Compute, Not Guess from Memory
LLM knowledge comes from statistical learning over training corpora. When answering, the model predicts the most likely next token from the surrounding context. That mechanism performs well for generating natural language, but it has an inherent weakness when precise numbers are required. The model does not strictly execute mathematical rules. Instead, it approximates a result that “looks reasonable,” and decimal places, rounding rules, and boundary conditions can all go wrong.
A more reliable approach for data analysis tasks is therefore to have the agent generate and execute Python scripts:
- Determinism: Code execution is deterministic. The same input always produces the same output, so there is no probabilistic memory bias.
- Reproducibility: A script is explicit computation logic that anyone can review, re-run, and modify.
- Auditability: Every intermediate result can be traced back to its data source and calculation steps.
- Hallucination avoidance: The model does not need to “remember” what the data contains. It reads real files and processes them row by row. This removes, at the root, the problem of the model making up data when handling complex structured information.
A minimal example shows the difference:
import pandas as pd# Deterministic calculation logic generated by the agent: read real data instead of estimating from memorydf = pd.read_excel("factor_table.xlsx")quantile = df["factor_value"].quantile(0.25) # quantile computed from the actual databaseline = df.loc[df["code"] == "BASELINE", "factor_value"].mean()result = {"current_quantile": round(quantile * 100, 1),"baseline_quantile": round(baseline * 100, 1),}print(result)
The value of this code is that the results come from calculations on the data, not from guesses by the model. This is also the dividing line for judging whether a data analysis agent is reliable.
Standard Workflow of an Agent-Driven Analysis
A mature agent works much like the mainstream “command-line agents”: plan first, then execute, then summarize. A typical flow looks like this.
1. Task planning and to-do breakdown
On receiving an instruction, the agent first breaks the goal into an actionable to-do list. For example, “generate a factor analysis report” becomes: load the data table, calculate quantiles, search the web for related news, create charts, and merge and export everything into a document. This explicit task list keeps execution transparent and controllable.
2. Data loading and structured parsing
The agent writes scripts to load data files, such as spreadsheets, from local or cloud storage. It parses and aggregates complex structured information row by row. Code handles this entire stage, which keeps the numbers exact.
3. Information retrieval and knowledge supplementation
For parts that need external information, such as time-sensitive news or industry background, the agent searches the web or retrieves relevant content from a local knowledge base. It then cross-checks this information against the data results.
4. Programmatic visualization
The agent calls Python data visualization libraries to create charts. One key engineering detail is that if the prompt explicitly instructs the agent to “automatically call a plotting library to generate charts and merge the charts with the report body into a document,” the agent can produce charts that follow the calculation logic used for the factors. The end result is a document that combines text and visuals, such as a PDF research report.
5. Report synthesis and export
The agent uses scripts to combine written conclusions, data tables, and visualizations into a structured document. This closes the loop from “data” to a “deliverable report.”
Programmatic vs. Generative Plotting: Precision Determines Professionalism
There are two fundamentally different technical paths for generating charts. Understanding the difference between them is key to evaluating an agent’s capabilities.
| Dimension | Programmatic plotting (Python plotting libraries) | Generative plotting (image generation models) |
|---|---|---|
| Generation mechanism | Computed and drawn from real data | Probabilistic pixel generation |
| Data consistency | Every point corresponds to a specific value | Looks like a chart, but the numbers are unreliable |
| Axes and tick marks | Precisely labeled | May be blurry or incorrect |
| Reproducibility | High | Low |
| Domain fit | Strong (research, finance, and more) | Weak |
In programmatic plotting, such as plotting with established Python data visualization libraries, every point on a chart is calculated from specific data. Coordinates, tick marks, and trend lines correspond strictly to the underlying data. Generative image models, by contrast, produce pixels based on probability. The image may look like a chart, but it cannot guarantee accurate values. For use cases with zero tolerance for inaccuracy, such as quantitative analysis and financial research reports, programmatic plotting is clearly more professional and trustworthy.
So when you evaluate a data analysis agent, one important test is: does it “compute and plot,” or does it “generate an image that looks like a chart”? Only the former is suitable for serious business deliverables.
Limitations to Face: An LLM Is Not a Computation Engine
Even with agent mode, a few limitations deserve clear-eyed recognition:
- Don’t outsource numerical computation to the model. LLMs have limited ability to handle exact decimal places and follow strict mathematical rules. They tend to produce approximate rather than exact results. All key numbers should be computed with code. The model’s role is to orchestrate, not to calculate.
- Always cross-validate results. For metrics such as quantiles, averages, and baseline comparisons, have the model produce the calculation script rather than conclusion numbers. Then verify the output manually or with an independent script. This avoids results that look precise but are actually off.
- Tool use depends on the environment and configuration. Whether the agent can reliably read and write files, search the web, and call plotting and document libraries depends on permissions, installed dependencies, and usage limits in the runtime environment. Plan for this infrastructure early in any engineering effort.
It is also worth noting that evaluating the capabilities of such external models essentially tests a general engineering capability: whether the agent can orchestrate a tool chain and produce deterministic results. It does not test a feature unique to any one specific model.
Engineering Recommendations
To build a trustworthy data analysis agent for production, consider these practices:
- Enforce code-based calculation: In both prompt design and workflow design, require every numerical conclusion to come from a script. Forbid the model from reporting numbers directly.
- Keep intermediate artifacts structured: Have the agent produce auditable intermediate files, such as tables and logs, to make locating issues and re-running easier.
- Prefer programmatic visualization: For charts that demand high accuracy, standardize on Python plotting libraries.
- Rely on cloud infrastructure where appropriate: Scenarios that need elastic compute, object storage, message queues, logging, monitoring, and alerting can use general-purpose product categories on cloud platforms to host and schedule the agent. For example, general capabilities from cloud platforms such as Baidu AI Cloud, including container platforms, log services, and monitoring and alerting, can serve as infrastructure that supports stable agent operation.
- Keep a human in the loop: Retain human review for critical deliverables, especially in high-risk domains such as finance and research.
