IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
1
CastFlow: Learning Role-Specialized Agentic Workflows for Time Series Forecasting
arXiv:2604.27840v1 [cs.LG] 30 Apr 2026
Bokai Pan , Mingyue Cheng , Zhiding Liu , Shuo Yu , Xiaoyu Tao , Yuchong Wu , Qi Liu , Member, IEEE, Defu Lian , Member, IEEE, and Enhong Chen , Fellow, IEEE
Abstract—Recently, large language models (LLMs) have shown great promise in time series forecasting. However, most existing LLM-based forecasting methods still follow a static generative paradigm that directly maps historical observations to future values in a single pass. Under this paradigm, forecasting is constrained by limited temporal pattern extraction, single-round acquisition of contextual features, one-shot forecast generation, and lack of support from ensemble forecasts. To address these limitations, in this work, we propose CastFlow, a dynamic agentic forecasting framework that enables multi-view temporal pattern extraction, multi-round contextual features acquisition, iterative forecast refinement, and forecasting with ensemble forecasts. First, CastFlow organizes the forecasting process into planning, action, forecasting, and reflection, establishing an agentic workflow. Second, this workflow is supported by a memory module that retrieves prior experience and a multi-view toolkit that constructs diagnostic evidence and provides a reliable ensemble forecast baseline. Third, CastFlow adopts a role-specialized design that combines general-purpose reasoning with specialized numerical forecasting. Under this design, a frozen LLM preserves general-purpose reasoning, while a fine-tuned domain-specific LLM performs evidence-guided numerical forecasting based on the ensemble forecast baseline, rather than from scratch. To optimize a fine-tuned domain-specific LLM, we further develop a two-stage workflow-oriented training that combines supervised fine-tuning (SFT) and reinforcement learning with verifiable rewards (RLVR). To evaluate the effectiveness of CastFlow, we conduct extensive experiments on diverse datasets and show that it achieves superior overall results against strong baselines. We hope that this work can serve as a step toward more adaptive and accurate time series forecasting. Index Terms—Time series forecasting, large language models, agentic forecasting, reinforcement learning, tool use.
I. I NTRODUCTION
T
IME series forecasting is a fundamental task in datadriven decision-making for real-world infrastructures, ranging from renewable energy generation forecasting [1] to streamflow forecasting [2]. Given historical observations, the task aims to predict future values for one or multiple variables over a predefined horizon under complex temporal dynamics and evolving environments [3], [4]. In practice, time series often exhibit strong non-stationarity, short- and long-term dependencies, regime shifts, and complex crossBokai Pan, Mingyue Cheng, Zhiding Liu, Shuo Yu, Xiaoyu Tao, Yuchong Wu, Qi Liu, Defu Lian, and Enhong Chen are affiliated with the State Key Laboratory of Cognitive Intelligence, University of Science and Technology of China, Hefei 230026, China. Email: {bkpan, zhiding, yu12345, txytiny, yuchongwu}@mail.ustc.edu.cn, {mycheng, qiliuql, liandefu, cheneh}@ustc.edu.cn. The source code is available at https://github. com/Forever-Pan/CastFlow.
variable interactions [4]–[6]. These properties make accurate forecasting difficult over time and across domains [5], [7]. Over the past years, forecasting methods have evolved from classical statistical models such as ARIMA [8] and ETS [9] to machine learning approaches such as support vector regression [10], tree-based boosting methods [11], [12], and feature-based forecasting strategies [13]. This evolution has extended to deep learning architectures [14]–[18], and more recently to time series foundation models [19]–[21] and large language model (LLM)-based methods [22]–[24]. Recent LLM-based methods further extend forecasting beyond static pattern matching by introducing explicit reasoning over temporal dynamics [25], multimodal language modeling for time series tasks [26], [27], and agentic forecasting with planning and tool use [28], [29]. However, despite these advances, most LLM-based forecasting methods still follow a static generative paradigm that directly maps historical observations to future values in a single pass [30]. Consequently, this static paradigm offers limited capacity for temporal pattern extraction, only single-round access to contextual features, one-shot generation of future values, and little room for leveraging ensemble forecasts. Importantly, because this paradigm relies on a singlemodel design, it often struggles to jointly preserve generalpurpose reasoning ability and numerical forecasting performance. In practice, training-free methods usually preserve the general-purpose reasoning ability of LLMs but often fall short in numerical accuracy [23], whereas fine-tuning methods can improve numerical forecasting performance [31], [32] while tending to narrow general-purpose reasoning ability and weaken cross-domain generalization [33]. As a result, the central difficulty of current LLM-based forecasting lies in jointly maintaining general-purpose reasoning capacity and numerical forecasting performance within a unified framework. These limitations pose several challenges. First, replacing this static generative paradigm with a dynamic forecasting process is nontrivial [30], because the framework must decide what information to inspect, when to invoke tools, and how to update intermediate reasoning states [34], rather than simply producing one-shot outputs. Second, effective tool use in time series forecasting cannot be achieved by simply equipping an LLM with tools. The toolkit must be task-relevant, numerically reliable, and tightly coupled with task needs [25], [28], while also avoiding redundant operations, unstable interactions, and information leakage from unavailable future observations [35]. Third, iterative forecast refinement is desirable for reliable forecasting [36] but difficult to implement in a principled way. Without a proper workflow, the framework may accumulate
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
a. Training-Free Methods Historical Data
Large Language Model
Predicted Values
Fine-tuned Model
Predicted Values
b. Fine-Tuning Methods Historical Data
c. Agentic Workflow Methods
Toolkit
Action
SFT+RLVR Forecasting
Historical Data
Predicted Values Planning
Memory
Reflection
Fig. 1. Comparison among training-free, fine-tuning, and agentic workflow methods. CastFlow combines role-specialized reasoning with workfloworiented training and shifts forecasting from one-shot generation to evidenceguided correction supported by a memory module and a multi-view toolkit.
errors across steps, incur excessive inference cost, or fail to convert diagnostic feedback into improved numerical forecasting [29], [32]. Fourth, workflow design introduces another layer of difficulty, because planning, action, forecasting, and reflection must be coordinated as a coherent process rather than a loose collection of modules [37]. In addition, the overall workflow must support stable interaction across these modules, so that retrieved experience, tool-derived evidence, intermediate decisions, and numerical forecasting outputs remain consistent throughout the overall process [25], [37]. These challenges make it difficult to jointly preserve adaptability and forecasting accuracy in a unified framework. To address these challenges, we develop CastFlow, a dynamic agentic forecasting framework that reformulates forecasting as a workflow-driven process with multi-view temporal pattern extraction, multi-round contextual features acquisition, iterative forecast refinement, and forecasting with ensemble forecasts. As illustrated in Fig. 1, CastFlow organizes the forecasting process into planning, action, forecasting, and reflection, establishing an agentic workflow. Within this framework, a frozen LLM is used for planning and reflection, while a finetuned domain-specific LLM is used for numerical forecasting. We adopt this role-specialized design because it avoids forcing a single model to optimize conflicting objectives at once, preserves the general-purpose reasoning ability of the frozen LLM, and allows the forecasting model to focus on domainspecific numerical adaptation. To support this workflow, we introduce a memory module that retrieves distilled planning trajectories and tool use patterns to provide prior experience for reasoning, together with a multi-view toolkit that constructs diagnostic evidence and provides a reliable ensemble forecast baseline. Under this workflow, the forecasting model performs evidence-guided numerical forecasting based on the ensemble forecast baseline, rather than from scratch. This design improves numerical stability and shifts forecasting from one-shot generation to evidence-guided correction. We further optimize the framework through a two-stage workflow-oriented training that combines supervised fine-tuning (SFT) and reinforcement learning with verifiable rewards (RLVR), where SFT aligns reasoning signals and tool-derived evidence with numerical
2
forecasting, and RLVR further refines this alignment through verifiable workflow feedback. Extensive experiments on diverse datasets show that CastFlow achieves superior results against strong baselines and provides an effective path toward more adaptive and accurate time series forecasting. In summary, our main contributions are as follows: • We propose a role-specialized reasoning paradigm for agentic time series forecasting, unifying general-purpose reasoning with specialized numerical forecasting. • We develop CastFlow, a dynamic agentic forecasting framework with a memory module and a multi-view toolkit, transforming forecasting into an evidence-guided decision process through workflow coordination. • We introduce a two-stage workflow-oriented training based on SFT and RLVR, and demonstrate its effectiveness across diverse real-world benchmarks. II. R ELATED W ORK A. Traditional Time Series Forecasting Time series forecasting has evolved from classical statistical modeling to machine learning methods, deep learning architectures, and, more recently, foundation models [3], [4]. Classical statistical approaches such as ARIMA [8] and ETS [9] characterize trend, seasonality, and temporal dependence through explicit structural assumptions, and remain important because of their interpretability, efficiency, and strong inductive biases [5]. Machine learning methods further expanded the forecasting toolbox by combining supervised learning algorithms with lagged observations, covariates, and engineered temporal features, with representative directions including support vector regression [10], tree-based boosting methods [11], [12], and feature-based forecasting strategies [13]. Deep learning substantially reduced reliance on manual feature engineering and broadened the architectural design space of forecasting models. Within this paradigm, existing studies have explored diverse architectures [5], [38], [39], including linear models, convolution-based models [18], Transformer variants [17], [40], and state-space models [41]. Representative models such as N-HiTS [42], ETSformer [43], iTransformer [17], and ConvTimeNet [18] show that competitive forecasting performance can emerge from different architectural biases rather than a single dominant backbone. More recently, foundation models such as Chronos [19], TimesFM [20], and Sundial [21] have demonstrated promising zero-shot and crossdomain forecasting ability through large-scale pretraining. Despite these advances, most traditional forecasting frameworks remain model-centric. They typically formulate forecasting as a direct mapping from historical observations to future values, providing limited support for test-time interaction, explicit evidence acquisition, and iterative revision [30]. B. LLM-Based Time Series Forecasting Recent large language model (LLM)-based forecasting studies have adapted language models to time series forecasting through prompt reformulation, input reprogramming, and semantic alignment. PromptCast [22] reformulates numerical sequences as textual prompts and casts forecasting as a
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
3
prompt-based generation problem. Time-LLM [23] reprograms frozen language models with patch-level temporal embeddings, enabling temporal sequences to interact with pretrained semantic space. Related methods such as S2 IP-LLM [31] and TokenCast [44] further explore semantic alignment and tokenbased modeling for time series forecasting. At the same time, analyses of LLM-based time series modeling have pointed out that text-native tokenization and next-token generation remain imperfect fits for continuously valued temporal signals [45]. In response to these limitations, more recent studies increasingly formulate forecasting as a reasoning-driven or workfloworiented forecasting process rather than a static input-output mapping. TimeReasoner [25] studies slow-thinking temporal reasoning, TimeSeriesScientist [28] develops an agentic framework for time series analysis, and AlphaCast [29] reformulates forecasting as an interaction-driven reflective process. Beyond these non-RL reasoning and workflow-oriented efforts, Time-R1 [32] further introduces reinforcement fine-tuning to strengthen multi-step temporal reasoning, while Cast-R1 [37] formulates forecasting as a tool-augmented sequential decision problem that supports evidence acquisition and multi-round interaction. Taken together, these studies move LLM-based forecasting from prompt-based sequence generation toward multi-step reasoning, tool use, and workflow-oriented forecasting with explicit reasoning traces. However, most current methods still face the central difficulty of jointly maintaining general-purpose reasoning capacity and numerical forecasting performance within a unified model, especially when dynamic tool use and iterative correction must be carried out under temporal distribution shifts [30], [37].
workflow and adaptive feature preparation. Recent frameworks such as TimeOmni-1 [54] and AlphaAgentEvo [55] further explore reward-driven reasoning and self-evolving agentic RL in temporal scenarios. Overall, the field is moving from static prediction toward workflow-centric frameworks that integrate reasoning, tools, memory, and learning within a unified workflow for time series forecasting [56].
C. Evolution of LLMs and Agentic Techniques Recent progress in agentic forecasting is also rooted in broader advances in LLM reasoning, tool use, memory, and post-training. Toolformer [46] shows how language models can learn to invoke external tools, ReAct [34] interleaves reasoning with actions, and DEPS [47] supports interactive planning in complex environments. Subsequent work further strengthened reflection, memory, and self-improvement mechanisms. Self-Refine [48] studies iterative refinement through self-feedback, while Reflexion [49] introduces verbal reinforcement and episodic memory to support self-correction across reasoning trajectories. In parallel, post-training methods such as STaR [50], DeepSeek-R1 [51], and Qwen3 [52] have advanced reasoning through self-improvement and reinforcement learning (RL), showing that slow-thinking behavior can be elicited and stabilized beyond simple supervised imitation. These developments are increasingly influencing time series forecasting and analysis [53]. Position-level discussions have argued for moving beyond model-centric prediction toward agentic time series forecasting [30]. Against this broader methodological backdrop, related temporal studies further show how LLM techniques can be extended beyond conventional forecasting settings. InstructTime++ [26] demonstrates the value of multimodal language modeling for time series tasks, while AnomaMind [35] extends tool-augmented reasoning to time series anomaly detection through a structured
III. P RELIMINARIES A. Problem Formulation In this section, we formulate time series forecasting in CastFlow as a sequential agentic forecasting process supported by an ensemble forecast baseline and multi-view diagnostic evidence. Given a dataset D = {(xi , yi )}N i=1 with a lookback window xi ∈ RL×C and a future horizon yi ∈ RH×C , our goal is to learn a reasoning policy πθ that produces refined forecasts through a structured workflow. Unlike conventional approaches f : x → ŷ that generate forecasts through direct mapping, CastFlow starts from a reliable ensemble forecast baseline and performs iterative, evidence-guided refinement. The policy generates a trajectory τ = (s1 , a1 , . . . , sM , aM ), where sj and aj denote the intermediate state and action at step j, respectively, and M is the total number of decision steps. These intermediate steps may involve diagnosing trend shifts or filtering noise via a multi-view toolkit, ultimately leading to a refined forecast ŷ. This formulation shifts the objective from merely minimizing point-wise error to optimizing the sequential decision trajectory, ensuring that forecasting is both statistically grounded and evidence-guided. From a decisiontheoretic perspective, this sequential formulation also captures the non-negative value of multi-round evidence acquisition. Let Om = {o1 , . . . , om } denote the tool observations collected after m interactions, and define the optimal risk as ⋆ Rm = inf E[ℓ(y, f (x, Om ))]. f ∈F
Since a predictor using Om+1 = Om ∪ {om+1 } can always ⋆ ⋆ under ignore the observation om+1 , we have Rm+1 ≤ Rm leakage-free tool execution. This observation explains why CastFlow reformulates forecasting as a multi-round evidence acquisition process rather than a one-shot prediction problem. B. Markov Decision Process Formulation To implement this agentic framework, we model the forecasting process as a Markov Decision Process defined by the tuple (S, A, P, R). Within this framework, the state space S characterizes the agent’s context at step j as sj = (x, ŷbase , Mretrieved , Hj ). This state includes the raw input sequence x, the ensemble forecast baseline ŷbase , the retrieved prior experience Mretrieved from the strategy library, and the historical trajectory Hj , which records prior tool observations and reasoning steps up to the current iteration. The ensemble forecast baseline ŷbase is initialized as ∅ until it is produced by the action module. To address the conflict between semantic reasoning and numerical precision, we employ a hierarchical action space A = Adiscrete ∪ Acontinuous , where planning actions aplan ∈ Adiscrete invoke diagnostic modules and
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
Input
Multi-view Toolkit Foundational Anchorer
Statistical and Spectral Profiler Querying
Lookback Window
Dynamics Monitor
Forecasting
Tool Invocation Forecast Prompt Tool Scheduling Strategy Retrieval
Strategy Generating
Append
Tool-call Results
Parallel Exploration
Forecast Window
Format Checking Result Assessing Self-Correction
Interpretable Forecasting
Model Response Rollout
<think> <think> <think>
thinking process
</think> <think> <think>
<answer> <think> <think>
explanation
</answer> <think> <think>
SFT Warmup
Reward Advantage
Base Model
Response Optimized Trajectory
Memory Construction
Based on the lead-lag effects, we refine the forecast baseline. date target 00:00:00 125.34 00:15:00 234.56 00:30:00 189.23
Fine-tuned Model
Precision Judgment Planning
Construction
Tool-use Experience
Retrieval Window
Frozen Model
Evidence Extraction
Reflection
Historical Strategy
Memory Module
Output
Residual Diagnoser
Tool Response
Action
Planning
Domain Knowledge
Tool Information
4
Group SFT Model
GRPO
SFT Model
Fine-tuned Model
Fig. 2. Overview of CastFlow. The framework orchestrates a planning-action-forecasting-reflection loop via a multi-view toolkit and a memory module. The optimization training progresses from memory construction to supervised fine-tuning (SFT) and group relative policy optimization (GRPO) refinement.
refinement actions arefine ∈ Acontinuous guide quantitative adjustments to the forecast baseline. In implementation, these refinement actions are realized through token-level generation by the forecasting module. The transition dynamics P(sj+1 | sj , aj ) are governed by the execution of the selected tools and the subsequent appending of observations to Hj . Finally, the optimization is guided by a composite reward mechanism R(τ ) that enforces strict structural validity while evaluating both the absolute precision of the refined trajectory and its relative gain against the initial baseline. This formulation explicitly incentivizes strategies that effectively combine ensemble forecasting with diagnostic evidence to achieve measurable forecasting improvements. IV. M ETHODOLOGY In this section, we present CastFlow, a dynamic agentic forecasting framework that combines general-purpose reasoning with specialized numerical forecasting. This role-specialized design transforms time series forecasting from static one-shot generation into a dynamic, evidence-guided decision process. A. Framework Overview As illustrated in Fig. 2, CastFlow integrates a multi-view toolkit, a memory module, and four workflow stages: planning, action, forecasting, and reflection. During the forecasting process, the framework queries the strategy memory to retrieve relevant historical patterns. Guided by these retrieved strategies, the planning module utilizes a frozen large language model (LLM) to conduct general-purpose reasoning for tool scheduling. Subsequently, the action module invokes the toolkit to gather diagnostic evidence and an ensemble forecast baseline. The forecasting module, implemented as
a fine-tuned domain-specific LLM, then performs evidenceguided numerical forecasting by integrating this baseline with the gathered evidence. Finally, the reflection module assesses forecast quality and supports iterative refinement to enforce structural validity and evidence alignment. B. Multi-View Toolkit Construction To ground general-purpose reasoning in empirical observations, we construct a multi-view toolkit that transforms raw time series characteristics into interpretable diagnostic signals. This toolkit comprises four functional categories encapsulating eleven specialized tools. 1) Foundational Anchorer: The foundational anchorer establishes a dependable ensemble forecast baseline by utilizing the model auxiliary tool to extract reliable forecasting priors, thereby preventing the agent from generating numerical values from scratch. This tool implements a cluster-based retrieval mechanism to select an optimal ensemble of forecasting models from a historical case library. Specifically, the historical library is constructed offline by partitioning past time series data into sliding windows and grouping them using K-medoids clustering. Each cluster is represented by a medoid sequence and maintains a historical performance distribution across a diverse model pool. To ensure comprehensive representation, this pool spans three distinct paradigms encompassing classical statistical forecasting methods, advanced deep learning architectures, and pre-trained time series foundation models. During the forecasting process, the newly observed input sequence x is matched against the stored medoids to retrieve the most relevant optimal cluster C ∗ . To ensure reliable matching against temporal distortions, this retrieval employs a comprehensive distance metric that integrates dynamic time warping, Euclidean distance, and cosine similarity computed
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
5
over z-score normalized representations. We then define the ensemble forecast baseline ŷbase for the input sequence x as a weighted aggregation of these historical experts: ! X exp(−Lk ) P ŷbase = · fk (x), (1) j∈C ∗ exp(−Lj ) ∗
∆xt − ∆xt−1 to predict early momentum reversals. For multivariate dependencies, the cross-channel tool and the exogenous analysis tool evaluate lead-lag dependencies and cross-channel associations. We quantify cross-channel dependency using the time-shifted Pearson correlation function: P (xt − x̄)(yt+∆t − ȳ) , (3) ρx,y (∆t) = pP t P 2 2 t (yt+∆t − ȳ) t (xt − x̄)
k∈C
where fk (x) denotes the forecast of the k-th model associated with the retrieved cluster. The term Lk denotes the historical validation loss of model fk , which determines the performance-based voting weights derived during the clustering phase. This softmax-based formulation ensures that models demonstrating historically superior accuracy on similar temporal patterns receive exponentially higher influence in the ensemble. Ultimately, this aggregation serves as the primary quantitative baseline, establishing a reliable prior for subsequent evidence-guided refinement. 2) Statistical and Spectral Profiler: The statistical and spectral profiler delineates the macroscopic numerical boundaries and inherent predictability of the sequence through four specialized tools, thereby equipping the agent with the context needed to calibrate forecasting confidence and prevent implausible extrapolation. The statistical analysis tool calculates fundamental metrics including mean µ, standard deviation σ, and boundary extrema to validate forecasting ranges. The basic statistics tool extends this by extracting advanced features like the median absolute deviation MAD = median(|xi − x̃|) for bias correction, where x̃ is the sequence median. To evaluate the inherent predictability and noise level of the data, it computes the spectral entropy: ⌊L/2⌋
Sspec (x) = −
X
Pk log Pk ,
(2)
k=1 2
|F (x)k | where Pk = P⌊L/2⌋ j=1
|F (x)j |2
denotes the normalized power
spectral density at frequency k, and F(x)k represents the k-th frequency component obtained via the discrete Fourier transform of the lookback window of length L. A higher spectral entropy indicates a sequence resembling white noise, prompting the agent to adopt conservative strategies. To ensure signal reliability, the data quality tool acts as a risk gatekeeper by measuring dropout ratios and defining a strict clipping boundary B = [µ − κσ, µ + κσ] when historical sequences exhibit degradation. Finally, the comprehensive feature tool aggregates these continuous metrics into an abstract diagnostic state Sstat = ⟨µ, σ, MAD, Sspec , B⟩, ensuring the agent has complete visibility over the overall data distribution. 3) Dynamics Monitor: The dynamics monitor captures evolving temporal trajectories, structural regime shifts, and multivariate dependencies using a suite of five tools, thereby enabling the agent to adapt its refinement strategy in response to sudden disruptions rather than blindly extrapolating historical inertia patterns. The trend analysis tool quantifies the overallPtrajectory by calculating the linear slope inline as P t̄)(xt2−x̄) to evaluate trend direction. The changem = (t− (t−t̄) point trend tool serves as a critical correction mechanism to detect structural breaks, computing the first-order difference ∆xt = xt − xt−1 and the second-order difference ∆2 xt =
where ∆t denotes the lead-lag shift between the target variable x and the auxiliary variable y, while x̄ and ȳ are their respective global temporal means. This formulation enables the agent to identify leading indicators and incorporate external adjustment criteria into subsequent forecast refinement. Complementing these quantitative metrics, the event summary tool provides a macroscopic qualitative analysis by mapping the sequence into a discrete semantic space Et ∈ {rise, fall, flat, oscillation}, allowing the agent to apply logical directional constraints based on the dominant abstract pattern. 4) Residual Diagnoser: The residual diagnoser employs an autoregressive residual tool to isolate uncaptured nonlinearities and systematic biases in the initial baseline, thereby exposing specific structural deficiencies and guiding targeted numerical compensation. To achieve this, the tool fits a proxy autoregressive process to the raw input sequence and extracts the corresponding residual error component: ! p X ϵt = xt − c + ϕi xt−i , (4) i=1
where c is the intercept constant, ϕi represents the learned autoregressive coefficients, and p indicates the optimal lag order determined by information criteria. By analyzing this residual PLsequence, the tool extracts the residual mean µϵ = 1 t=p+1 ϵt to detect systematic lag. It further computes L−p PL
ϵt ϵt−1
t=p+2 to the first-order residual autocorrelation r1 = P L 2 t=p+1 ϵt diagnose unmodeled dependencies. This allows the agent to recognize whether simple linear extrapolation fails to capture complex dynamics, guiding higher-order compensation and tail-risk preservation. Crucially, to prevent unintended futuredata leakage, this diagnostic tool is deployed only during the training phase and is strictly bypassed during testing.
C. Agentic Forecasting Workflow The CastFlow framework interconnects planning, action, forecasting, and reflection through a memory-supported workflow. This workflow formulates time series forecasting as a sequential decision process that couples general-purpose reasoning with specialized numerical forecasting. To prevent the planning module from generating unstable tool schedules in a zero-shot setting, we augment this stage with a dedicated memory module. This memory stores distilled procedural knowledge, allowing the agent to ground current tool orchestration decisions in successful historical reasoning trajectories. To build the strategy memory, the framework expands an initial planning result into K parallel exploration paths for each training instance. By evaluating the forecasts generated under these candidate strategies against the ground truth,
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
6
the framework identifies and archives the optimal reasoning trajectory. We define each memory entry as a structural tuple e = ⟨x, A∗ , O∗ , τ ∗ ⟩, preserving the input sequence x, the optimal tool execution schedule A∗ , the corresponding diagnostic outputs O∗ , and the final model response τ ∗ . The optimal trajectory τ ∗ is selected by minimizing the overall mean squared error (MSE) over the entire future forecasting horizon H for each training instance:
the trainable forecasting module carries domain-oriented specialized reasoning. The action module does not itself perform reasoning. Instead, it serves as an execution interface that deterministically follows the planning result, invokes the selected tools, and returns the resulting ensemble forecast baseline and diagnostic evidence to support downstream forecasting and verification across the forecasting workflow.
H
2 1 X (τ ) τ ∗ = arg min ŷt+h − yt+h , 2 τ ∈Tvalid H · C
(5)
h=1
where Tvalid represents the subset of generated candidate trajectories that successfully pass strict formatting and logic validation constraints. This optimal memory entry is then indexed via vector similarity to enable precise retrieval during the forecasting process. During the forecasting process, the input interface encodes the lookback window and queries the strategy memory for relevant historical tool strategies. The framework retrieves memory items satisfying the boundary condition sim(x, xe ) ≥ η, where η is a predefined similarity threshold. The planning module acts as the central control unit, utilizing a frozen LLM to map retrieved strategies into a structured tool schedule. This schedule explicitly delineates mandatory baselinetracking tools and dynamically selected optional diagnostic tools tailored to the current sequence. Directed by this schedule, the action module interfaces with the multi-view toolkit to translate the plan into an ensemble forecast baseline ŷbase alongside diagnostic evidence Ddiag . The forecasting module, implemented as a fine-tuned domain-specific LLM, then integrates retrieved strategies and localized temporal evidence to generate the final forecast under the current workflow. The workflow is closed by the reflection module, which functions as a quality gatekeeper for output reliability. It employs a dual-check mechanism combining a deterministic format verification indicator If ormat ∈ {0, 1} with a logic evaluation indicator Ilogic ∈ {0, 1} driven by the frozen model. If any inconsistency is detected such that If ormat · Ilogic = 0, the module triggers a feedback loop that routes the process back to the planning phase for iterative refinement. This selfcorrection process is strictly bounded by a maximum retry limit to prevent infinite loops, ensuring that the final output maintains structural validity and evidence alignment. D. Role-Specialized Reasoning Architecture The reasoning architecture of CastFlow follows a selective training strategy that fine-tunes only the forecasting module while freezing the planning and reflection modules. This configuration preserves the stability of semantic tool scheduling and logic verification while enabling the specialized forecaster to capture domain-specific temporal patterns for high-precision numerical forecasting. To operationalize this strategy, CastFlow organizes the overall reasoning process through role specialization rather than assigning all cognitive responsibilities to a single model. Under this design, the frozen planning and reflection modules preserve general-purpose reasoning, while
1) Role-Specialized Cognitive Architecture: To resolve the inherent conflict between language generation and numerical regression, we organize the reasoning framework into two selectively partitioned parameter spaces with distinct optimization objectives. The general-purpose layer operates entirely within the frozen parameter space Θf rozen . By utilizing the unaltered weights of the foundational model, the planning and reflection modules retain broad semantic reasoning capabilities to process natural language tool descriptions, retrieve relevant historical strategies, and evaluate logical consistency without suffering from catastrophic forgetting. Conversely, the specialized numerical engine operates within the tunable parameter space θtuned . This selective parameter partitioning ensures that the framework avoids forcing a single model to simultaneously balance semantic generation and numerical fitting. By focusing gradient updates exclusively on θtuned , the forecasting module learns to bridge the representation gap, mapping qualitative structural signals returned by the toolkit into precise quantitative adjustments. As a result, CastFlow does not separate reasoning and forecasting into isolated pipelines. Instead, it assigns them complementary roles within a collaborative architecture, while the action module functions as a non-parametric execution interface between planning and forecasting across the full workflow. 2) General-Purpose Reasoning: General-purpose reasoning in CastFlow is instantiated in the planning and reflection modules, both of which are driven by the frozen model. The process begins with the planning phase, where the frozen planner evaluates the input sequence x together with the retrieved historical strategies Mretrieved . Based on this context, the planner generates a structured tool execution schedule A = {a1 , a2 , . . . , aM } by maximizing the joint probability over the vocabulary space: P (A | x, Mretrieved ; Θf rozen ) = QM i=1 P (ai | a<i , x, Mretrieved ; Θf rozen ), where ai represents the discrete token for the selected tool at step i. Through this process, the planner does not directly output numerical forecasts. Instead, it determines which diagnostic tools should be executed and how the subsequent forecasting stage should be grounded before numerical prediction is attempted. After the tool schedule is produced, the action module deterministically executes the selected tools and constructs the corresponding execution context, including the ensemble forecast baseline ŷbase and the multi-view diagnostic evidence Ddiag . This step is guided by the planner and is deterministic rather than reasoning-driven. Once a candidate forecast is generated, the reflection module performs general-purpose reasoning for output verification and self-correction. The frozen evaluator computes a binary validation score v ∈ {0, 1} by combining deterministic formatting rules with semantic
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
reasoning over the generated forecast: v = If ormat (ŷ) · Ilogic (ŷ, Ddiag ),
(6)
where the indicator If ormat ensures exact sequence length compliance and Ilogic verifies alignment with the diagnostic signals. If the validation score evaluates to v = 0, the reflection module generates natural language feedback to update the prompt context and triggers a guided self-correction loop for revision. To guarantee computational termination, the iterative feedback loop counter c strictly halts the process when c ≥ Cmax , where Cmax defines the maximum retry limit. In this way, the frozen model supports both forward planning and backward verification, thereby preserving general-purpose reasoning throughout the workflow. 3) Domain-Oriented Specialized Reasoning: Domainoriented specialized reasoning in CastFlow is carried by the forecasting module. Unlike the frozen planner and evaluator, this module is explicitly trained to transform domain-specific evidence into accurate numerical forecasting. Its input is not the raw history alone, but the complete execution context produced by the workflow, including the original sequence x, the ensemble forecast baseline ŷbase , and the multi-view diagnostic evidence Ddiag returned by the action module. Therefore, the forecasting module does not generate numerical values from scratch. Instead, it performs domain-oriented reasoning over a structured forecasting context that has already been organized by planning and grounded by tool execution. Under this formulation, the forecasting module serves as the synthesis engine that converts retrieved strategies and diagnostic evidence into quantitative refinement under explicit domain-specific constraints. We formalize this evidenceguided refinement as a conditional generation process optimizing the final numerical forecasting: ŷ = arg max log P (ỹ | ŷbase , Ddiag , x; θtuned ) ,
(7)
ỹ
where ỹ denotes a candidate forecast sequence, and the output probability distribution is explicitly conditioned on the ensemble forecast baseline and the extracted evidence to guide continuous numerical alignment. To make this refinement explicit, let ebase = y − ŷbase denote the baseline residual and let ∆θ = ŷ − ŷbase denote the evidence-guided correction produced by the forecasting module. Then y − ŷ = ebase −∆θ , and the change in squared error can be written as ∥ŷ − y∥22 − ∥ŷbase − y∥22 = ∥∆θ ∥22 − 2⟨ebase , ∆θ ⟩. Hence, the refinement improves the ensemble forecast baseline whenever 2⟨ebase , ∆θ ⟩ > ∥∆θ ∥22 . This condition shows that effective correction requires both residual-direction alignment and controlled correction magnitude, which motivates the combination of a reliable baseline, diagnostic evidence, and reward-guided refinement in CastFlow. Because θtuned is optimized specifically for forecasting, the module learns to interpret statistical constraints, temporal dynamics, residual cues, and retrieved procedural hints in a domain-adaptive manner. Consequently, the specialized reasoning process does not replace general-purpose reasoning, but builds directly on it
7
during forecasting. Instead, it operationalizes the guidance produced by the frozen modules into evidence-guided numerical refinement, enabling the final forecast to remain both logically grounded and quantitatively precise under the given evidence. E. Workflow-Oriented Training To train the specialized forecasting module for expert numerical reasoning, we adopt a workflow-oriented training strategy that progressively refines the model from behavioral imitation to autonomous precision alignment. This supervised fine-tuning (SFT)-then-reinforcement learning with verifiable rewards (RLVR) paradigm is essential for resolving the precision-reasoning dilemma. Relying solely on SFT restricts the model to mimicking the teacher’s behavior, fundamentally limiting its ability to explore the continuous numerical space for optimal accuracy. Conversely, applying RLVR directly from scratch often leads to severe format collapse and unstable exploration. Therefore, SFT serves to establish a reliable reasoning structure and protocol compliance, while the subsequent RLVR phase pushes the model beyond simple imitation to explicitly maximize forecasting precision through trial-anderror during policy optimization. Formally, the training target can be viewed as trajectory-level policy optimization under the workflow-induced sequential decision process: J(πθ ) = Eτ ∼πθ [R(τ )], where τ = (s1 , a1 , . . . , sM , aM ) denotes the full workflow trajectory. This objective emphasizes that CastFlow does not optimize an isolated forecast token or a single regression output alone; instead, it optimizes the trainable forecasting policy under the complete workflow trajectory that includes planning, evidence acquisition, refinement, and verification. 1) Supervised Fine-Tuning: The process begins with SFT to address the cold-start problem. We construct a highquality dataset by extracting the optimal reasoning trajectories archived during the memory construction phase. Specifically, after building the memory module, we integrate it into the complete framework and execute the full workflow using a powerful teacher model, such as Grok 4. For each training instance, we capture the complete input context, including the ensemble forecast baseline and multi-view evidence, and pair it with the teacher model’s output, which comprises both the step-by-step reasoning trace and the final numerical answer. The response that yields the minimum error during parallel exploration is then selected to form the SFT training corpus. Fine-tuning the local model on this refined corpus minimizes the negative log-likelihood loss inline as LSF T = P −E[ j log πθ (wj | w<j , Cexec )], where wj represents the discrete generated tokens, ensuring that the agent masters the structural protocols required for subsequent RLVR while acquiring the foundational ability to accurately interpret domainspecific diagnostic signals. 2) Reinforcement Learning with Verifiable Rewards: Building upon this foundation, we employ group relative policy optimization (GRPO), a critic-free RL algorithm, to transition the model toward maximizing forecasting precision. Unlike traditional proximal policy optimization that relies on a separate value network, GRPO samples a group of outputs for
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
8
TABLE I S UMMARY OF THE BENCHMARK DATASETS FOR TIME SERIES FORECASTING . ”D IM ” DENOTES THE TOTAL NUMBER OF RECORDED COLUMNS , INCLUDING THE TIMESTAMP COLUMN , WHILE THE FEATURE LIST REPORTS ONLY THE TARGET VARIABLE AND COVARIATES . T HE DATA SPLIT RATIO FOR ALL DATASETS IS STRICTLY SET TO 7:1:2 FOR TRAINING , VALIDATION , AND TESTING . Domain
Frequency
Dim
L
H
Stride
BE
Electricity Market
1h
4
168
24
48
Electricity price, Generation forecast, System load forecast
DE
Electricity Market
1h
4
168
24
48
Electricity price, Wind power forecast, Amprion zonal load forecast
NP
Electricity Market
1h
4
168
24
48
Electricity price, Grid load forecast, Wind power forecast
FR
Electricity Market
1h
4
168
24
48
Electricity price, Generation forecast, System load forecast
PJM
Electricity Market
1h
4
168
24
48
Electricity price, System load forecast, Zonal COMED load forecast Oil temperature, High useful load, High useless load, Middle useful load, Middle useless load, Low useful load, Low useless load
Dataset
ETTh
Power Grid
1h
8
96
96
48
ETTm
Power Grid
15min
8
96
96
96
WP
Renewable Energy Generation
15min
8
96
96
96
SP
Renewable Energy Generation
15min
8
96
96
96
Streamflow
1day
6
96
96
48
MOPEX
each prompt and estimates the baseline directly from these multiple rollouts. For a given set of sampled trajectories, it R computes the normalized advantage inline as Ai = Riσ−µ , R where µR and σR represent the mean and standard deviation of the group rewards. This lightweight formulation significantly reduces memory overhead while incentivizing the agent to autonomously refine its logic paths beyond simple supervised imitation under verifiable groupwise relative reward signals across sampled reasoning trajectories. The optimization is driven by a composite reward mechanism designed to strictly enforce structural validity while incentivizing the agent to outperform the ensemble forecast baseline. We formally define the reward function R(τ ) for a reasoning trajectory τ as a piecewise combination of format penalization and contrastive performance evaluation. Let V denote the set of structurally valid trajectories satisfying the required output format: ( R(τ ) =
−Pviolation , L −L Rabs (Lagent ) + Clip λ · base ν agent , −δ, δ ,
τ ∈ / V, τ ∈ V.
(8)
where Pviolation represents a severe negative penalty applied immediately to trajectories outside V, such as JSON parsing failures or forecasting length mismatches. For structurally valid outputs, the final composite reward comprises an absolute utility function and a relative contrastive gain. The absolute πϵ term Rabs decays smoothly inline as Rabs (ϵ) = 1 − α sin 2γ for errors below a dataset-specific empirical upper bound γ, shifting to an exponential decay function for more severe deviations. The core innovation lies in designing the contrastive relative term, which calculates the improvement of the agent error Lagent against the baseline error Lbase . By scaling this difference with a multiplier λ and a datasetspecific normalization factor ν, and clipping it within the strict boundary [−δ, δ], the optimization landscape explicitly encourages the agent to actively leverage diagnostic evidence to rectify baseline lag or bias. This contrastive objective ensures that the specialized module learns to function as a true refinement engine, synthesizing semantic context to achieve numerical accuracy superior to pure extrapolation.
Features (Target & Covariates)
Real power, Direct radiation, Wind direction 80m, Wind speed 80m, Temperature 2m, Relative humidity 2m, Precipitation Streamflow discharge, Mean areal precipitation, Climatic potential evaporation, Maximum air temperature, Minimum air temperature
V. E XPERIMENTS In this section, we conduct a comprehensive evaluation of CastFlow across diverse forecasting benchmarks, comparing it against state-of-the-art baselines to demonstrate its effectiveness in both short-term and long-term scenarios. A. Experimental Settings 1) Datasets: We evaluate our framework on a diverse set of real-world benchmarks covering varying horizons, multiple sampling frequencies, and complex contextual dependencies. A comprehensive summary of all datasets, including their dimensions, target variables, and specific configurations, is provided in Table I. For short-term forecasting, we employ five regional datasets from the EPF benchmark [57], specifically BE, DE, FR, NP, and PJM, each containing a target electricity price series and two market-specific exogenous forecast series. In the long-term setting, the widely used ETTh and ETTm datasets [58] are utilized to monitor transformer temperature and load variations under different time granularities. To capture the dynamics of renewable energy generation, we adopt the Windy Power (WP) and Solar Power (SP) datasets [1], which align real power generation records with multi-dimensional meteorological conditions. Additionally, the MOPEX dataset [2] is included for streamflow forecasting, featuring streamflow series supported by climatic factors. For rigorous evaluation, all multivariate time series datasets are strictly split chronologically into training, validation, and testing sets with a consistent ratio of 7:1:2. 2) Baselines: To provide a comprehensive evaluation, we compare CastFlow against 21 representative baselines spanning five distinct methodological paradigms, covering both conventional and emerging approaches, from classical forecasting to recent reasoning-oriented frameworks under a unified evaluation protocol: (1) statistical models: Prophet [59] and ARIMA [8]; (2) machine learning models: XGBoost [11] and LightGBM [12]; (3) deep learning forecasters: Autoformer [14], DLinear [15], PatchTST [16], iTransformer [17], TimeXer [57], and ConvTimeNet [18]; (4) foundation models: Chronos [19], TimesFM [20], and Sundial [21]; (5) large
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
9
TABLE II MSE AND MAE RESULTS ON A COMPREHENSIVE BENCHMARK SUITE SPANNING ELECTRICITY MARKETS , POWER GRIDS , RENEWABLE ENERGY GENERATION , AND STREAMFLOW, EVALUATING BOTH SHORT- AND LONG - TERM HORIZONS . B EST RESULTS ARE BOLDED AND SECOND - BEST RESULTS ARE UNDERLINED , DEMONSTRATING THE MODEL’ S EFFECTIVENESS UNDER CROSS - DOMAIN JOINT TRAINING . Settings Dataset Metric
Short-term Forecasting BE MSE MAE
DE NP MSE MAE MSE MAE
Prophet 992.90 16.94 320.63 13.25 57.79 ARIMA 869.14 17.04 372.91 11.82 55.51 1344.39 16.44 227.01 10.21 28.31 XGBoost LightGBM 1168.62 15.71 231.44 9.57 30.92 Autoformer 891.02 16.62 331.37 13.33 46.11 DLinear 658.66 12.84 239.98 12.84 32.22 PatchTST 627.27 11.44 208.93 10.04 24.64 606.71 11.25 230.05 10.23 27.10 iTransformer 703.00 10.70 252.05 10.26 27.31 TimeXer ConvTimeNet 621.73 10.98 231.26 10.80 28.13 Chronos 625.88 9.63 223.24 10.00 24.39 TimesFM 784.98 10.92 219.57 9.98 25.11 651.50 11.00 264.72 10.71 28.68 Sundial Time-LLM 729.68 11.88 253.97 10.85 33.05 PromptCast 824.27 13.38 293.24 10.93 43.16 654.38 11.48 232.21 10.84 31.49 TokenCast 701.24 11.89 313.82 11.15 29.67 S2 IP-LLM TimeReasoner 691.28 11.62 272.19 10.77 31.27 Time-R1 635.23 10.23 210.28 9.89 26.28 TimeSeriesScientist 906.68 14.94 245.40 10.39 46.31 AlphaCast 653.98 10.71 248.98 10.23 24.16 CastFlow
546.87
9.60
200.47
9.50
23.92
Long-term Forecasting
FR PJM ETTh ETTm MSE MAE MSE MAE MSE MAE MSE MAE
WP MSE MAE
5.00 4.45 3.24 3.38 4.86 3.84 3.27 3.44 3.44 3.62 3.21 3.20 3.36 3.71 3.93 3.59 3.42 3.62 3.35 4.16 3.19
1035.70 964.00 1044.82 933.84 934.55 811.62 797.42 940.51 834.86 882.85 812.40 870.17 942.46 936.46 1105.16 963.09 872.55 899.47 842.19 904.65 804.89
14.42 13.22 10.14 9.96 13.37 10.45 9.13 11.10 9.38 8.97 8.24 8.84 8.54 11.51 14.42 11.82 10.93 11.01 10.92 12.71 9.10
52.26 33.02 30.36 29.63 77.59 42.16 31.88 35.14 25.88 28.71 25.70 33.99 30.72 35.84 47.62 32.37 35.67 34.38 27.35 45.40 26.53
5.53 4.00 3.86 3.88 6.43 4.65 4.17 4.37 3.65 3.79 3.63 4.14 3.99 4.32 5.58 3.92 4.16 4.22 3.80 5.39 3.59
46.70 10.88 13.37 12.22 11.60 8.51 8.40 8.31 8.77 8.62 9.40 9.20 9.44 8.04 9.46 8.28 9.68 9.14 8.02 9.09 8.47
4.59 2.43 2.96 2.75 2.64 2.24 2.17 2.14 2.20 2.18 2.25 2.26 2.32 2.08 2.82 2.17 2.39 2.18 2.04 2.24 2.21
21.18 2.71 3.41 2.91 4.23 2.63 2.62 3.14 2.56 2.71 2.75 2.78 3.21 2.57 4.25 2.50 3.01 4.04 2.80 5.28 2.48
3.11 1.17 1.37 1.26 1.57 1.14 1.11 1.28 1.11 1.16 1.18 1.15 1.24 1.13 1.60 1.10 1.29 1.57 1.11 1.61 1.16
8071.24 2106.64 2384.63 2290.27 2568.13 1932.59 2270.10 2064.60 2170.25 2081.37 2269.43 2228.19 2168.81 2833.24 2626.89 2521.39 2497.38 2228.24 2054.88 2551.19 2131.02
3.11
707.96
8.16
27.45
3.74
8.00
2.03
2.36
1.04
1719.99 27.40
language model (LLM)-based and agentic frameworks: TimeLLM [23], PromptCast [22], TokenCast [44], S2 IP-LLM [31], TimeReasoner [25], Time-R1 [32], TimeSeriesScientist [28], and AlphaCast [29]. These baselines provide a solid basis for evaluating our method across diverse benchmarks. 3) Implementation Details: We utilize Grok 4 [60] as the frozen backbone model for general-purpose reasoning during both training and testing phases, which also facilitates experience generation as a teacher model during memory construction. Meanwhile, Qwen3-4B [52] is employed specifically as the trainable local LLM for specialized numerical forecasting, configured with a max completion length of 5,000 tokens. For computational consistency, each individual experiment is conducted on 2 NVIDIA A800 GPUs. We implement the training pipeline using the transformers Trainer [61] for the supervised stage and the Agent Lightning framework [62] for the reinforcement learning with verifiable rewards (RLVR) stage. The process consists of two phases: (1) supervised finetuning (SFT) with a learning rate of 5×10−5 and batch size of 8, running for 1 epoch in cross-domain joint training; and (2) RLVR using group relative policy optimization (GRPO) [63] with a group size of G = 8, temperature of 1.0, and learning rate of 2 × 10−6 . To ensure full policy adaptability, the KL penalty coefficient is set to β = 0.0. The RLVR stage spans 3 epochs in cross-domain joint training. For evaluation, we set the lookback window L = 168 and horizon H = 24 for short-term tasks, while long-term tasks use L = 96 and H = 96. All methods are evaluated using the same chronological splits, target variables, and forecasting horizons. For methods that support exogenous inputs, the same available covariates are provided; for target-only baselines, only the target series is used. We follow official implemen-
SP MOPEX MSE MAE MSE MAE
56.06 64.81 28.77 80.48 37.99 33.85 34.81 29.50 37.01 39.14 29.33 19.06 32.47 19.44 29.90 17.96 31.92 20.12 28.52 23.22 29.63 79.28 29.84 45.91 31.22 100.40 38.05 17.25 36.20 18.21 34.29 18.13 33.13 18.46 31.57 20.91 30.13 17.42 33.59 25.82 30.22 18.89 16.90
6.44 4.60 3.50 2.80 4.34 2.74 2.78 2.67 2.92 3.10 4.57 3.37 6.61 2.68 2.84 2.74 2.96 2.98 2.67 3.14 2.80
12.40 9.19 6.91 9.63 6.17 5.26 5.36 4.88 4.83 5.07 5.29 5.58 5.15 5.77 6.70 5.52 6.29 5.92 5.83 5.60 5.19
2.50 1.85 1.68 1.84 1.96 1.33 1.44 1.34 1.28 1.29 1.31 1.35 1.42 1.44 1.59 1.39 1.58 1.46 1.35 1.42 1.43
2.50
3.60
1.19
tations or recommended configurations whenever available, including model-specific training schedules, early stopping, preprocessing, and prompt construction. Trainable baselines are fitted on the training split, while remaining hyperparameters and early-stopping criteria are selected on the validation split without test-set information. For prompt- or LLM-based baselines, contextual inputs are constructed according to their original protocols but restricted to the same available forecasting information, including the lookback window and supported covariates, without future observations or test labels. When model-specific preprocessing or normalization is applied, all reported metrics are computed after inverse transformation to the original target scale. CastFlow retains the original magnitude values in its forecasting context without explicit input-output normalization strategies such as RevIN [64]. B. Main Results The performance evaluation in Table II demonstrates that CastFlow achieves superior accuracy across the vast majority of benchmarks, exhibiting distinct advantages in different forecasting horizons. This result remains encouraging given the breadth of the comparison, which spans statistical, machine learning, deep learning, foundation, LLM-based, and agentic baselines across short- and long-term settings. In long-term scenarios, the framework achieves the best results across all five datasets, effectively mitigating the error accumulation that plagues traditional autoregressive models, with particularly notable gains on WP and MOPEX. In short-term tasks, CastFlow achieves the best results on 4 out of 5 datasets. By reformulating forecasting as a dynamic agentic forecasting framework, CastFlow effectively addresses the limitations of task-specific architectures like PatchTST and foundation
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
10
TABLE III A BLATION STUDY OF C AST F LOW COMPONENTS . “ W / O T OOLKIT ” REMOVES EXTERNAL TOOLS , EFFECTIVELY DISABLING THE DEPENDENT PLANNING MECHANISM , AND RELIES SOLELY ON INTERNAL PARAMETRIC KNOWLEDGE ; “ W / O M EMORY ” REMOVES THE RETRIEVAL MECHANISM ACTING AS A TRAINING STABILIZER ; “ W / O R EFLECTION ” EXCLUDES SELF - CORRECTION . F ULL M ODEL ACHIEVES THE BEST OVERALL PERFORMANCE .
Settings
Short-term Forecasting
Long-term Forecasting
Metrics
Variants
BE
DE
NP
FR
PJM
ETTh
ETTm
WP
SP
MOPEX
MSE
w/o Reflection w/o Toolkit w/o Memory Full Model
1027.76 836.24 551.54 546.87
394.83 358.33 204.54 200.47
38.64 31.21 24.67 23.92
801.89 724.87 712.30 707.96
45.06 42.33 28.30 27.45
35.97 23.71 8.45 8.00
20.51 17.68 2.41 2.36
5102.29 3517.03 1820.92 1719.99
22.72 21.46 17.49 16.90
5.18 4.54 4.63 3.60
MAE
w/o Reflection w/o Toolkit w/o Memory Full Model
15.35 13.53 9.62 9.60
12.44 11.50 9.77 9.50
4.07 3.62 3.14 3.11
10.55 9.46 8.22 8.16
5.47 4.77 3.79 3.74
6.62 3.55 2.18 2.03
4.27 2.86 1.08 1.04
43.48 37.52 28.69 27.40
3.85 2.96 2.55 2.50
1.79 1.36 1.38 1.20
models such as Sundial. While conventional models focus on mapping sequences through static one-step function approximation, CastFlow’s iterative planning and action allow it to adaptively navigate diverse data characteristics. Regarding the suboptimal performance on PJM, where CastFlow trails slightly behind strong baselines such as Chronos, TimeXer, and AlphaCast, we attribute this gap to two primary factors. First, our cross-domain joint training prioritizes distilling generalized reasoning rules over overfitting the specific highfrequency volatilities inherent to PJM. Second, specific dataset characteristics, such as the ambiguous correlation between PJM’s exogenous variables and forecasting targets, limit the efficacy of the multi-view toolkit’s adjustment strategies compared to strong baselines like TimeXer and Chronos. Despite this local trade-off, CastFlow provides a more robust alternative to existing agentic forecasting frameworks. Unlike AlphaCast or TimeReasoner, which rely on direct LLM invocations for numerical generation, CastFlow integrates a reinforcement-learned decision module that optimizes the reasoning trajectory. This approach overcomes the numerical limitations of LLMs by employing an evidence-guided refinement mechanism based on an ensemble forecast baseline, where the agent acts as a reasoning layer over a reliable ensemble forecast baseline established by the foundational anchorer. Through workflow-oriented RLVR, the agent learns to utilize the multi-view toolkit and retrieve experience from the strategy memory, ensuring that improvements are driven by traceable evidence under complex temporal shifts rather than mere memorization of local patterns. C. Ablation Studies 1) Component Ablation: To evaluate the contribution of each core component in CastFlow, we conduct a comprehensive ablation study across diverse energy and streamflow benchmarks. The results in Table III show that the full model consistently achieves the highest forecasting accuracy on both mean squared error (MSE) and mean absolute error (MAE), validating the essential synergy between the multi-view toolkit, strategy memory, and self-correction. The most substantial performance degradation occurs when the reflective validation mechanism is removed. Fundamentally, without the structural safeguard of iterative self-correction, the agent occasionally
produces formatting inconsistencies or sequence length mismatches. To maintain pipeline continuity, such violations inevitably trigger naive fallback mechanisms, such as mean imputation, to fill empty forecasting windows, which lead to severe numerical error spikes. This is particularly evident in the MSE metric for complex and volatile scenarios like the WP and BE datasets, where these fallbacks cause catastrophic deviations. Secondarily, the absence of reflection also hinders the dynamic refinement of tool scheduling and compromises the overall quality of strategy memory construction. Furthermore, excluding the multi-view toolkit forces the framework to rely solely on internal parametric knowledge. This limitation prevents the agent from grounding its reasoning in diagnostic evidence such as trend analysis and the ensemble forecast baseline, visibly reducing overall precision in both absolute and squared errors. Finally, omitting the strategy memory removes a critical stabilizer providing distilled historical strategies, resulting in suboptimal reasoning behaviors and increased MAE across all observed forecasting horizons. This pattern underscores their complementary contributions to forecasting. 2) Multi-View Toolkit Category Ablation: To investigate the granular contributions of specific tool clusters within the multi-view toolkit, we categorize the individual tools into four functional modules based on their diagnostic objectives: the foundational anchorer, the statistical and spectral profiler, the dynamics monitor, and the residual diagnoser. We conduct a leave-one-category-out ablation study across all benchmark datasets, with the comprehensive results presented in Table IV. The evaluation demonstrates that the foundational anchorer is arguably the most critical component. Omitting this module, which is responsible for retrieving and synthesizing the ensemble forecast baseline from historical models, triggers the most severe performance degradation across nearly all datasets. This substantial drop underscores the absolute necessity of establishing a reliable ensemble forecast baseline to ground the agent’s subsequent evidence-guided refinement. The toolkit ablation results further show that the full model achieves optimal performance on the vast majority of datasets, validating the synergistic design of the toolkit. Together with the anchorer, the profiler, monitor, and diagnoser collaboratively provide multi-dimensional diagnostic signals, enabling the specialized forecasting module to effectively rectify biases
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE
11
TABLE IV A BLATION STUDY OF THE M ULTI -V IEW T OOLKIT CATEGORIES . T HE EVALUATION CONFIRMS THE CRITICAL ROLE OF THE F OUNDATIONAL A NCHORER AND THE SYNERGISTIC EFFECTIVENESS OF THE COMPLETE TOOLKIT. B EST RESULTS ARE HIGHLIGHTED IN BOLD .
Settings
Short-term Forecasting
Metrics
Variants
BE
DE
NP
FR
PJM
ETTh
ETTm
WP
SP
MOPEX
MSE
w/o Anchorer w/o Profiler w/o Monitor w/o Diagnoser Full Model
697.35 548.56 547.23 553.86 546.87
270.36 201.87 200.90 201.67 200.47
28.50 24.16 24.66 24.48 23.92
786.70 675.67 695.90 710.00 707.96
47.89 28.15 28.57 28.18 27.45
17.30 7.88 7.90 8.08 8.00
3.53 2.33 2.43 2.38 2.36
2718.42 1821.36 1890.65 1805.12 1719.99
20.17 17.42 19.38 17.49 16.90
5.67 4.69 4.52 4.54 3.60
MAE
w/o Anchorer w/o Profiler w/o Monitor w/o Diagnoser Full Model
13.37 9.60 9.62 9.68 9.60
11.16 9.68 9.66 9.69 9.50
3.53 3.11 3.15 3.12 3.11
10.55 7.59 7.88 8.20 8.16
4.85 3.78 3.82 3.78 3.74
3.00 2.03 2.04 2.07 2.03
1.36 1.05 1.08 1.06 1.04
35.05 28.40 28.96 28.39 27.40
2.62 2.51 2.45 2.53 2.50
1.35 1.37 1.36 1.36 1.19
w/o RLVR
w/o SFT
10.0