- Categories:
Context functions (General)
IS_ AGENT_ ACTIVATED (SYS_ CONTEXT function)¶
Returns the VARCHAR value 'TRUE' if an agent is active in the current execution context.
Syntax¶
Arguments¶
'SNOWFLAKE$CURRENT'Specifies that you want to call a function to return context information about the current execution context.
'IS_AGENT_ACTIVATED'Calls the IS_AGENT_ACTIVATED function. This function takes no additional arguments and returns whether any agent is active in the current execution context.
Returns¶
The function returns one of the following VARCHAR values:
'TRUE'if any agent is active in the current execution context.'FALSE'if no agent is active.
The function returns 'TRUE' in the following scenarios:
- A Snowflake first-party agent is executing the query, including:
- A named Cortex Agent (data agent)
- A stateless lite agent invoked through a Snowflake CoCo client (CLI, Desktop, or web) or the REST API
- A query initiated through Snowflake CoWork
- An external agent is executing the query, including:
- An agent that connects to Snowflake through a managed MCP server
- A session opened by a SERVICE_AGENT user, which is automatically agent-active
- A session using a custom OAuth integration
configured with
IS_AGENTIC = TRUE
To compare this return value against the BOOLEAN value TRUE or FALSE, cast the return value to BOOLEAN. For example:
2026_06 behavior change bundle
When the 2026_06 behavior change bundle is enabled in your account, when you call this
function through SYS_CONTEXT, it returns BOOLEAN instead of the VARCHAR
string 'TRUE' or 'FALSE'.
Existing casts, such as ::BOOLEAN or ::NUMBER, continue to work unchanged.
For the return type of every property and function by namespace, see SYS_CONTEXT return types.
Examples¶
The following example checks whether any agent is active in the current execution context:
Masking policy to restrict agent access¶
You can use IS_AGENT_ACTIVATED in a masking policy to mask sensitive data when an agent runs a query:
When an agent-initiated query accesses the ssn column, only the last four digits are visible.
Direct user queries see the full value.