Use Business Ontology with Cortex Agents (Preview)¶
Business Ontology stores governed definitions of your business terms, metrics, and entities, organized into domains. A Cortex Agent can use those definitions when it answers questions about your business data. For example, to answer “What was Net Revenue last quarter?”, the agent looks up the approved meaning of Net Revenue and then queries a Semantic View that you’ve configured for the agent. The same agent can also answer questions about the definitions themselves, such as “How is Net Revenue defined?”
Overview¶
In this topic, you create an agent that answers questions about your business data using Business Ontology:
- Confirm that your ontology is searchable with CoCo.
- Create the agent. The agent looks up the governed definition, formula, and synonyms of a term in Business Ontology, then uses Cortex Analyst to query the Semantic View that you configure for the agent.
- Grant access to the agent, the ontology domains, and the Semantic View.
- Test the agent with questions about your data and about the definitions.
If you use Cortex Sense, you can connect a Cortex Sense context to the agent instead. The context includes your Business Ontology, so the agent doesn’t need its own Business Ontology search. See Use Business Ontology through Cortex Sense.
Prerequisites¶
Before you begin, verify the following:
- Business Ontology is enabled for your account, with at least one domain containing approved nodes. Draft and deprecated nodes aren’t searchable.
- Your role, and the roles that will call the agent, can read the ontology domains that you want the agent to search. See Search access to a node and Business Ontology access control.
- Your ontology content is indexed for search on your deployment. Step 1 verifies this prerequisite.
- You have a Semantic View that implements the metrics the agent should answer questions about, and a warehouse that Cortex Analyst can use to run queries.
- You have an existing database and schema in which to create an agent, with
CREATE AGENTon the schema and the required privileges on the containing database and schema. - You have configured the roles, authentication, and warehouse required to call Cortex Agents. See Access control and authentication.
- You have CoCo connected to the same account for the search check in Step 1.
Step 1: Confirm that your ontology is searchable¶
In CoCo, run the following command to search for a node that you know is approved. Use the same role that agent requests use: a search result for one role doesn’t mean that another role can find the node. Replace the example query with words from your own ontology:
Check that the results include the expected domain-qualified name, kind, and definition, along with any recorded
formula and synonyms. A Business Ontology node is an account-level object. Its identity is the domain-qualified name
(domain.node), not a database-and-schema-qualified object name.
If the search returns no results, confirm the node and your access before you treat the content as unindexed:
- The node is approved. Open it in Snowsight and check its status. Draft and deprecated nodes aren’t searchable.
- Your role can find nodes in the node’s domain: it has
READ,MODIFY,OWNERSHIP, orSUGGESTon that domain, and the grant was made before the last index refresh. See Search access to a node.
This search is the indexing check. When the results include the node’s domain-qualified name, that node is in the search index. If an approved node that you can open is still absent, it isn’t indexed on your deployment yet, or a recent edit hasn’t reached the index. Contact your Snowflake account team. Creating an agent doesn’t make unindexed content searchable.
The search object type is business-ontology. The corresponding corpus name in an agent specification is
businessOntology. Use each spelling in its respective configuration.
Step 2: Create the agent¶
Run the following CREATE AGENT statement in a SQL worksheet. Replace the placeholders with your database, schema, Semantic View, and warehouse names. Choose an unused agent name; this example doesn’t replace an existing agent.
Keep these three settings when adapting the specification:
experimental.EnableSnowscopeBusinessOntologySearch: truepermits the agent to search the ontology corpus. The default isfalse.tools[].tool_spec.type: snowscope_searchselects the built-in search tool.tool_resources.business_ontology.corpus: businessOntologyselects the ontology corpus. The resource keybusiness_ontologymust match the tool’sname.
CREATE AGENT doesn’t validate these three values. A misspelled flag, tool type, or corpus name is accepted without
an error, and the agent then doesn’t search the ontology. After you create the agent, run
DESCRIBE AGENT to confirm the stored values:
The agent_spec column returns the specification as JSON. Check that it contains
"EnableSnowscopeBusinessOntologySearch":true, "type":"snowscope_search", and "corpus":"businessOntology".
The instructions require the agent to look up the governed definition before it queries data, report the definition it used, and report missing results instead of substituting generic definitions. Keep these behaviors if you customize the agent. Instructions guide model behavior; test them as described in Step 4 rather than treating them as a guarantee.
To cover more domains, add a Cortex Analyst tool for each Semantic View and describe in each tool’s description
which data it covers. Business Ontology search results don’t name the assets that implement a node, so the tool
descriptions are how the agent chooses which Semantic View to query.
To build an agent that answers only questions about definitions, remove the sales_analyst tool, its tool
resource, and the instructions that refer to it.
Step 3: Grant access¶
To let an existing role use the agent, run the following statement with a role authorized to grant access. Replace
<role_name> with the intended role:
This statement grants access to the agent only. Users also need the database, schema, warehouse, and Cortex Agents privileges described in Access control and authentication, and the privileges required to query the Semantic View. See Additional privileges for tools.
Two access checks apply to each request:
- Business Ontology search returns only nodes in domains that the requesting role can read. Granting
USAGEon the agent doesn’t grant access to ontology domains. See Search access to a node. - Cortex Analyst queries run with the caller’s privileges on the Semantic View and its tables. Access to an ontology domain doesn’t grant access to the data that implements its nodes.
Users with different access can receive different results for the same question. Verify both allowed and restricted requests with the roles that your users use to call the agent.
For the role used by an agent request, see User requirements. Don’t assume that switching your active role in Snowsight changes the role used by agent requests, including requests from the agent playground.
Search access to a node¶
A role can find a node in Business Ontology search when it has one of the following privileges on the node’s domain, granted to the role directly or inherited from a role granted to it:
READMODIFYOWNERSHIPSUGGEST
USAGE on a domain isn’t enough.
Keep the following in mind when you grant access:
- Grants apply to one domain. A privilege on a domain applies only to that domain. Grant access on each domain whose nodes the agent should find.
- System-defined roles don’t automatically receive custom roles. If a custom role owns a domain,
ACCOUNTADMINcan’t find that domain’s nodes until you grant the custom role toACCOUNTADMIN, or grantACCOUNTADMINaccess on the domain. - Access changes apply at the next index refresh. Search uses the domain privileges recorded when the search index was last refreshed. After you grant or revoke access to a domain, the change can take up to 6 hours to apply to search results.
For example, to let the role that calls the agent find the nodes in a domain, run the following statement with a role authorized to grant access:
For more information, see Business Ontology access control.
Step 4: Test the agent¶
To test the agent in Snowsight, select AI & ML » Agents in the navigation menu, select the agent, and enter each question in the agent playground. You can also query the agent using the Cortex Agents Run API. Use names from your own ontology and Semantic View.
Start with questions about your data:
- “What was Net Revenue last quarter?”
- “Show Net Revenue by region for this year.”
- “Which customers count as Active Customers this month?”
For each response, check that the agent calls business_ontology before sales_analyst, and that it names the
governed definition it used. Compare the generated SQL with the node’s recorded formula. If they differ, review the
Semantic View metric or the ontology definition before you make the agent available to users.
Then ask questions about the definitions:
- “How is Net Revenue defined? Return the recorded formula.”
- “What’s the difference between Gross Revenue and Net Revenue?”
- “What are the synonyms for Net Revenue?”
Check that the agent returns the domain, kind, definition, and formula when one is available, without querying data.
Also test these cases:
- Unknown node: Ask about an invented name, such as Widget Velocity Quotient. Don’t use a real industry term, because one of your domains might already define it. The agent should report that it couldn’t find an accessible governed definition, rather than supply a generic one.
- Restricted domain: Choose an approved node and ask about it twice, once as a caller with
READon its domain and once as a caller without access. Change the grants, wait for an index refresh, and then run both requests. The first response should return the node’s definition, and its formula if one is recorded. The second shouldn’t disclose either. Run both halves: the agent reports a missing definition the same way for an access denial as for a node that isn’t indexed or approved, so the restricted request alone doesn’t prove that access checks are working. - Ambiguous name: If two domains use the same name, check that the agent identifies the domains rather than silently choosing one definition.
- Synonym: Ask about a node by one of its recorded synonyms instead of its name. The agent should return that node’s definition and use it for any data query.
- Metric outside the Semantic View: Ask for the value of a governed metric that the Semantic View doesn’t implement. The agent should return the definition and say that it can’t compute the value, rather than approximate it with a different metric.
If the agent guesses, review its tool configuration and instruction blocks before making it available to users.
Troubleshooting¶
Use the following checks to investigate missing or unexpected results:
| Symptom | Checks |
|---|---|
| The agent answers from general knowledge. | Run DESCRIBE AGENT and check that agent_spec contains the three values listed in Step 2. Also check that the instructions require searching before answering. |
| The agent queries data without looking up a definition. | Check that the orchestration instructions call business_ontology before the Cortex Analyst tool for questions that use a business term or metric. |
| A computed value doesn’t match the governed definition. | Compare the Semantic View metric expression with the node’s recorded formula. The formula is documentation: Cortex Analyst computes values from the Semantic View, not from the ontology. |
| Every search returns no results. | Repeat Step 1 with the role that agent requests use. Confirm the node is approved, that role can find nodes in its domain (see Search access to a node), and the corpus spelling is businessOntology. If you granted access recently, wait for the next index refresh. If an approved node is still missing for a role that can find nodes in its domain, it isn’t in the search index yet. |
| The Step 1 search finds the node, but the agent doesn’t. | The agent request probably uses a role that can’t find nodes in the domain. Check the role used for agent requests (see User requirements) and grant that role READ on the domain. |
| A specific node is missing. | Confirm the node is approved, not draft or deprecated, and that the caller can find nodes in its domain. A grant on one domain doesn’t apply to another domain. Repeat the Step 1 search. If the node is approved and accessible but still missing, it isn’t in the search index yet. Try a synonym. |
| Two users receive different results. | Compare their access to the ontology domains, their privileges on the Semantic View and its tables, and the roles used for their agent requests. |
The search reports Unknown object type(s): businessOntology. | Use --types=business-ontology in cortex search object. Use businessOntology only as the agent corpus name. |
The search reports an unknown object type for business-ontology. | Your version of CoCo doesn’t support Business Ontology search. Update CoCo to the latest version and repeat the search. |
| Results don’t reflect a recent edit, grant, or revoke. | Ontology edits and changes to domain access might not be available to the agent immediately. Repeat the Step 1 search after the next index refresh. |
The CoCo authoring flag EnableBusinessOntology is separate from the agent specification setting
EnableSnowscopeBusinessOntologySearch. Enabling authoring tooling doesn’t configure ontology search for an agent.
Limitations¶
The following limitations apply to the Business Ontology search tool in this preview:
- No representations in search results: The search tool returns a node’s definition, formula, and synonyms, but not the tables, views, columns, or Semantic Views bound to it. Give the agent a data tool for each Semantic View it should query, or use a Cortex Sense context, which ingests representations.
- Formulas are documentation: A returned formula reflects what a steward recorded. The agent doesn’t run it. Cortex Analyst computes values from the Semantic View definition, so keep the two consistent.
- Approved nodes only: Draft and deprecated nodes aren’t available through this search tool.
- Index freshness: Results come from a search index, so recent ontology edits might not appear immediately. Propagation to the index can take up to 6 hours, so a newly created, updated, or approved node might not be returned by search until the index refreshes. The same applies to changes in domain access: after you grant a role access to a domain, the role might not find the domain’s nodes until the index refreshes, and after you revoke access, the role might still find them until then.
- No inherited domain access: A privilege on a domain applies only to that domain. Grant access on each domain whose nodes the agent should find.
- Client validation: Ontology search is verified in the Snowsight agent playground. Availability and equivalent behavior in Snowflake CoWork haven’t been validated. Test your intended client before a broader rollout.
Use Business Ontology through Cortex Sense¶
Business Ontology is integrated with Cortex Sense. A Cortex Sense context ingests approved nodes, their relationships, and their representations, alongside metadata about your tables, Semantic Views, and query history. An agent connected to the context uses the governed definitions and the assets bound to them when it answers questions about your data, so it doesn’t need a separate Business Ontology search tool.
For setup instructions and requirements for connecting a Cortex Sense context to a Cortex Agent, see Where you can use Cortex Sense.