## Data Analysis and Research Report Generation with AI Agents: From Guessing to Computing

    Conversational LLMs produce plausible-looking answers instead of verified results, which is why they struggle with exact decimals, percentiles, and complex tables. This article explains how agent mode changes that by delegating precision-sensitive work to deterministic code. It covers how agents plan and execute tasks like developers, plot charts where every point comes from a calculation, and combine text and charts into exported PDF reports. A comparison of different models in agent mode shows that results can still drift from true values if the calculation is not really handled by code, so code execution plus result verification is key. The article also covers production practices such as reproducibility, auditability, containerized scheduling, monitoring, and message-queue integration. One principle ties it together: wherever precision matters, let code do the computing instead of letting the model guess.

    From Guessing Answers to Computing Them: A Dividing Line for LLM Capabilities

    Conversational LLMs are fundamentally probabilistic text generators. They predict the next token based on their training data and the current context. That makes them good at language and pattern matching, but it doesn’t make them follow mathematical rules strictly. When you ask one to compute a percentile, keep a specific number of decimal places, or parse a complex structured table, it usually returns a plausible-looking approximation rather than a precise value you can verify.

    This is the root cause of the well-known problem that AI struggles with exact decimals: it is guessing, not calculating. Agent mode draws a clear line here. Instead of outputting a number directly, the model can invoke external tools and delegate anything that requires precision to deterministic code.

    Why Letting the AI Write Code Is More Reliable Than Letting It Answer Directly

    In data analysis, having the model generate and run a script to parse tables is the sounder engineering approach. The core reason is determinism: a program follows predefined logic, every step is reproducible and auditable, and nothing comes from probabilistic “memory.” This avoids the hallucinations models tend to produce when handling complex structured information.

    A representative execution flow looks like this:

    1. import data_tools as dt # Table/data processing tools
    2. import plotting as pl # Data visualization tools
    3. # 1. Load the structured table instead of letting the model "recall" the data and introduce bias
    4. data = dt.load_table("factor_data.xlsx")
    5. # 2. Compute percentiles with deterministic functions instead of having the model guess decimals
    6. cur_quantile = dt.quantile(data["current_position"], 0.5)
    7. base_quantile = dt.quantile(data["basis_diff"], 0.5)
    8. print(f"Current inventory percentile: {cur_quantile:.1f}%")
    9. print(f"Current basis diff percentile: {base_quantile:.1f}%")
    10. # 3. Plot from the computed results, so every point can be traced back to the source data
    11. chart = pl.line(data["time"], data["basis_diff"])
    12. chart.save("basis_trend.png")

    The key difference is that the numbers come from rigorously tested numerical functions such as quantile, not from the model’s free association.

    The Agent Workflow: Breaking Down and Completing Tasks Like a Programmer

    For data tasks, an agent behaves more like a programmer than a chat partner. Once it receives a goal, it typically breaks the work into a task list automatically and then works through it item by item:

    • read the data files;
    • search the web or retrieve reference material from a local knowledge base;
    • run code;
    • validate intermediate results;
    • assemble the final output.

    This “plan first, then execute, with a clear trail back through each step” process is closely aligned with how leading AI coding tools work. It turns a vague natural-language request into a series of deterministic, verifiable operations.

    Data Visualization: Every Point Is Computed

    Chart accuracy is a baseline requirement for professional research reports. When an agent writes code that calls a data visualization library, every point in the chart is determined by calculations on actual data, not by pixels generated by a probabilistic model. This differs fundamentally from generative image models: those aim to “look right,” while code-based plotting aims to “be right.” For analysis that needs accurate trends, inflection points, and value labels, code-generated charts offer a clear edge in professionalism and trustworthiness.

    From Analysis to Finished Product: Generate Illustrated Research Reports in One Pass

    An agent’s real value is that it chains scattered steps into a complete pipeline. If you state the output requirement explicitly, for example: “Automatically invoke the visualization tools to generate the charts, and merge the text and charts into a PDF research report” — the agent can produce the charts based on the analysis logic and then combine the written conclusions with those charts into a PDF daily report with both text and visuals. Agents can also use scripts to generate structured documents such as PDF and Excel files directly, greatly reducing the manual effort of moving data around and formatting reports.

    A Cross-Model Look at Agent Capabilities

    Most mainstream LLMs now support agent mode. In a comparison test focused on percentile calculations, outputs varied across models:

    Execution mode Current inventory percentile Current basis diff percentile
    Agent mode · Model A 27.4% 68.0%
    Agent mode · Model B 21.2% 55.2%
    Agent mode · Model C ~30% ~30%
    No agent · Direct generation Greater variation Greater variation

    These results support the point made earlier. Even in agent mode, results can still deviate from the true values if the calculation is not actually delegated to deterministic code. Running calculations in code instead of having the model output them directly, and then verifying the results, is therefore the key to greater reliability.

    Engineering for Production: Reliability, Reproducibility, and Scale

    To keep agent-based analysis reliably serving the business, you need to complete the engineering side:

    • Reproducibility: Pin the runtime environment and data version so that the same input always produces the same output.
    • Auditability: Use a logging service to record each step and its intermediate results, making issues easy to trace.
    • Schedulability: Package script execution as containerized tasks and run them on a container platform that can scale out and in elastically.
    • Observability: Use monitoring and alerting to track task success rates and runtimes, and catch problems early.
    • Integrability: Use a message queue to decouple task triggering from execution, so the system can handle high concurrency.

    General-purpose capabilities like these are typically offered as established product categories on platforms such as Baidu AI Cloud. Teams can combine them to fit their own technology stack and turn a one-off AI demo into an automation pipeline for data analysis that can run reliably over the long term.

    Summary

    Agent mode is essentially about evolving LLMs from “good at chatting” to “good at getting work done.” By delegating precise calculations, data visualization, and document generation to deterministic code, supported by planning, retrieval, and validation, AI can deliver professional analysis that is verifiable, traceable, and reusable. For scenarios that demand rigorous data, remember one principle: wherever precision matters, let code do the calculation instead of letting the model guess.