Expedition. Free, on-demand.

Technical tracks for practitioners, outcomes for leaders.

One interface is requested for self-service analytics. You want to keep the token consumption low and need to design around multiple sub-domains for different personas. A semantic view defines the metrics and relationships up front, so the LLM generates SQL from agreed definitions instead of inventing them.

Machines fail, output drops, and every production manager asks questions. Can you ensure they get answers from the same data?

In this post I build one operations intelligence agent in Snowflake that answers production, quality and supply questions in one conversational interface and backs every number with a query and data. Cortex Agents, Cortex Analyst, Cortex Search, Semantic View Autopilot and SNOWFLAKE.CORTEX.DATA_AGENT_RUN are generally available.

Industrial Operations Agent

In this post you learn how to:

  • Split an operational domain into reusable semantic views using Domain Modelling and Personas
  • Define rates and inventory snapshots so they aggregate correctly
  • Combine Cortex Analyst and Cortex Search tools in one Cortex Agent
  • Test an agent with expected answers, follow-ups and unsupported questions
  • Use synthetic data and inject errors for Quality Assurance

The full, runnable code is in the developer guide Build an Industrial Operations Intelligence Agent.

Design semantic views for multiple domains

The main challenge was to design one agent for multiple domains and personas. The goal was a single conversational interface that personas across several factory sites could use to answer the same kinds of questions consistently.

Cross-domain analytics are hard because you don't want to duplicate definitions across domain views. A semantic view can import definitions from another view, but I kept this demo simple: separate domain views plus a small cross-domain view. One semantic view should cover one domain or one set of questions. I designed the semantic views around the three domains and added Cortex Search for unstructured data. A small, dedicated cross-domain semantic view can handle the questions that span domains. These turned out to be a small set, mostly executive reporting.

For more on scoping, see Best practices for scoping and organizing semantic views. The design is intentionally simple in this demo.

The source data was of poor quality, so I first built a Verified Query Repository of hand-written queries and let Semantic View Autopilot learn from them. This was an effective way to get started. The demo follows the actual design.

Inject a known failure into synthetic factory data

The demo uses synthetic data: three sites, two products, six assets and 540 production runs from January through March 2026. The GENERATOR table function produces the same data set on every run.

The data contains one built-in disruption. Asset A-001 at site S-01 shows problems from February 10–16: higher downtime, more rejects and less good output. The process keeps running and recovers. Each persona looks at the same problem from a different angle at a different point in the process.

Three personas investigate the same event:

Three parallel investigations by the production manager, quality lead and supply planner

The agent reports the results but doesn't analyze them. It doesn't diagnose the causes of the rejects or the downtime; that's up to the responsible staff.

One Cortex Agent with five tools

The design is deliberately simple: one agent, three structured tools and two document tools.

Architecture: Cortex Analyst tools over three semantic views, Cortex Search tools over two document collections
  • Cortex Analyst tools answer quantitative questions through the Manufacturing, Quality and Supply Chain semantic views.
  • Cortex Search tools retrieve text: documented review workflows and investigation notes with historical context.

One agent serves all three personas and routes each question to the right tool.

The semantic views hold the meaning. The agent doesn't know what a metric means, but it knows which tool to ask. Other clients can reuse the same semantic layer.

Avoid averaging percentages in semantic view metrics

Agents make mistakes when formulas and definitions are vague.

A daily rejection rate averaged over a week isn't the weekly rejection rate. The Quality view defines it as a ratio of totals:

inspection.rejected_unit_rate_pct AS
  100.0 * SUM(inspection.REJECTED_UNITS)
        / NULLIF(SUM(inspection.INSPECTED_UNITS), 0)
  COMMENT = 'Weighted rejection percentage: ratio of summed quantities, not mean daily percentage.'

NULLIF returns NULL when no units were inspected, so the rate shows as undefined instead of a misleading 0% or a division error.

Model inventory snapshots with NON ADDITIVE BY

Daily demand and shipments are flows, so you can add them up. Inventory and backlog are end-of-day balances. Summing a week of backlog gives a meaningless number, and the agent presents it with confidence.

The Supply Chain view uses NON ADDITIVE BY to take the closing balance from the latest date in the group:

