How LLM Agents Automatically Generate Illustrated Research Reports: Workflow and Engineering Practices

    This article breaks down how LLM-powered agents deliver end-to-end illustrated reports, from data to a finished document. It outlines the standard five-stage workflow, explains why code execution, retrieval augmentation, programmatic charting, and template-based document composition matter, and highlights the accuracy limits of generative models. You will also find practical guidance on reproducible validation, common failure modes, cost control, and a reusable layered architecture for production deployment.

    1. Introduction: From Chatting to Delivering

    LLM application patterns are evolving rapidly from single-turn question answering into agents capable of autonomous planning and tool use. In scenarios such as financial news aggregation, industry daily briefings, and weekly data reports, what users actually need is not a paragraph of natural-language summary but a deliverable that can be distributed directly: structured body text, accurate metrics, accompanying charts, and a fully formatted document file.

    The core practice shown in the source material is a typical example of this trend: after adding a single instruction to the prompt—“automatically call a plotting library to generate illustrations, and merge the body text and images into a document”—the agent breaks the task down on its own, executes code, retrieves information, draws charts, and assembles the final file. Setting aside the specific product involved, this article abstracts the phenomenon into a general technical problem: how to make an LLM-driven agent reliably complete end-to-end delivery of a “data-to-illustrated-report” pipeline.

    2. The Standard Workflow for Generating Illustrated Reports

    From an engineering perspective, the operating logic of such agents closely resembles that of mainstream AI coding tools and can be summarized in five stages.

    1. Task planning: After receiving a goal, the agent first generates a to-do list, breaking “produce a daily report” into subtasks such as data acquisition, metric calculation, information retrieval, charting, and layout composition.
    2. Data reading: It runs scripts to read local spreadsheets or structured data files, completing field parsing and cleaning.
    3. Information retrieval: It searches online or queries a local news repository for supplementary information used to fill in qualitative descriptions and event background.
    4. Visualization rendering: It calls a plotting library to generate image files according to predefined logic.
    5. Document composition: It merges text and image assets and outputs a distributable document format.

    The following illustrative pseudocode explains the orchestration approach rather than any specific API:

    1. plan = agent.plan("Generate today's industry daily report and output an illustrated document")
    2. for task in plan:
    3. if task.type == "read_table":
    4. df = run_python(task.script) # Read data and compute metrics
    5. elif task.type == "search":
    6. context = retriever.query(task.query)
    7. elif task.type == "chart":
    8. images = run_python(plot_script, data=df)
    9. elif task.type == "compose":
    10. document = compose(text, images) # Merge body text and illustrations

    It is worth noting that the planning stage delivers far more value than isolated tool calls. It translates an uncontrollable natural-language goal into a series of observable, retryable, and auditable execution steps—the fundamental difference between an agent and one-off prompt engineering.

    3. Breakdown of Key Capabilities

    3.1 Code Execution and Data Processing

    By generating and running scripts to read tabular data, the agent essentially offloads computation to a deterministic execution environment. This yields two direct benefits: first, logic such as data cleaning, group aggregation, and year-over-year or period-over-period comparisons can be expressed precisely; second, the process leaves a trace, making review easier.

    3.2 Retrieval Augmentation and Local Knowledge Bases

    Online retrieval addresses timeliness, while a local news repository addresses proprietary corpora and compliance boundaries. Combining the two significantly reduces the model’s reliance on parametric memory and helps limit factual errors.

    3.3 Programmatic Charting Rather Than Generative Images

    This is the dividing line that determines how professional a report looks. A programmatic plotting library renders based on data coordinates, so axes, ticks, and legends correspond strictly to real values. In contrast, charts “drawn” by an image-generation model often only look like charts visually; their values and proportions are unreliable and cannot support professional judgment. In engineering practice, the rule should be: any graphic that carries data semantics must be rendered by code.

    3.4 Document Composition and Layout

    Composing body text, heading hierarchy, tables, and images into a single document requires handling details such as fonts, pagination, figure caption numbering, and asset paths. The robust approach is to use a template with placeholder substitution rather than having the model output an entire layout in code.

    4. Accuracy and Reliability: Boundaries You Must Address

    The source material raises a key observation: different models produce inconsistent results for the same percentile metric, and some results clearly deviate from a reproducible definition. This is not a defect of any particular product but a common mechanism of generative models—they predict the next token based on the training distribution and context, producing approximate results rather than naturally executing strict mathematical rules.

    This leads to three engineering principles:

    • Leave computation to code and phrasing to the model. All metrics must be produced by scripts; the model is only responsible for organizing the language.
    • Build reproducible validation. Set assertions and tolerances for key values; when a value falls outside the expected range, trigger recomputation rather than accepting it outright.
    1. assert abs(metric - expected) < 1e-6, "Metric deviation exceeds threshold; recomputation required"
    • Fix definitions and control randomness. Clearly specify the percentile definition, sample interval, and decimal-place rules, and lower the randomness in the generation parameters so that repeated runs on the same input produce consistent results.

    5. Common Engineering Problems and Optimization Tips

    Symptom Root cause Recommended practice
    Inconsistent values The model “writes” numbers directly Inject all values from scripts
    Unprofessional charts Generative images used instead of plotting Enforce programmatic chart rendering
    Interrupted runs that cannot resume No state tracking for long tasks Persist each step and support reruns from breakpoints
    Halting when quota or resources run out No fallback strategy Design caching, batching, and fallback paths
    Hard-to-audit results Missing execution logs Record scripts, data versions, and intermediate artifacts

    For cost control, templatize and cache high-frequency fixed steps, and call the model only for the parts that change. For stability, split long workflows into idempotent steps and combine them with logging services and monitoring alerts to enable failure localization and automatic retries.

    6. A Reusable Implementation Pattern

    To build similar capabilities in your own environment, you can follow this layered structure:

    1. Access layer: Uniformly wrap model calls, retrieval, and a script-execution sandbox.
    2. Orchestration layer: Handle task planning, dependency ordering, state persistence, and retries.
    3. Data layer: Store structured metrics with version management to keep definitions traceable.
    4. Rendering layer: Programmatic charting and template-based document composition.
    5. Operations layer: Logging, monitoring and alerting, quota management, and access control.

    For cloud deployment, you can typically combine object storage to hold artifacts, a container platform to host the execution sandbox, a message queue to decouple long-running tasks, and logging and monitoring services to observe runtime status. All of these are standard, widely available capability categories.

    7. Conclusion

    The value of using an LLM agent to generate illustrated research reports lies not in “how fast it writes” but in constraining an uncertain generation process into a deterministic, verifiable, and reproducible delivery pipeline. The real focus for developers is task orchestration, separating computation from phrasing, programmatic visualization, and end-to-end observability. Hold these boundaries, and automated reporting can move from a demo to production.