Snowflake for Gen AI · Topic 4 of 13
Cortex Agents and Cortex Code in Snowsight and the CLI
What Cortex Agents are and which tools they use, plus Snowflake Cortex Code in the Snowsight UI and the command line, with the roles and traps to know.
- 4 min
- Agent = plan, tools, reflect, answer; tools include Analyst, Search, custom tools, Data to Chart, web search.
- Roles for agents:
CORTEX_USERorCORTEX_AGENT_USER. - Agents run through
agent:run; threads hold context.
What it is
A Cortex Agent is a managed AI agent that plans a request, calls tools and writes an answer, all inside Snowflake's governed environment. Where Cortex Analyst only turns questions into SQL and Cortex Search only retrieves text, an agent decides which of them to use, and in what order.
Snowflake Cortex Code (shown in the documentation as CoCo) is a different thing: an AI coding agent for people who build in Snowflake. It writes and fixes SQL and Python, understands your roles, schemas and best practices, and helps with data engineering, analytics, machine learning and agent building.
How it works
Cortex Agents
An agent runs a loop: plan, use tools, reflect, answer. It can repeat the loop within one request. You guide it with natural language instructions and pick a model or use auto.
| Tool | Use |
|---|---|
| Cortex Analyst | SQL over structured data through a semantic view |
| Cortex Search | Retrieval from unstructured data |
| Custom tools | Stored procedures and UDFs for business logic |
| Data to Chart | Visualizations from data other tools returned |
| Web search | Public internet; must be enabled at the account level |
| MCP connectors | Tools on remote Model Context Protocol servers |
Agents are created in Snowsight, with SQL, or through the REST API, and are called with the agent:run API. Threads keep conversation context across turns. Calling an agent needs the SNOWFLAKE.CORTEX_USER or SNOWFLAKE.CORTEX_AGENT_USER database role, plus privileges on the agent and on every object its tools use.
When a scenario mixes numbers and documents in one question, the answer is an agent with Cortex Analyst and Cortex Search as tools.
Cost controls exist for agents: an orchestration budget per run, resource budgets that monitor an agent's spend, and per user quotas.
Cortex Code
Cortex Code runs under your role. It sees only what your RBAC allows, so it cannot widen access.
Cortex Code in Snowsight
It is built into Workspaces and admin pages. It helps author SQL and Python notebooks, supports account administration tasks and knows the file you are viewing. Proposed changes appear as a visual diff that you accept or reject. It cannot reach files on your computer.
Cortex Code Command Line (CLI)
The CLI runs in a local shell and connects with your existing Snowflake authentication. It can read and write local repositories, run bash and git and execute SQL. The command is cortex, and a first run starts a setup wizard that lists connections from ~/.snowflake/connections.toml, the same file the Snowflake CLI (snow) uses.
| Capability | Snowsight | CLI |
|---|---|---|
| Local files and git | No | Yes |
| Visual diff | Yes | Terminal based |
| Account administration pages | Yes | Not described |
| Needs install | No | Yes |
Prerequisites for the CLI are the SNOWFLAKE.CORTEX_USER or SNOWFLAKE.CORTEX_AGENT_USER database role and the Snowflake CLI. Plan mode asks you to confirm each action. Restricted session scope can make a session read only.
Cortex Code inherits your role. Running it as ACCOUNTADMIN gives the agent that power, so work with the least privileged role that fits the task.
Common mistakes
Calling an agent "Cortex Analyst with chat". An agent orchestrates several tools; Analyst is one tool.
Enabling web search by default. It must be enabled at the account level.
Granting only the role. Agents also need privileges on the agent object and on each tool's objects.
Expecting Snowsight Cortex Code to edit local repos. Only the CLI (or Desktop) reaches local files.
Confusing Cortex Code with Cortex Analyst. Code helps developers write code; Analyst answers business questions.
What to remember for the exam
- Agent = plan, tools, reflect, answer; tools include Analyst, Search, custom tools, Data to Chart, web search.
- Roles for agents:
CORTEX_USERorCORTEX_AGENT_USER. - Agents run through
agent:run; threads hold context. - Cortex Code works within your RBAC.
- Snowsight: diff view, no local files. CLI:
cortexcommand, local repos,bashandgit.
Check yourself
Which feature chooses between Analyst and Search at run time?
A Cortex Agent.
What can the CLI do that Snowsight Cortex Code cannot?
Read and write local repositories and run
bashandgit.What limits what Cortex Code can see?
The role you use, because it operates within your RBAC permissions.
Topic 4 of 13 in Snowflake for Gen AI
Test yourself on Snowflake for Gen AI
The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.