CREATE AGENT

statementsupportedAI & ML

docs.snowflake.com ↗

Object: AGENT

Creates a new Cortex Agent object with the specified attributes and specification.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] [ { TEMP | TEMPORARY } ] [ SECURE ] AGENT [ IF NOT EXISTS ] <name>
  [ COPY GRANTS ]
  [ SECURE = { TRUE | FALSE } ]
  [ COMMENT = '<comment>' ]
  [ PROFILE = '<profile_object>' ]
  FROM SPECIFICATION
  $$
    <specification_object>
  $$;

CREATE [ OR REPLACE ] [ SECURE ] AGENT [ IF NOT EXISTS ] <name>
  [ COPY GRANTS ]
  [ COMMENT = '<comment>' ]
  FROM @<stage_path>;

Parameters

NameRequiredDescription
namerequiredString that specifies the identifier (i.e. name) for the agent; must be unique for the schema in which the agent is created. You can create an agent in the PUBLIC schema of your Personal Database by using a fully qualified name in the form "USER$<username>".PUBLIC.<agent_name>. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
{ TEMP | TEMPORARY }optionalSpecifies that the agent persists only for the duration of the session in which you created it. A temporary agent is bound to the creating user, role, and session. It is dropped automatically when the session ends and is not recoverable. TEMP is an accepted abbreviation for TEMPORARY. Creating a temporary agent does not require the CREATE AGENT privilege on the schema. Temporary agents cannot be converted to permanent agents, and they do not support versioning operations such as COMMIT or aliases. For more information, see Working with temporary agents. Default: No value (agent is permanent)
SECURE or SECURE = { TRUE | FALSE }optionalSpecifies whether the agent is secure. Use the SECURE keyword before AGENT, or set the SECURE property to TRUE, to create a secure agent. Setting the property to FALSE creates a non-secure agent. For a secure agent, the complete specification is visible only when the owner role is activated in the session. Roles with only USAGE or MODIFY cannot read the specification through DESCRIBE, GET_DDL, SHOW VERSIONS, or stage paths. For more information, see Secure agents. Default: No value (agent is not secure)
COPY GRANTSoptionalRetains the access privileges from the original agent when you replace it using CREATE OR REPLACE AGENT. When COPY GRANTS is specified, Snowflake copies all privileges granted on the existing agent to the replacement agent, except OWNERSHIP. The replacement agent does not inherit any future grants defined for the agent type in the schema. The role that executes the CREATE OR REPLACE AGENT statement owns the new agent. When COPY GRANTS is not specified, the replacement agent loses all explicit access privileges that were granted on the original agent. It inherits only future grants defined for the agent type in the schema. COPY GRANTS is meaningful only when used with OR REPLACE. If the agent does not already exist, there are no existing grants to copy and the clause has no effect. COPY GRANTS and IF NOT EXISTS are mutually exclusive. You cannot use both in the same statement. Default: No value (grants are not copied)
COMMENT = 'comment'optionalDescription of the agent.
PROFILE = profile_objectoptionalSpecifies the OBJECT value containing agent profile information, such as display name, avatar, and color. Serialize the profile_object into a string as follows:Copy code '{"display_name": "<display_name>", "avatar": "<avatar>", "color": "<color>"}' The following table describes the key-value pairs in this object: Key Type Description display_name String Display name for the agent. avatar String Avatar image file name or identifier. color String Color theme for the agent (such as “blue”, “green”, “red”)ExpandShow lessSee more
FROM SPECIFICATION $$ specification_object $$optionalSpecifies the VARCHAR value containing the settings for an agent as a YAML object. The maximum length of the specification object is 100,000 bytes. Successful creation doesn’t guarantee valid tool specifications; test the agent before deploying it. The YAML object should have the following structure:Copy code models: orchestration: <model_name> orchestration: capabilities: analytical_search: true tool_not_accessible: <accept | reject | legacy> budget: seconds: <number_of_seconds> tokens: <number_of_tokens> instructions: response: '<response_instructions>' orchestration: '<orchestration_instructions>' sample_questions: - question: '<sample_question>' ... tools: - tool_spec: type: '<tool_type>' name: '<tool_name>' description: '<tool_description>' input_schema: type: 'object' properties: <property_name>: type: '<property_type>' description: '<property_description>' required: <required_property_names> ... tool_resources: <tool_name>: <resource_key>: '<resource_value>' ... ... sandbox_config: mount_user_default_workspace: <true | false> artifact_repositories: - <artifact_repository_name> ... The following table describes the key-value pairs in this object: Key Type Description models ModelConfig An optional model configuration for the agent. Includes the orchestration model, for example auto, which lets Snowflake select the model. If not provided, a model is automatically selected. Currently only available for the orchestration step. orchestration OrchestrationConfig An optional orchestration configuration, including budget constraints (seconds, tokens), capabilities such as analytical_search, and tool_not_accessible (accept, reject, or legacy). If tool_not_accessible is omitted, the default is accept. For details, see Inaccessible tool handling. instructions AgentInstructions Optional instructions for the agent’s behavior, including response, orchestration, and sample questions. tools array of Tool An optional list of tools available for the agent to use. Each tool includes a tool_spec with type, name, description, and input schema. Tools may have a corresponding configuration in tool_resources. tool_resources map of ToolResource An optional configuration for each tool referenced in the tools array. Keys must match the name of the respective tool. sandbox_config object An optional configuration for the agent’s sandbox, with the keys mount_user_default_workspace (Boolean) and artifact_repositories (array of artifact repository names). Requires the account parameter CORTEX_AGENT_SANDBOX_DEFAULT_ON to be TRUE; otherwise creating or altering an agent with sandbox_config fails (error 399511). For details, see The sandbox_config section. mcp_servers array of objects An optional list of MCP servers whose tools the agent can use. Each entry has a server_spec with the fully qualified name of an MCP server object. For details, see MCP Connectors.ExpandShow lessSee more
FROM @stage_pathoptionalCreates the agent from files on a stage instead of an inline specification. The stage directory must contain an agent_spec.yaml file at its root; otherwise, the statement fails. For more information, see Cortex Agent versioning.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE AGENT | Schema | Required to create a permanent Cortex Agent. Not required for temporary agents. OWNERSHIP | Agent | Required to replace an existing agent with CREATE OR REPLACE. USAGE | Cortex Search service | Required to run the Cortex Search services in the Cortex Agents request. USAGE | Database, schema, table | Required to access the objects referenced in the Cortex Agents semantic model.

See also

Referenced by