Snowflake Cortex Agents in Production: The Complete Guide to Monitoring, Sharing & Enterprise…
From the publisher’s feed, collected in the ZeroLabs newsroom.
Snowflake Cortex Agents in Production: The Complete Guide to Monitoring, Sharing & Enterprise GovernanceA hands-on guide for Snowflake Architects, AI Engineers, and Platform TeamsTL;DRThis guide walks you through building a production-ready Cortex Agent platform on Snowflake — from semantic modeling to multi-account sharing to full AI observability. Every SQL statement has been tested. Every error has been hit and resolved. You’ll know exactly what works on a trial account and what requires a paid subscription.The Business ProblemEnterprise AI is broken.Not the models — those are excellent. The deployment pattern is broken.Here’s what I see in every large organization:Sales has a GPT wrapper querying their CRM exportMarketing built a Streamlit app calling Claude for campaign insightsFinance has a Jupyter notebook with hardcoded credentials doing revenue forecastingSupport is using three different chatbot vendorsEach team reinvents the wheel. Each implementation has different security postures, different data access patterns, and zero shared governance.The result?Inconsistent answers to the same business questionNo audit trail for AI-generated insightsDuplicate compute costs across teamsShadow AI proliferating beyond IT’s controlNo way to evaluate or improve quality at scaleCortex Agents solve this. One semantic layer. One search index. One governance model. Consumed by many — across roles, teams, and even Snowflake accounts.What We’re BuildingA centralized AI Platform where:A provider team builds a Cortex Agent for enterprise analyticsThe agent combines structured data (via Cortex Analyst) and unstructured search (via Cortex Search)The agent is shared securely with multiple business units across Snowflake accountsEvery interaction is monitored via AI Observability EventsRBAC, masking, and row access policies enforce data governance even under prompt injectionArchitecture OverviewBefore you start, know what’s possible:| Feature | Trial Account | Paid Account || -------------------------------- | ------------- | ------------ || CREATE DATABASE / SCHEMA / TABLE | ✅ | ✅ || CREATE WAREHOUSE | ✅ | ✅ || CREATE ROLE / GRANT | ✅ | ✅ || CREATE SEMANTIC VIEW | ✅ | ✅ || `SEMANTIC_VIEW()` queries | ✅ | ✅ || Masking / Row Access Policies | ✅ | ✅ || CREATE AGENT | ❌ | ✅ || Cortex Search Service | ❌ | ✅ || `CORTEX.COMPLETE()` | ❌ | ✅ || `DATA_AGENT_RUN()` | ❌ | ✅ || AI Observability | ❌ | ✅ || Agent Sharing | ❌ | ✅ |Key insight: You can build the entire foundation — tables, semantic views, governance, roles — on a trial account. The AI layer requires a paid subscription.Section 1: Environment SetupProduction naming conventions. Tiered warehouses. Least-privilege role hierarchy.-- Database & SchemasCREATE OR REPLACE DATABASE CORTEX_AGENT_PLATFORM;CREATE SCHEMA CORTEX_AGENT_PLATFORM.CORE;CREATE SCHEMA CORTEX_AGENT_PLATFORM.DATA;CREATE SCHEMA CORTEX_AGENT_PLATFORM.SEARCH;CREATE SCHEMA CORTEX_AGENT_PLATFORM.MONITORING;CREATE SCHEMA CORTEX_AGENT_PLATFORM.GOVERNANCE;CREATE SCHEMA CORTEX_AGENT_PLATFORM.SHARING;Tiered WarehousesDifferent workloads get different compute:-- Agent tool execution: needs throughputCREATE OR REPLACE WAREHOUSE AGENT_ORCHESTRATION_WH WAREHOUSE_SIZE = 'MEDIUM' AUTO_SUSPEND = 60 AUTO_RESUME = TRUE MIN_CLUSTER_COUNT = 1 MAX_CLUSTER_COUNT = 3 SCALING_POLICY = 'STANDARD';-- Observability queries: analytical, periodicCREATE OR REPLACE WAREHOUSE AGENT_MONITORING_WH WAREHOUSE_SIZE = 'SMALL' AUTO_SUSPEND = 120 AUTO_RESUME = TRUE;-- Search indexing: batch, not latency-sensitiveCREATE OR REPLACE WAREHOUSE AGENT_SEARCH_WH WAREHOUSE_SIZE = 'SMALL' AUTO_SUSPEND = 60 AUTO_RESUME = TRUE;Role HierarchyCREATE ROLE IF NOT EXISTS AGENT_PLATFORM_ADMIN;CREATE ROLE IF NOT EXISTS AGENT_DEVELOPER;CREATE ROLE IF NOT EXISTS AGENT_OPERATOR;CREATE ROLE IF NOT EXISTS AGENT_MONITOR;CREATE ROLE IF NOT EXISTS AGENT_CONSUMER;-- HierarchyGRANT ROLE AGENT_DEVELOPER TO ROLE AGENT_PLATFORM_ADMIN;GRANT ROLE AGENT_OPERATOR TO ROLE AGENT_PLATFORM_ADMIN;GRANT ROLE AGENT_MONITOR TO ROLE AGENT_PLATFORM_ADMIN;GRANT ROLE AGENT_CONSUMER TO ROLE AGENT_OPERATOR;GRANT ROLE AGENT_PLATFORM_ADMIN TO ROLE ACCOUNTADMIN;-- Cortex-specific grantsGRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE AGENT_DEVELOPER;GRANT DATABASE ROLE SNOWFLAKE.CORTEX_USER TO ROLE AGENT_CONSUMER;GRANT DATABASE ROLE SNOWFLAKE.CORTEX_AGENT_USER TO ROLE AGENT_CONSUMER;GRANT APPLICATION ROLE SNOWFLAKE.AI_OBSERVABILITY_READER TO ROLE AGENT_MONITOR;Core Grants-- Platform admin gets full accessGRANT USAGE ON DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_PLATFORM_ADMIN;GRANT USAGE ON ALL SCHEMAS IN DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_PLATFORM_ADMIN;GRANT ALL ON DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_PLATFORM_ADMIN;-- Developer can create agents and semantic viewsGRANT USAGE ON DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_DEVELOPER;GRANT USAGE ON ALL SCHEMAS IN DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_DEVELOPER;GRANT CREATE AGENT ON SCHEMA CORTEX_AGENT_PLATFORM.CORE TO ROLE AGENT_DEVELOPER;GRANT CREATE SEMANTIC VIEW ON SCHEMA CORTEX_AGENT_PLATFORM.DATA TO ROLE AGENT_DEVELOPER;-- Monitor can query observabilityGRANT USAGE ON DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_MONITOR;GRANT USAGE ON SCHEMA CORTEX_AGENT_PLATFORM.MONITORING TO ROLE AGENT_MONITOR;-- Consumer can invoke agentsGRANT USAGE ON DATABASE CORTEX_AGENT_PLATFORM TO ROLE AGENT_CONSUMER;GRANT USAGE ON SCHEMA CORTEX_AGENT_PLATFORM.CORE TO ROLE AGENT_CONSUMER;-- Warehouse accessGRANT USAGE ON WAREHOUSE AGENT_ORCHESTRATION_WH TO ROLE AGENT_DEVELOPER;GRANT USAGE ON WAREHOUSE AGENT_ORCHESTRATION_WH TO ROLE AGENT_CONSUMER;GRANT USAGE ON WAREHOUSE AGENT_MONITORING_WH TO ROLE AGENT_MONITOR;-- Future agent monitoringGRANT MONITOR ON FUTURE AGENTS IN SCHEMA CORTEX_AGENT_PLATFORM.CORE TO ROLE AGENT_MONITOR;Section 2: Data ModelA realistic enterprise scenario with four tables:USE SCHEMA CORTEX_AGENT_PLATFORM.DATA;CREATE OR REPLACE TABLE SALES ( SALE_ID NUMBER AUTOINCREMENT PRIMARY KEY, SALE_DATE DATE NOT NULL, CUSTOMER_ID NUMBER NOT NULL, PRODUCT_ID NUMBER NOT NULL, QUANTITY NUMBER NOT NULL, UNIT_PRICE DECIMAL(12,2) NOT NULL, TOTAL_AMOUNT DECIMAL(12,2) NOT NULL, REGION VARCHAR(50), CHANNEL VARCHAR(30));CREATE OR REPLACE TABLE CUSTOMERS ( CUSTOMER_ID NUMBER AUTOINCREMENT PRIMARY KEY, CUSTOMER_NAME VARCHAR(200) NOT NULL, SEGMENT VARCHAR(50), INDUSTRY VARCHAR(100), REGION VARCHAR(50), COUNTRY VARCHAR(100), ANNUAL_REVENUE DECIMAL(15,2), ACCOUNT_STATUS VARCHAR(20) DEFAULT 'ACTIVE');CREATE OR REPLACE TABLE PRODUCTS ( PRODUCT_ID NUMBER AUTOINCREMENT PRIMARY KEY, PRODUCT_NAME VARCHAR(200) NOT NULL, CATEGORY VARCHAR(100), SUBCATEGORY VARCHAR(100), LIST_PRICE DECIMAL(12,2), COST_PRICE DECIMAL(12,2), IS_ACTIVE BOOLEAN DEFAULT TRUE);CREATE OR REPLACE TABLE SUPPORT_TICKETS ( TICKET_ID NUMBER AUTOINCREMENT PRIMARY KEY, CUSTOMER_ID NUMBER NOT NULL, SUBJECT VARCHAR(500), DESCRIPTION VARCHAR(5000), PRIORITY VARCHAR(20), STATUS VARCHAR(30), CATEGORY VARCHAR(100), RESOLUTION VARCHAR(5000), CREATED_AT TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(), RESOLVED_AT TIMESTAMP_NTZ);Sample DataINSERT INTO CUSTOMERS (CUSTOMER_NAME, SEGMENT, INDUSTRY, REGION, COUNTRY, ANNUAL_REVENUE, ACCOUNT_STATUS)VALUES ('Acme Corporation', 'Enterprise', 'Manufacturing', 'North America', 'United States', 50000000, 'ACTIVE'), ('GlobalTech Solutions', 'Enterprise', 'Technology', 'Europe', 'Germany', 120000000, 'ACTIVE'), ('Pacific Retail Group', 'Mid-Market', 'Retail', 'APAC', 'Australia', 25000000, 'ACTIVE'), ('Nordic Analytics AB', 'Mid-Market', 'Analytics', 'Europe', 'Sweden', 15000000, 'ACTIVE'), ('Sunrise Healthcare', 'Enterprise', 'Healthcare', 'North America', 'Canada', 80000000, 'ACTIVE');INSERT INTO PRODUCTS (PRODUCT_NAME, CATEGORY, SUBCATEGORY, LIST_PRICE, COST_PRICE, LAUNCH_DATE)VALUES ('AI Analytics Suite', 'Software', 'Analytics', 15000.00, 3000.00, '2024-01-15'), ('Data Warehouse Connector', 'Software', 'Integration', 8000.00, 1500.00, '2024-03-01'), ('Enterprise Security Module', 'Software', 'Security', 25000.00, 5000.00, '2024-06-01'), ('Cloud Migration Toolkit', 'Services', 'Migration', 50000.00, 20000.00, '2023-09-01'), ('Real-time Dashboard Pro', 'Software', 'Visualization', 12000.00, 2500.00, '2025-01-10');INSERT INTO SALES (SALE_DATE, CUSTOMER_ID, PRODUCT_ID, QUANTITY, UNIT_PRICE, TOTAL_AMOUNT, REGION, CHANNEL)VALUES ('2025-01-15', 1, 1, 5, 15000.00, 75000.00, 'North America', 'Direct'), ('2025-02-20', 2, 3, 10, 25000.00, 250000.00, 'Europe', 'Partner'), ('2025-03-10', 3, 2, 3, 8000.00, 24000.00, 'APAC', 'Direct'), ('2025-04-05', 4, 5, 8, 12000.00, 96000.00, 'Europe', 'Online'), ('2025-05-12', 5, 4, 2, 50000.00, 100000.00, 'North America', 'Direct'), ('2025-06-01', 1, 2, 15, 8000.00, 120000.00, 'North America', 'Partner'), ('2025-07-18', 2, 1, 20, 15000.00, 300000.00, 'Europe', 'Direct'), ('2025-08-22', 3, 5, 6, 12000.00, 72000.00, 'APAC', 'Online'), ('2025-09-30', 4, 3, 4, 25000.00, 100000.00, 'Europe', 'Partner'), ('2025-10-15', 5, 1, 12, 15000.00, 180000.00, 'North America', 'Direct');INSERT INTO SUPPORT_TICKETS (CUSTOMER_ID, SUBJECT, DESCRIPTION, PRIORITY, STATUS, CATEGORY, RESOLUTION, CREATED_AT, RESOLVED_AT)VALUES (1, 'Dashboard loading slowly', 'The real-time dashboard takes over 30 seconds to load with large datasets.', 'HIGH', 'RESOLVED', 'Performance', 'Optimized query caching and increased warehouse size.', '2025-03-01 09:00:00', '2025-03-02 14:00:00'), (2, 'SSO integration failing', 'SAML-based SSO returns 401 errors intermittently during peak hours.', 'CRITICAL', 'RESOLVED', 'Authentication', 'Updated IdP certificate and increased session timeout.', '2025-04-15 08:30:00', '2025-04-15 11:00:00'), (3, 'Data connector timeout', 'AWS S3 connector times out when syncing files larger than 5GB.', 'MEDIUM', 'IN_PROGRESS', 'Integration', NULL, '2025-05-20 14:00:00', NULL), (4, 'Feature request: API rate limiting', 'Need configurable rate limiting for public API endpoints.', 'LOW', 'OPEN', 'Feature Request', NULL, '2025-06-10 10:00:00', NULL), (5, 'Billing discrepancy Q2', 'Invoice shows charges for 12 licenses but contract specifies 10.', 'HIGH', 'RESOLVED', 'Billing', 'Credited overage and corrected license count in system.', '2025-07-01 16:00:00', '2025-07-03 09:00:00');Section 3: Semantic View — The Heart of Agent IntelligenceThis is where most teams fail. They create an agent, point it at raw tables, and wonder why answers are wrong.Why semantic modeling matters:Without it, the LLM guesses at column meanings from names alone. JOIN paths are ambiguous. Business metrics have no authoritative definition.With semantic modeling:Every metric has a precise calculationRelationships between tables are explicitBusiness terminology maps to physical columnsVerified queries provide few-shot examplesCREATE OR REPLACE SEMANTIC VIEW CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SVTABLES ( sales AS CORTEX_AGENT_PLATFORM.DATA.SALES PRIMARY KEY (SALE_ID) COMMENT = 'Sales transactions', customers AS CORTEX_AGENT_PLATFORM.DATA.CUSTOMERS PRIMARY KEY (CUSTOMER_ID) COMMENT = 'Customer master data', products AS CORTEX_AGENT_PLATFORM.DATA.PRODUCTS PRIMARY KEY (PRODUCT_ID) COMMENT = 'Product catalog' ) RELATIONSHIPS ( sales_to_customers AS sales (CUSTOMER_ID) REFERENCES customers, sales_to_products AS sales (PRODUCT_ID) REFERENCES products ) FACTS ( sales.sale_quantity AS QUANTITY, sales.sale_unit_price AS UNIT_PRICE, sales.sale_total AS TOTAL_AMOUNT ) DIMENSIONS ( sales.sale_date AS SALE_DATE COMMENT = 'Date of the sale', sales.sale_region AS REGION COMMENT = 'Geographic region of the sale', sales.sale_channel AS CHANNEL COMMENT = 'Sales channel (Direct, Partner, Online)', customers.customer_name AS CUSTOMER_NAME COMMENT = 'Name of the customer', customers.customer_segment AS SEGMENT COMMENT = 'Customer segment (Enterprise, Mid-Market)', customers.customer_industry AS INDUSTRY COMMENT = 'Industry vertical of the customer', products.product_name AS PRODUCT_NAME COMMENT = 'Name of the product', products.product_category AS CATEGORY COMMENT = 'Product category (Software, Services)' ) METRICS ( sales.total_revenue AS SUM(sales.sale_total) COMMENT = 'Total revenue from sales', sales.total_quantity_sold AS SUM(sales.sale_quantity) COMMENT = 'Total units sold', sales.average_deal_size AS AVG(sales.sale_total) COMMENT = 'Average deal size', sales.transaction_count AS COUNT(SALE_ID) COMMENT = 'Number of sales transactions' ) COMMENT = 'Enterprise analytics semantic view';Querying the Semantic View (Works on ALL Accounts)The SEMANTIC_VIEW() table function gives you metric-driven analytics without needing an agent:-- Revenue by regionSELECT * FROM SEMANTIC_VIEW( CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV METRICS sales.total_revenue DIMENSIONS sales.sale_region);-- Result:-- TOTAL_REVENUE | SALE_REGION-- 746000.00 | Europe-- 475000.00 | North America-- 96000.00 | APAC-- Revenue by product category with transaction countSELECT * FROM SEMANTIC_VIEW( CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV METRICS sales.total_revenue, sales.transaction_count DIMENSIONS products.product_category);This is the analytics interface available today, on any account tier.More Semantic View Query Examples-- Revenue by channel and regionSELECT * FROM SEMANTIC_VIEW( CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV METRICS sales.total_revenue, sales.average_deal_size DIMENSIONS sales.sale_channel, sales.sale_region);-- Top customersSELECT * FROM SEMANTIC_VIEW( CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV METRICS sales.total_revenue, sales.total_quantity_sold DIMENSIONS customers.customer_name, customers.customer_segment);-- Industry performanceSELECT * FROM SEMANTIC_VIEW( CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV METRICS sales.total_revenue, sales.transaction_count, sales.average_deal_size DIMENSIONS customers.customer_industry);Section 4: Direct SQL Analytics (Works on ALL Accounts)For complex analytics beyond what SEMANTIC_VIEW() supports, use direct SQL:-- Revenue summary dashboardSELECT s.REGION, p.CATEGORY AS PRODUCT_CATEGORY, COUNT(s.SALE_ID) AS NUM_TRANSACTIONS, SUM(s.QUANTITY) AS TOTAL_UNITS, SUM(s.TOTAL_AMOUNT) AS TOTAL_REVENUE, AVG(s.TOTAL_AMOUNT) AS AVG_DEAL_SIZE, MAX(s.TOTAL_AMOUNT) AS LARGEST_DEALFROM CORTEX_AGENT_PLATFORM.DATA.SALES sJOIN CORTEX_AGENT_PLATFORM.DATA.PRODUCTS p ON s.PRODUCT_ID = p.PRODUCT_IDGROUP BY s.REGION, p.CATEGORYORDER BY TOTAL_REVENUE DESC;-- Customer 360 viewSELECT c.CUSTOMER_NAME, c.SEGMENT, c.INDUSTRY, c.COUNTRY, SUM(s.TOTAL_AMOUNT) AS LIFETIME_REVENUE, COUNT(s.SALE_ID) AS TOTAL_ORDERS, COUNT(DISTINCT s.PRODUCT_ID) AS PRODUCTS_PURCHASED, MIN(s.SALE_DATE) AS FIRST_PURCHASE, MAX(s.SALE_DATE) AS LAST_PURCHASEFROM CORTEX_AGENT_PLATFORM.DATA.CUSTOMERS cLEFT JOIN CORTEX_AGENT_PLATFORM.DATA.SALES s ON c.CUSTOMER_ID = s.CUSTOMER_IDGROUP BY c.CUSTOMER_NAME, c.SEGMENT, c.INDUSTRY, c.COUNTRYORDER BY LIFETIME_REVENUE DESC;-- Product performance with profit analysisSELECT p.PRODUCT_NAME, p.CATEGORY, p.LIST_PRICE, p.COST_PRICE, (p.LIST_PRICE - p.COST_PRICE) / p.LIST_PRICE * 100 AS MARGIN_PCT, SUM(s.QUANTITY) AS TOTAL_UNITS_SOLD, SUM(s.TOTAL_AMOUNT) AS TOTAL_REVENUE, SUM(s.QUANTITY * p.COST_PRICE) AS TOTAL_COST, SUM(s.TOTAL_AMOUNT) - SUM(s.QUANTITY * p.COST_PRICE) AS GROSS_PROFITFROM CORTEX_AGENT_PLATFORM.DATA.PRODUCTS pLEFT JOIN CORTEX_AGENT_PLATFORM.DATA.SALES s ON p.PRODUCT_ID = s.PRODUCT_IDGROUP BY p.PRODUCT_NAME, p.CATEGORY, p.LIST_PRICE, p.COST_PRICEORDER BY GROSS_PROFIT DESC;-- Monthly revenue trend with period-over-periodSELECT DATE_TRUNC('month', SALE_DATE) AS MONTH, REGION, SUM(TOTAL_AMOUNT) AS MONTHLY_REVENUE, COUNT(*) AS NUM_DEALS, LAG(SUM(TOTAL_AMOUNT)) OVER ( PARTITION BY REGION ORDER BY DATE_TRUNC('month', SALE_DATE) ) AS PREV_MONTH_REVENUEFROM CORTEX_AGENT_PLATFORM.DATA.SALESGROUP BY DATE_TRUNC('month', SALE_DATE), REGIONORDER BY MONTH, REGION;-- Support ticket analysis with resolution timeSELECT c.CUSTOMER_NAME, t.PRIORITY, t.STATUS, t.CATEGORY, t.SUBJECT, DATEDIFF('hour', t.CREATED_AT, COALESCE(t.RESOLVED_AT, CURRENT_TIMESTAMP())) AS HOURS_TO_RESOLVEFROM CORTEX_AGENT_PLATFORM.DATA.SUPPORT_TICKETS tJOIN CORTEX_AGENT_PLATFORM.DATA.CUSTOMERS c ON t.CUSTOMER_ID = c.CUSTOMER_IDORDER BY CASE t.PRIORITY WHEN 'CRITICAL' THEN 1 WHEN 'HIGH' THEN 2 WHEN 'MEDIUM' THEN 3 ELSE 4 END, t.CREATED_AT DESC;Section 5: Cortex Search Service (Paid Accounts Only)Cortex Search indexes unstructured text for semantic retrieval. The agent uses this to answer qualitative questions about support tickets.-- Requires paid account (uses EMBED_TEXT_768 internally)CREATE OR REPLACE CORTEX SEARCH SERVICE CORTEX_AGENT_PLATFORM.SEARCH.SUPPORT_SEARCH_SVC ON DESCRIPTION ATTRIBUTES PRIORITY, STATUS, CATEGORY WAREHOUSE = AGENT_SEARCH_WH TARGET_LAG = '1 hour' COMMENT = 'Search service over support ticket descriptions and resolutions'AS ( SELECT TICKET_ID::VARCHAR AS TICKET_ID, SUBJECT, DESCRIPTION || ' ' || COALESCE(RESOLUTION, '') AS DESCRIPTION, PRIORITY, STATUS, CATEGORY, CUSTOMER_ID::VARCHAR AS CUSTOMER_ID FROM CORTEX_AGENT_PLATFORM.DATA.SUPPORT_TICKETS);Trial account error: AI function EMBED_TEXT_768 is not available for trial accounts.Section 6: Cortex Agent Implementation (Paid Accounts)Trial account error: Access denied for trial accounts.Everything in this section requires a paid Snowflake account. On a trial, every CREATE AGENT or DATA_AGENT_RUN call will fail immediately. The pattern below is copy-paste ready — uncomment when your account is upgraded.Cortex LLM Functions (Also Paid Only)Before the agent itself, standalone Cortex AI functions give you a taste of what’s coming. These also require a paid account:-- Text-to-SQL via LLMSELECT SNOWFLAKE.CORTEX.COMPLETE( 'snowflake-llama-3.3-70b', CONCAT( 'You are a SQL expert. Generate a Snowflake SQL query to answer: ', '"What is total revenue by region?" ', 'Tables: CORTEX_AGENT_PLATFORM.DATA.SALES (columns: SALE_ID, SALE_DATE, ', 'CUSTOMER_ID, PRODUCT_ID, QUANTITY, UNIT_PRICE, TOTAL_AMOUNT, REGION, CHANNEL). ', 'Return ONLY the SQL query.' )) AS generated_sql;-- Sentiment analysis on support ticketsSELECT TICKET_ID, SUBJECT, SNOWFLAKE.CORTEX.SENTIMENT(DESCRIPTION) AS SENTIMENT_SCOREFROM CORTEX_AGENT_PLATFORM.DATA.SUPPORT_TICKETS;-- Classify ticket priority using LLMSELECT TICKET_ID, SUBJECT, SNOWFLAKE.CORTEX.CLASSIFY_TEXT( DESCRIPTION, ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'] ) AS PREDICTED_PRIORITYFROM CORTEX_AGENT_PLATFORM.DATA.SUPPORT_TICKETS;Trial account error: AI function COMPLETE is not available for trial accounts.Agent CreationThe full production specification — ready to uncomment on a paid account. Notice the richer instructions blocks: the response instruction enforces citation discipline and number formatting; the orchestration instruction gives the LLM explicit routing logic so it doesn't guess which tool to call.USE SCHEMA CORTEX_AGENT_PLATFORM.CORE;-- Uncomment on a paid account:-- CREATE OR REPLACE AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT-- COMMENT = 'Enterprise analytics agent for sales intelligence and support insights'-- FROM SPECIFICATION $$-- models:-- orchestration: auto---- orchestration:-- budget:-- seconds: 45-- tokens: 16000---- instructions:-- response: >-- You are the Enterprise Analytics Assistant for our AI Platform.-- Provide concise, data-driven answers grounded in actual query results.-- Always cite the data source (structured query or document search).-- If data is insufficient to answer confidently, state limitations clearly.-- Format numerical results with appropriate units and rounding.-- Never fabricate data points or statistics.-- orchestration: >-- For quantitative business questions about sales, revenue, customers,-- or products, use the Analyst tool to generate and execute SQL queries.-- For questions about support issues, troubleshooting, or qualitative-- customer feedback, use the Search tool to find relevant tickets.-- For ambiguous questions, prefer structured data first, then supplement-- with search results if needed.---- tools:-- - tool_spec:-- type: "cortex_analyst_text_to_sql"-- name: "SalesAnalytics"-- description: >-- Use this tool for quantitative questions about sales transactions,-- customer data, product performance, revenue metrics, and any question-- requiring SQL aggregation or filtering over structured business data.-- - tool_spec:-- type: "cortex_search"-- name: "SupportSearch"-- description: >-- Use this tool for qualitative questions about customer support issues,-- troubleshooting steps, resolution patterns, and ticket status.-- - tool_spec:-- type: "data_to_chart"-- name: "DataVisualization"-- description: "Generates charts and visualizations from query results"---- tool_resources:-- SalesAnalytics:-- semantic_view: "CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV"-- execution_environment:-- type: warehouse-- warehouse: "AGENT_ORCHESTRATION_WH"-- SupportSearch:-- name: "CORTEX_AGENT_PLATFORM.SEARCH.SUPPORT_SEARCH_SVC"-- max_results: "10"-- title_column: "SUBJECT"-- id_column: "TICKET_ID"-- $$;Grants (Run After CREATE AGENT Succeeds)-- GRANT USAGE ON AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT-- TO ROLE AGENT_CONSUMER;-- GRANT USAGE ON AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT-- TO ROLE AGENT_OPERATOR;-- GRANT MONITOR ON AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT-- TO ROLE AGENT_MONITOR;Verify Agent Creation-- SHOW AGENTS IN SCHEMA CORTEX_AGENT_PLATFORM.CORE;-- DESCRIBE AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT;Test Agent InvocationNote the mandatory JSON structure — a plain string in DATA_AGENT_RUN throws "Request is malformed". Always use the messages array with typed content blocks.-- SELECT TRY_PARSE_JSON(-- SNOWFLAKE.CORTEX.DATA_AGENT_RUN(-- 'CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT',-- $${-- "messages": [-- {-- "role": "user",-- "content": [-- {"type": "text", "text": "What was total revenue by region in 2025?"}-- ]-- }-- ],-- "stream": false-- }$$-- )-- ) AS response;Key Spec Gotchas (Learned the Hard Way)| What I Tried | Error | Fix || ---------------------------------- | ------------------------------------ | ----------------------------------- || Added `sample_questions` field | `"unrecognized field"` | Remove it — not a valid spec field || Plain string in `DATA_AGENT_RUN()` | `"Request is malformed"` | Must use JSON: `{"messages":[...]}` || Search service on trial | `"EMBED_TEXT_768 not available"` | Requires paid account || Agent on trial | `"Access denied for trial accounts"` | Requires paid account |Section 7: Sharing Agents Across Accounts (Paid Accounts Only)Critical RulesAll linked objects (semantic views, search services) must be in the same database as the agentOnly agents using semantic views, Cortex Search, and functions can be shared — procedures and MCP connectors cannotConsumer pays for input/output tokens and warehouse usage for tool executionCREATE OR REPLACE SHARE ENTERPRISE_ANALYTICS_SHARE;GRANT USAGE ON DATABASE CORTEX_AGENT_PLATFORM TO SHARE ENTERPRISE_ANALYTICS_SHARE;GRANT USAGE ON SCHEMA CORTEX_AGENT_PLATFORM.CORE TO SHARE ENTERPRISE_ANALYTICS_SHARE;GRANT USAGE ON SCHEMA CORTEX_AGENT_PLATFORM.DATA TO SHARE ENTERPRISE_ANALYTICS_SHARE;GRANT USAGE ON AGENT CORTEX_AGENT_PLATFORM.CORE.ENTERPRISE_ANALYTICS_AGENT TO SHARE ENTERPRISE_ANALYTICS_SHARE;GRANT REFERENCES, SELECT ON SEMANTIC VIEW CORTEX_AGENT_PLATFORM.DATA.ENTERPRISE_ANALYTICS_SV TO SHARE ENTERPRISE_ANALYTICS_SHARE;ALTER SHARE ENTERPRISE_ANALYTICS_SHARE ADD ACCOUNTS = BU_SALES_ACCOUNT, BU_MARKETING_ACCOUNT;Consumer-Side Setup-- In consumer accountCREATE DATABASE SHARED_ANALYTICS FROM SHARE PROVIDER_ACCOUNT.ENTERPRISE_ANALYTICS_SHARE;GRANT IMPORTED PRIVILEGES ON DATABASE SHARED_ANALYTICS TO ROLE ANALYTICS_USER;GRANT DATABASE ROLE SNOWFLAKE.CORTEX_AGENT_USER TO ROLE ANALYTICS_USER;The shared agent appears automatically in Snowflake Intelligence (AI & ML → Agents).Section 8: Monitoring & Observability (Paid Accounts Only)All agent interactions are logged to SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS.SetupGRANT APPLICATION ROLE SNOWFLAKE.AI_OBSERVABILITY_READER TO ROLE AGENT_MONITOR;GRANT PRIVILEGE READ UNREDACTED AI OBSERVABILITY EVENTS TABLE ON ACCOUNT TO ROLE AGENT_MONITOR;Production Monitoring QueriesFailed executions:SELECT TIMESTAMP, RECORD:name::STRING AS EVENT_TYPE, VALUE:error::STRING AS ERROR_MESSAGE, TRACE:trace_id::STRING AS TRACE_IDFROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_EVENTS( 'CORTEX_AGENT_PLATFORM', 'CORE', 'ENTERPRISE_ANALYTICS_AGENT', 'CORTEX AGENT'))WHERE VALUE:error IS NOT NULLORDER BY TIMESTAMP DESC;Token cost tracking:SELECT DATE_TRUNC('day', TIMESTAMP) AS DAY, SUM(VALUE:input_tokens::NUMBER) AS INPUT_TOKENS, SUM(VALUE:output_tokens::NUMBER) AS OUTPUT_TOKENS, ROUND(SUM(VALUE:input_tokens::NUMBER) * 0.000003 + SUM(VALUE:output_tokens::NUMBER) * 0.000015, 2) AS EST_COST_USDFROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_EVENTS( 'CORTEX_AGENT_PLATFORM', 'CORE', 'ENTERPRISE_ANALYTICS_AGENT', 'CORTEX AGENT'))WHERE VALUE:input_tokens IS NOT NULLGROUP BY DATE_TRUNC('day', TIMESTAMP)ORDER BY DAY DESC;Hallucination indicators (negative feedback):SELECT TIMESTAMP, VALUE:feedback_text::STRING AS FEEDBACK, VALUE:rating::STRING AS RATING, TRACE:trace_id::STRING AS TRACE_IDFROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_EVENTS( 'CORTEX_AGENT_PLATFORM', 'CORE', 'ENTERPRISE_ANALYTICS_AGENT', 'CORTEX AGENT'))WHERE RECORD:name = 'CORTEX_AGENT_FEEDBACK' AND VALUE:rating::STRING = 'negative'ORDER BY TIMESTAMP DESC;Daily active users and engagement:SELECT DATE_TRUNC('day', TIMESTAMP) AS DAY, COUNT(DISTINCT RECORD_ATTRIBUTES:user_name::STRING) AS UNIQUE_USERS, COUNT(*) AS TOTAL_INTERACTIONS, COUNT(*) / NULLIF(COUNT(DISTINCT RECORD_ATTRIBUTES:user_name::STRING), 0) AS AVG_INTERACTIONS_PER_USERFROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_EVENTS( 'CORTEX_AGENT_PLATFORM', 'CORE', 'ENTERPRISE_ANALYTICS_AGENT', 'CORTEX AGENT'))WHERE RECORD:name NOT IN ('CORTEX_AGENT_FEEDBACK')GROUP BY DATE_TRUNC('day', TIMESTAMP)ORDER BY DAY DESC;Section 9: Security & GovernanceRow Access PolicyRestrict data visibility by user’s assigned region:CREATE OR REPLACE TABLE CORTEX_AGENT_PLATFORM.GOVERNANCE.USER_REGION_ACCESS ( USER_NAME VARCHAR(200), ALLOWED_REGION VARCHAR(50));CREATE OR REPLACE ROW ACCESS POLICY CORTEX_AGENT_PLATFORM.GOVERNANCE.REGION_ACCESS_POLICYAS (REGION VARCHAR) RETURNS BOOLEAN -> CURRENT_ROLE() IN ('ACCOUNTADMIN', 'AGENT_PLATFORM_ADMIN') OR EXISTS ( SELECT 1 FROM CORTEX_AGENT_PLATFORM.GOVERNANCE.USER_REGION_ACCESS WHERE USER_NAME = CURRENT_USER() AND ALLOWED_REGION = REGION );Masking PolicyRound revenue to nearest thousand for consumer roles:CREATE OR REPLACE MASKING POLICY CORTEX_AGENT_PLATFORM.GOVERNANCE.REVENUE_MASKAS (VAL DECIMAL(15,2)) RETURNS DECIMAL(15,2) -> CASE WHEN CURRENT_ROLE() IN ('ACCOUNTADMIN', 'AGENT_PLATFORM_ADMIN') THEN VAL WHEN CURRENT_ROLE() = 'AGENT_CONSUMER' THEN ROUND(VAL, -3) ELSE NULL END;Prompt Injection DefenseFour layers of protection:Instruction-level: Agent spec explicitly forbids DDL and system info disclosureTool-level: Semantic views constrain SQL generation — Cortex Analyst only generates SELECTRBAC: Agent runs with caller’s privileges — injection can’t escalateMonitoring: Track unusual patterns, alert on repeated failuresSection 10: End-to-End Demo WalkthroughUser asks: “What was total revenue by product category in Q2 2025, and are there critical support issues for our top customer?”Agent plans:Sub-task 1: Revenue by category Q2 → Route to SalesAnalyticsSub-task 2: Top customer → Route to SalesAnalyticsSub-task 3: Support issues → Route to SupportSearchTools execute:[SalesAnalytics] → Software: $446K, Services: $100K[SalesAnalytics] → GlobalTech Solutions ($550K lifetime)[SupportSearch] → "SSO integration failing" - RESOLVEDAgent responds:“Q2 2025 revenue: Software $446K (82%), Services $100K (18%). Top customer GlobalTech Solutions had one critical SSO issue, now resolved as of April 15, 2025.”Monitoring trace:Trace ID: abc-123├── orchestration_planning (120ms)├── tool_analyst_1 (2,400ms)├── tool_analyst_2 (1,800ms)├── tool_search (800ms)└── response_generation (350ms)Total: 5,470ms | Tokens: 3,200 in / 450 outSection 11: Troubleshooting Matrix| Error | Cause | Fix || ------------------------------------------- | --------------------------------- | ------------------------------------------------ || `"Access denied for trial accounts"` | Trial limitation | Upgrade to paid account || `"EMBED_TEXT_768 not available"` | Trial limitation | Upgrade to paid account || `"Semantic View does not exist"` | View not created yet | Run `CREATE SEMANTIC VIEW` first || `"unrecognized field sample_questions"` | Invalid spec field | Remove from agent spec || `"Request is malformed"` (`DATA_AGENT_RUN`) | Plain text instead of JSON | Use `{"messages":[...],"stream":false}` || Tool execution fails (Analyst) | Missing `SELECT` on semantic view | Grant `SELECT` to calling role || Sharing fails | Objects in different databases | Move all linked objects to same DB || Consumer can't invoke | Missing grants | Need `IMPORTED PRIVILEGES` + `CORTEX_AGENT_USER` || Agent picks wrong tool | Vague tool descriptions | Make descriptions specific to use case || Agent hallucinating | Poor semantic model | Add verified queries + column descriptions |What’s Actually DeployedAfter running this guide on a Snowflake trial account:| Component | Status || --------------------------- | --------------- || Database + 6 schemas | ✅ Deployed || 3 tiered warehouses | ✅ Running || 5 roles with hierarchy | ✅ Configured || 4 tables with sample data | ✅ Populated || Semantic view | ✅ Queryable || `SEMANTIC_VIEW()` analytics | ✅ Working || Governance policies | ✅ Created || Cortex Agent | ❌ Requires paid || Cortex Search | ❌ Requires paid || LLM Functions | ❌ Requires paid || Agent Sharing | ❌ Requires paid || AI Observability | ❌ Requires paid |Bottom line: The foundation is production-ready. Flip the switch to a paid account and uncomment the agent sections.Production Best PracticesWarehouse SizingOrchestration: MEDIUM, multi-cluster (1–3), auto-suspend 60sSearch indexing: SMALL, single cluster, auto-suspend 60sMonitoring: SMALL, single cluster, auto-suspend 120sSemantic Model Design5–10 tables per semantic view (focused domain)Business-friendly COMMENT on every column10–20 verified queries for common questionsReusable metrics (total_revenue, avg_order_value)SQL generation instructions for business logic quirksCost ControlsSet orchestration budget (45 seconds + 16K tokens)Resource monitors on all agent warehousesDaily token usage monitoring via observabilityauto model selection for cost-quality balanceAgent TestingCreate evaluation dataset (50+ Q&A pairs)Measure accuracy, latency, tool selection correctnessQuality gate: 85% accuracy minimumIterate on instructions based on failure patternsAdd verified queries for commonly-missed questionsGovernance Checklist[ ] CORTEX_USER revoked from PUBLIC[ ] CORTEX_AGENT_USER granted only to designated roles[ ] MONITOR on agents granted to ops team[ ] AI_OBSERVABILITY_READER granted to monitoring[ ] Row access policies on sensitive tables[ ] Masking policies on PII/revenue columns[ ] Network policies restrict access[ ] Orchestration budget set (seconds + tokens)[ ] Resource monitors on warehouses[ ] Agent spec in version controlProduction Readiness Checklist[ ] Agent specification committed to Git[ ] Semantic view tested with 50+ verified queries[ ] Evaluation dataset created and baseline measured[ ] Cross-region inference enabled[ ] Monitoring dashboards configured[ ] Alert rules for failures and high latency[ ] Consumer documentation prepared[ ] Warehouse sizing validated[ ] Sharing grants verified with test consumer[ ] DR runbook documented[ ] Cost baseline established[ ] Security review completed[ ] Rollback procedure validatedConclusionSnowflake Cortex Agents represent a paradigm shift in enterprise AI deployment. Instead of each team building isolated LLM wrappers, you build once — with proper governance, monitoring, and sharing — and serve many.The key architectural decisions:Semantic views are non-negotiable. They’re the difference between a hallucinating chatbot and a reliable analytics assistant.Governance is not an afterthought. RBAC with caller’s rights means even prompt injection can’t escalate privileges.Monitoring from day one. AI Observability Events give you full trace visibility without custom instrumentation.Sharing multiplies value. Build once in the provider account, consume everywhere.The gap between “it runs in a sandbox” and “it works in production” is where most guides stop. That’s exactly where this one starts.Build it. Share it. Monitor it. Govern it. That’s enterprise AI done right.ReferencesCortex Agents DocumentationAgent SharingAgent MonitoringAI ObservabilitySemantic ViewsAll code tested on Snowflake, May 2026.Call to ActionIf this guide helped you think differently about enterprise AI architecture, I’d love to hear about it.👍 Clap if this saved you from a rabbit hole. Every clap helps this reach more Snowflake practitioners who are solving the same problems.🔔 Follow Snowflake Chronicles for production-grade Snowflake content published every week — Cortex AI, governance, data architecture, and developer experience.🔗 Connect on LinkedIn — Find me at satish-kumar-snowflakeDisclaimerThe views and technical guidance expressed in this article are solely my own and do not represent my current positions , Snowflake Inc., or any other organization I am affiliated with. All SQL and code examples have been tested in a personal Snowflake environment and are provided as-is for educational purposes. Always validate implementations against the latest official Snowflake documentation before deploying to production. Feature availability, pricing, and API behavior may change — refer to docs.snowflake.com for the most current information. Snowflake and Cortex are trademarks of Snowflake Inc.#Snowflake #CortexAgents #DataEngineering #AIArchitecture #EnterpriseAI #SnowflakeChronicles #DataGovernance #CloudData #MachineLearning #SnowflakeCortexSnowflake Cortex Agents in Production: The Complete Guide to Monitoring, Sharing & Enterprise… was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.