- The paper introduces an agent-based framework that applies a ReAct-style LLM reasoning loop to post-hoc correct conventional yield forecasts.
- The methodology leverages historical knowledge graphs and domain-informed tools—such as phase detection and bias learning—to achieve MAE reductions of up to 28%.
- Experimental evaluations on strawberry and corn datasets demonstrate improved forecast accuracy while highlighting computational trade-offs for batch processing.
Agent-Based Post-Hoc Correction for Agricultural Yield Forecasting
Motivation and Context
Accurate crop yield forecasting is a cornerstone for operational planning in commercial agriculture, impacting labor, storage, and contractual commitments. Conventional approaches increasingly rely on dense sensor networks, satellite imagery, or extensive meteorological inputs—resources often unavailable or impractical for most growers, particularly in data-constrained environments like UK soft fruit farms dominated by polytunnel production. The persistent mismatch between research-grade infrastructure and real-world data availability motivates the need for alternative strategies that maximize utility from sparse, historical records.
Figure 1: XGBoost research baseline predictions on two test plots, highlighting model prediction errors that defy the crop's growth cycle, such as a pre-season spike and post-season spike.
Structured Agent Framework for Post-Hoc Forecast Correction
This work introduces a post-hoc agent framework which accepts the output from a conventional forecasting model and applies domain-informed correction using a structured LLM-based agent. The agent operates through a ReAct-style reasoning loop, iteratively applying expert-designed tools to interrogate predictions, detect seasonal phase violations, learn bias patterns, and enforce empirical bounds based on the knowledge graph encoding historical curves.
Figure 2: The agent pipeline utilizes a ReAct loop to iteratively refine predictions, passing accepted corrections to cross-plot memory that is injected into subsequent agent prompts.
Figure 3: High-level pipeline overview. Training data is encoded into the knowledge graph for reference, with test data processed week-by-week in the prediction loop.
The agent pipeline is initialized with a knowledge graph capturing curve shape features and metadata from previous seasons. During the weekly prediction loop, each test entity is evaluated in lockstep, leveraging stored plot histories and position-bias tables for systematic correction. The correction process is governed by a hierarchical toolset for:
- Similarity Search: Retrieval of historically analogous plots.
- Bias Learning: Dynamic estimation and adjustment for systematic model error.
- Phase Detection: Enforcement of seasonal logic (e.g., zero pre-flowering yield).
- Range Validation: Empirical bounding of weekly yield changes.
- Correction Synthesis: Blending of phase-conditioned and raw predictions.
- Safety Verification: Sanity checks to prevent correction-induced drift.
Experimental Evaluation: Datasets, Models, and Results
The methodology is validated on two distinct datasets: a proprietary UK strawberry yield dataset (Angus Soft Fruits, 123 plots across 16 farms) and the USDA corn harvest dataset (38 US states). Both exhibit seasonal bell-curve properties and sparse record structure, ensuring generalizability.
Three forecasting models are tested as prediction backbones: XGBoost, Random Forest, and Moirai2 (a zero-shot time series foundation model). Agent refinement is performed with three LLMs: Llama 3.1 8B, Qwen 2.5 7B, and LLaVA 13B, hosted locally via Ollama. Baseline and agent-refined forecasts are compared via MAE, RMSE, and MASE metrics.
Figure 4: Random Forest + Llama 3.1 MAE distributions for both datasets, demonstrating the correction effect of agent refinement.
Numerical Highlights
- Angus Strawberry: Llama 3.1 8B agent refinement on XGBoost reduced MAE by 20% and MASE by 56% relative to the baseline. Random Forest achieved a 28% MAE and 66% MASE reduction. Moirai2 achieved MAE and MASE reductions of 24% and 22%, respectively.
- USDA Corn: The largest improvements were on Moirai2 (MAE -24.2%, MASE -24.9%) and Random Forest (MAE -11%, MASE -10.5%). XGBoost baseline had limited room for correction due to already low error.
- LLaVA 13B provided inconsistent corrections, sometimes degrading accuracy, particularly on the corn dataset, underlining the necessity of selecting an LLM capable of numerical reasoning rather than vision-grounded tasks.
Figure 5: Scatter plot of per-plot MAE before and after agent correction (XGBoost + Llama 3.1 8B), with most plots improved.
Figure 6: Per-plot MAE improvement (%) for XGBoost + Llama 3.1 8B, showing the distribution of improvements and occasional degradations.
A systematic leave-one-out ablation study underscores the centrality of phase detection in the agent architecture. Removing phase detection results in +72% MAE increase on strawberry and +46% on corn, with RMSE more than doubling. Other tools (e.g., bias learning, range validation) provide incremental improvements, with correction robustness maintained unless phase detection is absent. Reverse ablation confirms that enabling phase detection alone recovers most correction capacity.
Computational Trade-offs and Limitations
Post-hoc agent correction incurs significant computational overhead, with wall times increasing from tens of seconds to hours for ReAct loop execution. The approach is not immediately suited for real-time inference but is practical for batch-postprocessing in operational contexts. Correction quality is tightly coupled to LLM capabilities; vision-LLMs (LLaVA) are ill-suited for numeric structured tasks, and even smaller LLMs may produce inconsistent tool sequences.
Explainability remains a challenge. While each tool invocation is auditable, the full reasoning path synthesized by the LLM may vary, occasionally reducing interpretability for commercial stakeholders.
Practical and Theoretical Implications
From a practical perspective, the agent framework positions itself as a deployable "correction layer" that requires no retraining or additional data, augmenting any existing forecasting pipeline. The portability across crop types and the ability to encode operational knowledge into fixed toolsets marks a shift away from "end-to-end" parametric prediction.
Theoretically, the results reinforce that systematic errors originating from a lack of context in classic ML models can be corrected via purposeful reasoning about domain structure, seasonal phase, and historical bias. The generalizability across crops and models suggests potential for adaptation to broader agricultural (or even industrial) forecasting scenarios with similar constraints. Extension to higher-frequency or non-seasonal datasets would require adaptation of phase detection and knowledge graph logic.
Conclusion
The agent-based post-hoc correction framework delivers consistent improvements for agricultural yield forecasts in data-constrained settings, functioning as a robust complement to conventional forecasting models. Numerical gains are strongest where baseline models fail to incorporate crop-season logic, and correction efficacy is dependent on the structured reasoning capabilities of the agent's underpinning LLM. Phase detection emerges as the critical tool for grounded correction. The architecture is generalizable and deployable for operational forecasting with appropriate tradeoff management regarding computational resources and explainability. Future research can explore optimizing agent orchestration, expanding tool coverage, and integrating uncertainty quantification for broader time series forecasting applications.