Demand Forecasting Agent

Agent Description:

The Demand Forecasting AI Agent automates the multi-step forecasting process: extracting sales ledgers from API endpoints, mapping seasonal impact factors from SQL databases, and fetching real-time industry drivers via external JSON payloads. The results are aggregated to produce adjusted, time-bound forecasts accompanied by explicit, data-backed reasoning.

Purpose and Components
  • Purpose: This agent is designed to predict future product demand by synthesizing internal historical sales data with seasonal impacts and external market variables. It enables supply chain and IT operations teams to move beyond simple linear projections by incorporating event-based multipliers and real-world industry trends into their planning cycles.

    The agent improves operational foresight and inventory optimization by:

    • Automating the extraction and baseline calculation of historical sales data.

    • Applying categorized seasonal multipliers (e.g., promotional events) directly from SQL databases.

    • Translating external industry sentiments into objective mathematical impact weights.

    • Standardizing disparate date and numeric formats for seamless cross-category calculation.

    • Generating clear, human-readable demand projections for management review.

  • Components:
    • SalesReaderAgent: Extracts transaction history, standardizes dates, and calculates baseline demand by category.

    • SeasonalityReaderAgent: Queries internal databases to identify event-based impact factors and temporal multipliers.

    • IndustryReaderAgent: Extracts external market trends and converts sentiment (Positive/Negative) into mathematical multipliers.

    • Demand Forecasting Agent (Parent): Merges all inputs to calculate final adjusted unit forecasts and generates a human-readable reasoning report.

Supported Capabilities
  • API integration for historical sales and industry trend retrieval

  • SQL database querying for seasonal impact factors

  • Date standardization to ISO 8601 (YYYY-MM-DD format)

  • Sentiment-to-Weight mapping (Positive: 1.1x, Negative: 0.9x)

  • Multi-factor mathematical demand adjustment (Forecast = Baseline \times Seasonal \times Industry)

  • Automated reasoning generation for forecast adjustments

  • Human-readable executive reporting

LLM Used
  • OPENAI GPT_4O_MINI for the parent forecasting engine and all specialized data-reading sub-agents.
    Note: To learn more about the LLM and to modify its behavior, refer to the Configuring LLM settings section.

Sub-Agents

1. Sales Reader Agent

  • Role:Data Reader.
  • Scope: Extracts transactions like product ID, quantity sold, revenue, and date.
  • Description: Uses the requests_get tool to fetch historical sales data. Standardizes dates to YYYY-MM-DD, groups transactions by Category, and calculates baseline demand by summing the Units Sold.

2. Seasonality Reader Agent

  • Role:Seasonality Analyst
  • Scope:Reads from a seasonality table and maps event-based multipliers to categories.
  • Description: Uses the SQL Toolkit to query the seasonality_factors table. Extracts category, event name, and numerical impact factors, compiling them into a structured object for the aggregator.

3. Industry Reader Agent

  • Role:Data Extractor
  • Scope:Reads trend-driven growth factors per product category.
  • Description: Parses external JSON payloads for market events. Translates sentiment into numerical weights (1.1 for "Positive" events, 0.9 for "Negative" events) and maps these drivers to specific categories.

4. Demand Forecasting Agent

  • Role:Demand Forecaster.
  • Scope:Merges outputs from all subagents and calculates adjusted demand forecasts.
  • Description: Ingests the three datasets. Multiplies the baseline units by the internal seasonal factor and the external industry multiplier. Outputs a final, human-readable report with explicit reasoning.
Tools Used:
  • Request - Get: Fetches the historical sales data (sales_demand_input.json) and external market trends (industry_demand_input.json).

  • SQL - Toolkit: Queries the SQLite database (seasonality_demand.sql) to retrieve internal seasonal impact multipliers.

Note: For details on modifying the Tools, refer Tools Library section.
Agent Workflow Behavior Summary
  1. Ingestion: The SalesReaderAgent, SeasonalityReaderAgent, and IndustryReaderAgent run simultaneously to fetch baselines, internal seasonal impacts, and external market sentiments.

  2. Standardization: Dates are formatted, baselines are summed by category, and textual sentiments are converted into math multipliers (for example, 1.1x).

  3. Calculation: The Demand Forecasting Agent merges the inputs, applying the formula: Forecast = Baseline × Seasonal_Factor × Industry_Trend

  4. Final Output: A human-readable text report detailing the forecasted units per category, accompanied by the explicit reasoning path used for the calculation.

Sample Questions:
  • Forecast demand for our Sensors and Robotics categories for the next six months.

  • What is the demand forecast for AI Processors over the next two quarters, and what are the primary events driving that number?