supply.closing_backlog_snapshot NON ADDITIVE BY (supply.balance_day)
  AS SUM(supply.CLOSING_BACKLOG_UNITS)
  COMMENT = 'Unfulfilled demand carried forward; select the requested closing date.'

Each view also carries AI_SQL_GENERATION and AI_QUESTION_CATEGORIZATION instructions: never add maintenance repair minutes to downtime, ask for a date range when none is given, and recognize that on-time delivery can't be calculated from daily flow data.

Check the views before the agent

Before any AI is involved, query the views directly. This query should return A-001 with 1,260 downtime minutes and 62.50% availability:

SELECT * FROM SEMANTIC_VIEW(
    INDUSTRIAL_OPERATIONS_DEMO.DEMO.MANUFACTURING_SV
    DIMENSIONS production.asset_identifier
    METRICS production.total_downtime_minutes, production.availability_pct
    WHERE production.run_day BETWEEN '2026-02-10'::DATE AND '2026-02-16'::DATE
)
ORDER BY total_downtime_minutes DESC, asset_identifier;

Two Cortex Search services cover two kinds of documents:

  • Procedures and Documentation Search: review workflows with version, applicability and approval status as attributes.
  • Operational Knowledge Search: investigation notes and historical context.

The unstructured examples also use synthetic text. The agent distinguishes between a note and an approved procedure.

Configure the agent specification

CREATE AGENT ... FROM SPECIFICATION creates the agent from a YAML document that lists the tools and their resources. The specification also defines the Cortex Analyst tools:

tools:
  - tool_spec:
      type: cortex_analyst_text_to_sql
      name: Quality_Analyst
      description: >-
        Analyze inspection summaries, inspected and rejected quantities, and
        weighted rejection rates by run, asset, site, product, and date.
        Not batch release, detailed deviations, or specification compliance.

tool_resources:
  Quality_Analyst:
    semantic_view: INDUSTRIAL_OPERATIONS_DEMO.DEMO.QUALITY_SV
    execution_environment:
      type: warehouse
      warehouse: INDUSTRIAL_OPERATIONS_WH

Each tool description says what the tool is for and what it isn't for, which keeps routing reliable.

The orchestration instructions add the conversational rules:

  • Preserve dates, site, product and asset across follow-ups.
  • Ask for missing scope instead of guessing.
  • Label the evidence for cross-domain questions, and query each domain with matching scope. Don't invent record-level joins across tools.
  • Never substitute zero for missing evidence, and describe associations, not causes.

The full specification is in the guide.

Test a Cortex Agent with deterministic data

Deterministic data makes tests reproducible. Every sample question has an exact expected answer.

QuestionExpected toolExpected answer
Which asset had the most downtime during February 10–16, 2026?Manufacturing AnalystA-001, 1,260 downtime minutes
How did A-001's rejected-unit rate change from February 3–9 to February 10–16?Quality Analyst89 / 6,902 = 1.29% → 490 / 4,900 = 10.00%: +8.71 percentage points
What was the S-01/P-01 closing backlog on February 16, and when did it next reach zero?Supply Chain Analyst500 units on February 16; zero again on March 1, with 16 units of inventory
Which customer orders were delivered late at S-01 on February 16?NoneNo customer orders in the data; no invented orders

The last row is a negative case. The agent should report that no matching tool or data exists rather than make something up.

Then ask a follow-up: "For that asset, compare output and availability with February 3–9." The agent should keep A-001 in scope and report 6,902 units at 97.08% availability against 4,900 units at 62.50%.

You can run the same tests from SQL with SNOWFLAKE.CORTEX.DATA_AGENT_RUN, which returns the answer, the generated SQL and the tool results as JSON.

Key takeaways for building operations agents

  • Domain Modelling works very well for designing agents
  • Product Management techniques like defining personas are very useful in the design of the semantic views
  • Synthetic data with injected errors help in Quality Assurance of agents
  • With good domain design, the cross-domain question set turned out to be relatively small and very manageable

Build it yourself with the full SQL and agent specification in Build an Industrial Operations Intelligence Agent.

Updated Dec 3, 2026

This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances