Cortex Sense (Private Preview)

Cortex Sense builds a working model of your business from metadata your account already produces, such as query history, semantic views, dbt models, dashboards, and tags, so that Cortex Agents answer questions accurately. This topic walks you through building your first context. For how it works, what it ingests, access control, and costs, see Cortex Sense reference.

Before you begin

  • Your account is enrolled in the private preview. If it isn’t, contact your account team to be nominated.
  • You have the CoCo CLI or CoCo Desktop. You can’t build a context in Snowsight.
  • You have ACCOUNTADMIN, or an administrator who can run Step 1 for you.

Step 1: Grant the required database role

Only ACCOUNTADMIN can grant the database role required to build a context.

USE ROLE ACCOUNTADMIN;

GRANT DATABASE ROLE SNOWFLAKE.CORTEX_SENSE_BUILDER TO ROLE <builder_role>;

The role that builds a context owns it. Querying a context needs only USAGE, which you grant in Step 5. See Access control and RBAC.

Step 2: Scope a use case

Open CoCo, then type /settings and point both Inference Connection and SQL Connection at the account where you want to build the context, using the role from Step 1. The skill needs both.

Invoke the cortex-sense skill and name a use case. Start with one business domain.

> $cortex-sense set up Cortex Sense for sales

CoCo scans your account and proposes a scope:

Domain — sales · proposed from a fresh scan
──────────────────────────────────────────────────
Tables         SALES.CORE.* (~40)
               ORDERS, ORDER_ITEMS, PRODUCTS, CUSTOMERS, …
               SALES.ANALYTICS.* (~17)
Dashboards     2 Streamlit apps
               REVENUE_DASHBOARD · SELLER_PERFORMANCE
Semantic views REVENUE_SV, DELIVERY_SV
Tags           CERTIFICATION_STATUS (2 in scope)
──────────────────────────────────────────────────
type to refine — or: help · deeper · looks good

Refine the scope in plain language, for example “include the MARKETING.LEADS schema” or “exclude anything in staging or test”. CoCo then asks about inputs it can’t detect, such as a dbt path or business documentation. Answer what’s useful and skip the rest; you can add more later.

CoCo also asks which database and schema to create the context in.

Indexing starts only after you confirm the scope. Scope drives both answer quality and indexing cost, so see What Cortex Sense can ingest and Best practices.

Step 3: Build the context

Confirm the scope:

> looks good

The build runs in the background and takes a few hours. While it runs, you can give CoCo facts you already know (for example, “ARR lives in ANALYTICS.MARTS.FACT_ARR”), add inputs, or note questions to test against.

When the build finishes, the context is live for the role that built it, stored as a CORTEX SENSE object in the database and schema you chose, named <database>.<schema>."sales".

Step 4: Check the build

Type /sense to open the Cortex Sense page and pick a domain, or /sense <name> to go straight to one. Tab moves between tabs and ? lists the keys.

Important

/sense is available in the CoCo CLI only. It isn’t in CoCo Desktop yet. You can still build, query, and refine a context from Desktop through the cortex-sense skill.

The page has six tabs:

TabWhat it shows
OverviewBuild state, eval score, records waiting, and who has access.
ScopeEverything the object reads, grouped by kind. Exclusions sit under the rule they carve into.
InboxCorrections to what Cortex Sense believes about your data. 1–3 filter, A approves, E edits.
StatusBuild state, when it last changed, and which sources are processed or still in progress.
AccuracyEval results. 1–3 switch views; lift is accuracy minus the pre-context baseline.
ActivateOptions for using this object in an agent or a CoCo skill. CoCo CLI 1.1.94 and later.

A ready state means that the build finished, not that every source succeeded. Check Status for per-source progress. For more about serving a context, see Where you can use Cortex Sense.

Step 5: Grant access to other roles

Grant USAGE to each role that should be able to query the context:

GRANT USAGE ON CORTEX SENSE <database>.<schema>."sales" TO ROLE <analyst_role>;

Quote the context name. Unquoted, sales resolves to SALES and the statement fails. During the private preview, give each role access to one context only. See One context per role.

Context access isn’t data access: table-level RBAC still applies.