Cortex Agents Run API¶
There are two methods to interact with an Agent:
Build an agent object and reference this agent object in a request to the
agent:run
API.Call
agent:run
directly without an agent object. You provide the configuration in the request body ofagent:run
.
Both methods use streaming APIs that respond with the server-sent events specified under Streaming Responses
.
Agent run request with agent object¶
POST /api/v2/databases/{database}/schemas/{schema}/agents/{name}:run
Sends a user query to the agent object and returns its response as a stream of events.
Path parameters¶
Parameter |
Description |
---|---|
|
(Required) The database containing the agent. You can use the |
|
(Required) The schema containing the agent. You can use the |
|
(Required) The name of the agent. |
Request headers¶
Header |
Description |
---|---|
|
(Required) Authorization token. See Authentication. |
|
(Required) application/json |
Request body¶
Field |
Type |
Description |
---|---|---|
|
integer |
The thread ID for the conversation. If thread_id is used, then parent_message_id must be passed as well. |
|
integer |
The ID of the parent thread in case you are forking the interaction. The initial parent_message_id should be 0. |
|
array of Message |
If thread_id and parent_message_id are passed in the request, messages includes the current user message in the conversation. Else, messages includes the conversation history and the current message. Messages contains both user queries and assistant responses in chronological order. |
|
Configures how the agent should select and use tools during the interaction. Controls whether tool use is automatic, required, or whether specific tools should be used. |
Example
{
"thread_id": 0,
"parent_message_id": 0,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is the total revenue for 2023?"
}
]
}
],
"tool_choice": {
"type": "auto",
"name": [
"analyst_tool",
"search_tool"
]
}
}
Agent run without an agent object¶
POST /api/v2/cortex/agent:run
Sends a user query to the Cortex Agents service provided in the request body and returns its response. Interacts with the agent without creating an agent object.
Note
Before September 1st, 2025, the request and response schemas for the agent:run
API were different from the schema listed in this document. Previously, the orchestration was static and the same sequence of tools was used to generate an answer. agent:run
now has an updated schema for both the request and response. In addition, the API now dynamically orchestrates and iterates to arrive at the final response. We recommend using the schema described in this document for an improved end-user experience.
To use the legacy schema and behavior, use the following schema:
{
"model": "claude-4-sonnet",
"messages": [
{"role":"user", "content": [] }
]
}
Request headers¶
Header |
Description |
---|---|
|
(Required) Authorization token. See Authentication. |
|
(Required) application/json |
Request body¶
Field |
Type |
Description |
---|---|---|
|
integer |
The thread ID for the conversation. If thread_id is used, then parent_message_id must be passed as well. |
|
integer |
The ID of the parent thread in case you are forking the interaction. The initial parent_message_id should be 0. |
|
array of Message |
If thread_id and parent_message_id are passed in the request, messages includes the current user message in the conversation. Else, messages includes the conversation history and the current message. Messages contains both user queries and assistant responses in chronological order. |
|
Configures how the agent should select and use tools during the interaction. Controls whether tool use is automatic, required, or whether specific tools should be used. |
|
|
LLM configuration for each step of the request. Currently only available for the |
|
|
Custom instructions for the Agent. |
|
|
array of Tool |
List of tools available for the agent to use. Tools may have a corresponding configuration in tool_resources. |
|
map of ToolResource |
Configuration for each tool referenced in the tools array. Keys must match the name of the respective tool. |
Example
{
"thread_id": 0,
"parent_message_id": 0,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is the total revenue for 2023?"
}
]
}
],
"tool_choice": {
"type": "auto",
"name": [
"analyst_tool",
"search_tool"
]
},
"models": {
"orchestration": "claude-4-sonnet"
},
"instructions": {
"response": "You will respond in a friendly but concise manner",
"orchestration": "For any query related to revenue we should use Analyst; For all policy questions we should use Search",
"system": "You are a friendly agent ..."
},
"tools": [
{
"tool_spec": {
"type": "generic",
"name": "get_weather",
"description": "Fetch the delivery revenue for a location.",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
}
},
"required": [
"location"
]
}
}
],
"tool_resources": {
"get_revenue": {
"type": "function",
"execution_environment": {
"type": "warehouse",
"warehouse": "MY_WH"
},
"identifier": "DB.SCHEMA.UDF"
}
}
}
Streaming responses¶
The agent:run
API provides streaming responses. The server streams back events. This allows you to display responses in your application, token-by-token, as they are generated by the Agent.
Each event streamed in the API response has a strictly typed schema. You can find a list of all of the events in the following section and select to which ones you’d like to subscribe.
The last event sent by the API is a response
event. This event contains the entire agent output. You can use this as
the agent’s final response. For any non-streaming clients, you can subscribe to this event because it is the logical aggregation of all prior events. If you don’t want to use streaming responses, wait for the response
event and ignore all prior events.
The majority of the other events streamed can be split into two categories: Delta
and Content Items
.
Delta
events represent a single token generated by the Agent. By listening to these events, you can create
a typewriter effect. The main delta events are response.thinking.delta
, which
represents a reasoning token, and response.text.delta
, which represent an answer token.
Content Item
events represent elements from the content
array in the final agent response.
Note
Make sure your application can handle unknown event types.
Example Response
event: response.status
data: {"message":"Planning the next steps","status":"planning"}
event: response.thinking.delta
data: {"content_index":0,"text":"\nThe user is asking for a"}
event: response.thinking.delta
data: {"content_index":0,"text":" chart showing the"}
...
...
...
event: response.status
data: {"message":"Reviewing the results","status":"reasoning_agent_stop"}
event: response.status
data: {"message":"Forming the answer","status":"proceeding_to_answer"}
response
¶
Event streamed when the final response is available. This is the last event emitted, it represents the aggregation of all other events previously streamed.
Field |
Type |
Description |
---|---|---|
|
string |
The role for the message. Always |
|
array of MessageContentItem |
The content generated by the agent. |
Example
{
"role": "assistant",
"content": [
{
"type": "chart",
"chart": {
"tool_use_id": "toolu_123",
"chart_spec": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"data\":{...},\"mark\":\"bar\"}"
}
}
]
}
response.text
¶
An event streamed when a text content block is done streaming, including all the aggregated deltas for a particular content index.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
A text result from the agent |
|
array of Annotation |
Any annotations attached to the text result (e.g. citations) |
|
boolean |
Whether this text content is the agent asking for more information from the end user. |
Example
{
"content_index": 0,
"text": "Lorem ipsum dolor...",
"annotations": [
{
"type": "cortex_search_citation",
"index": 0,
"search_result_id": "cs_61987ff6-6d56-4695-83c0-1e7cfed818c7",
"doc_id": "4ac085cb-82d0-4eb4-94f3-2672aa0599a2",
"doc_title": "Earnings Report",
"text": "The revenue for 2025 was..."
}
],
"is_elicitation": false
}
response.text.delta
¶
Event streamed when a new output text delta is generated.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
The text delta |
|
boolean |
Whether this text content is the agent asking for more information from the end user. |
Example
{
"content_index": 0,
"text": "Hello",
"is_elicitation": false
}
response.text.annotation
¶
Event streamed when an annotation is added to a text content.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
integer |
The index in the annotation array this |
|
The annotation object being added. |
Example
{
"content_index": 0,
"annotation_index": 0,
"annotation": {
"type": "cortex_search_citation",
"index": 0,
"search_result_id": "cs_61987ff6-6d56-4695-83c0-1e7cfed818c7",
"doc_id": "4ac085cb-82d0-4eb4-94f3-2672aa0599a2",
"doc_title": "Earnings Report",
"text": "The revenue for 2025 was..."
}
}
response.thinking
¶
An event streamed when a thinking content block is done streaming, including all the aggregated deltas for a particular content index.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
Thinking tokens from the agent |
Example
{
"content_index": 0,
"text": "To answer your question I must..."
}
response.thinking.delta
¶
Event streamed when a thinking delta is generated.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
The thinking token |
Example
{
"content_index": 0,
"text": "lorem ipsum"
}
response.tool_use
¶
An event streamed when the agent requests a tool use.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (e.g. cortex_search, cortex_analyst_text2sql) |
|
string |
The unique identifier for this tool instance |
|
object |
The structured input for this tool. The schema of this object should will vary depending on the tool spec. |
|
boolean |
Whether the tool use is executed on the client side. |
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"type": "cortex_analyst_text2sql",
"name": "my_cortex_analyst_semantic_view",
"input": {
"location": "San Francisco, CA"
},
"client_side_execute": "true"
}
response.tool_result
¶
Event streamed when a tool finishes executing, including the tool result.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (e.g. cortex_search, cortex_analyst_text2sql) |
|
string |
The unique identifier for this tool instance |
|
array of ToolResultContent |
The content on the tool result |
|
string |
The status of tool execution |
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"type": "cortex_analyst_text2sql",
"name": "my_cortex_analyst_semantic_view",
"content": [
{
"type": "json",
"json": {
"answer": 42
}
}
],
"status": "success"
}
response.tool_result.status
¶
Status update for a specific tool use.
Field |
Type |
Description |
---|---|---|
|
string |
Unique identifier for this tool use. |
|
string |
The type of the tool (e.g. cortex_search, cortex_analyst_text2sql) |
|
string |
Enum for the current state. |
|
string |
A more descriptive message expanding on the current status. |
Example
{
"tool_use_id": "toolu_123",
"tool_type": "cortex_analyst_text2sql",
"status": "Executing SQL",
"message": "Executing query 'SELECT * FROM my_table'"
}
response.tool_result.analyst.delta
¶
An delta event streamed for the Cortex Analyst tool execution
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (always cortex_analyst_text2sql for this event) |
|
string |
The unique identifier for this tool instance |
|
The content delta |
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"tool_type": "cortex_analyst_text2sql",
"tool_name": "my_cortex_analyst_semantic_view",
"delta": {
"text": "The...",
"think": "Thinking...",
"sql": "SELECT...",
"sql_explanation": "This...",
"query_id": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"verified_query_used": false,
"result_set": {
"statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"resultSetMetaData": {
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
},
"data": [
[
"row1 col1",
"row1 col2"
],
[
"row2 col1",
"row2 col2"
]
]
},
"suggestions": {
"index": 0,
"delta": "What..."
}
}
}
response.tool_result.sql_explanation.delta
¶
A delta event streamed for the SQL explanation tool execution
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (always sql_explanation for this event) |
|
string |
The unique identifier for this tool instance |
|
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"tool_type": "sql_explanation",
"tool_name": "my_sql_explanation_tool",
"delta": {
"text": "This query selects all columns"
}
}
response.table
¶
An event streamed when a table content block is added.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
The ID of the tool use that generated this table |
|
string |
The query id of the sql query that generated this data |
|
The SQL results to render a table. Matches the schema from Snowflake’s SQL API ResultSet (https://docs.snowflake.cn/en/developer-guide/sql-api/reference#resultset) |
|
|
string |
The title for this table |
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"query_id": "6ac75378-6337-48a6-80ab-6de48dd680eb",
"result_set": {
"statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"resultSetMetaData": {
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
},
"data": [
[
"row1 col1",
"row1 col2"
],
[
"row2 col1",
"row2 col2"
]
]
},
"title": "Revenue by Month"
}
response.chart
¶
An event streamed when a chart content block is added.
Field |
Type |
Description |
---|---|---|
|
integer |
The index in the response content array this event represents |
|
string |
The ID of the tool use that generated this chart |
|
string |
The vega-lite chart specification serialized as a string |
Example
{
"content_index": 0,
"tool_use_id": "toolu_123",
"chart_spec": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"data\":{...},\"mark\":\"bar\"}"
}
response.status
¶
Status update for the agent execution.
Field |
Type |
Description |
---|---|---|
|
string |
Enum for the current state. |
|
string |
A more descriptive message expanding on the current status. |
Example
{
"status": "executing_tool",
"message": "Executing tool `my_analyst_tool`"
}
error
¶
Sent when a fatal errors is encountered.
Field |
Type |
Description |
---|---|---|
|
string |
The Snowflake error code |
|
string |
The error message |
|
string |
The unique identifier for this request |
Example
{
"code": "399504",
"message": "Error during execution",
"request_id": "61987ff6-6d56-4695-83c0-1e7cfed818c7"
}
Schemas¶
AgentInstructions
¶
Field |
Type |
Description |
---|---|---|
|
string |
These custom instructions are displayed when the Agent generates the final response based on the tools executed. |
|
string |
These custom instructions are displayed when the Agent is planning which tools to use |
|
string |
Instructions always shown to the Agent |
Example
{
"response": "You will respond in a friendly but concise manner",
"orchestration": "For any query related to revenue we should use Analyst; For all policy questions we should use Search",
"system": "You are a friendly agent ..."
}
Annotation
¶
Field
Type
Description
type
string
The citation type (always
cortex_search_citation
)
index
integer
The index of the citation in the search results.
search_result_id
string
The unique identifier for the search result.
doc_id
string
The unique identifier for the document.
doc_title
string
The title of the document.
text
string
The text excerpt from the document used as the citation.
Example
{ "type": "cortex_search_citation", "index": 0, "search_result_id": "cs_61987ff6-6d56-4695-83c0-1e7cfed818c7", "doc_id": "4ac085cb-82d0-4eb4-94f3-2672aa0599a2", "doc_title": "Earnings Report", "text": "The revenue for 2025 was..." }
ChartContent
¶
Field |
Type |
Description |
---|---|---|
|
string |
The ID of the tool use that generated this chart |
|
string |
The vega-lite chart specification serialized as a string |
Example
{
"tool_use_id": "toolu_123",
"chart_spec": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"data\":{...},\"mark\":\"bar\"}"
}
CortexAnalystSuggestionDelta
¶
Field |
Type |
Description |
---|---|---|
|
integer |
The index of the suggestion array this delta represents |
|
string |
The text delta for the suggestion in this index |
Example
{
"index": 0,
"delta": "What..."
}
CortexAnalystToolResultDelta
¶
Field |
Type |
Description |
---|---|---|
|
string |
A text delta from Cortex Analyst’s final response. |
|
string |
A text delta from Cortex Analyst’s reasoning steps. |
|
string |
A delta from Cortex Analyst’s SQL output. Currently, the entire SQL query comes in a single event but we may stream the SQL token-by-token in the future. |
|
string |
A delta from Cortex Analyst’s explanation of what the SQL query does |
|
string |
The query id once SQL execution begins |
|
boolean |
Whether a verified query was used to generate this response |
|
The results from SQL execution. Matches the schema from Snowflake’s SQL API ResultSet (https://docs.snowflake.cn/en/developer-guide/sql-api/reference#resultset) |
|
|
A delta from Cortex Analyst’s suggested questions. This is sent when Analyst cannot answer the question due to missing information or other failures. |
Example
{
"text": "The...",
"think": "Thinking...",
"sql": "SELECT...",
"sql_explanation": "This...",
"query_id": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"verified_query_used": false,
"result_set": {
"statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"resultSetMetaData": {
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
},
"data": [
[
"row1 col1",
"row1 col2"
],
[
"row2 col1",
"row2 col2"
]
]
},
"suggestions": {
"index": 0,
"delta": "What..."
}
}
ExecutionEnvironment
¶
Configuration for server-executed tools.
Field |
Type |
Description |
---|---|---|
|
string |
The type of execution environment, currently only |
|
string |
The name of the warehouse (case-sensitive, if it is an unquoted identifier, provide the name in all-caps). |
|
integer |
The query timeout in seconds |
Example
{
"type": "warehouse",
"warehouse": "MY_WAREHOUSE",
"query_timeout": "60"
}
Message
¶
Represents a single message in the conversation. Can be either from the user or the assistant.
Field |
Type |
Description |
---|---|---|
|
string |
Identifies who sent the message - either the user or the assistant. User messages typically contain queries, while assistant messages contain responses and tool results. |
|
array of MessageContentItem |
Array of content elements making up the message. Can include text, tool results, or custom content types. |
Example
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is the total revenue for 2023?"
}
]
}
MessageContentItem
¶
Field
Type
Description
type
string
The content type (always
chart
).
chart
The chart.
Example
{ "type": "chart", "chart": { "tool_use_id": "toolu_123", "chart_spec": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v5.json\",\"data\":{...},\"mark\":\"bar\"}" } }
Field
Type
Description
type
string
The content type (always
table
).
table
The table.
Example
{ "type": "table", "table": { "tool_use_id": "toolu_123", "query_id": "6ac75378-6337-48a6-80ab-6de48dd680eb", "result_set": { "statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9", "resultSetMetaData": { "partition": 0, "numRows": 0, "format": "jsonv2", "rowType": [ { "name": "my_column", "type": "VARCHAR", "length": 0, "precision": 0, "scale": 0, "nullable": false } ] }, "data": [ [ "row1 col1", "row1 col2" ], [ "row2 col1", "row2 col2" ] ] }, "title": "Revenue by Month" } }
Field
Type
Description
text
string
A text result from the agent
annotations
array of Annotation
Any annotations attached to the text result (e.g. citations)
is_elicitation
boolean
Whether this text content is the agent asking for more information from the end user.
type
string
The content type (always
text
).Example
{ "text": "Lorem ipsum dolor...", "annotations": [ { "type": "cortex_search_citation", "index": 0, "search_result_id": "cs_61987ff6-6d56-4695-83c0-1e7cfed818c7", "doc_id": "4ac085cb-82d0-4eb4-94f3-2672aa0599a2", "doc_title": "Earnings Report", "text": "The revenue for 2025 was..." } ], "is_elicitation": false, "type": "text" }
Field
Type
Description
type
string
The content type (always
thinking
).
thinking
The thinking content.
Example
{ "type": "thinking", "thinking": { "text": "To answer your question I must..." } }
Field
Type
Description
type
string
The content type (always
tool_result
).
tool_result
The tool result.
Example
{ "type": "tool_result", "tool_result": { "tool_use_id": "toolu_123", "type": "cortex_analyst_text2sql", "name": "my_cortex_analyst_semantic_view", "content": [ { "type": "json", "json": { "answer": 42 } } ], "status": "success" } }
Field
Type
Description
type
string
The content type (always
tool_use
).
tool_use
The tool use.
Example
{ "type": "tool_use", "tool_use": { "tool_use_id": "toolu_123", "type": "cortex_analyst_text2sql", "name": "my_cortex_analyst_semantic_view", "input": { "location": "San Francisco, CA" }, "client_side_execute": "true" } }
ModelConfig
¶
Field |
Type |
Description |
---|---|---|
|
string |
Which LLM to use for orchestration. If left blank, the best LLM available to you will be selected |
Example
{
"orchestration": "claude-4-sonnet"
}
ResultSet
¶
Field |
Type |
Description |
---|---|---|
|
string |
The query id. |
|
Metadata on the result set. |
|
|
array of array |
2D array representing the data |
Example
{
"statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"resultSetMetaData": {
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
},
"data": [
[
"row1 col1",
"row1 col2"
],
[
"row2 col1",
"row2 col2"
]
]
}
ResultSetMetaData
¶
Field |
Type |
Description |
---|---|---|
|
integer |
The index number of the partition. |
|
integer |
The total number of rows of results. |
|
string |
Format of the data in the result set. |
|
array of RowType |
Description of the columns in the result. |
Example
{
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
}
RowType
¶
Field |
Type |
Description |
---|---|---|
|
string |
Name of the column. |
|
string |
Snowflake data type of the column. (https://docs.snowflake.cn/en/sql-reference/intro-summary-data-types) |
|
integer |
Length of the column. |
|
integer |
Precision of the column. |
|
integer |
Scale of the column. |
|
boolean |
Specifies whether or not the column is nullable. |
Example
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
SqlExplanationToolResultDelta
¶
Field |
Type |
Description |
---|---|---|
|
string |
The text delta for the SQL explanation |
Example
{
"text": "This query selects all columns"
}
TableContent
¶
Field |
Type |
Description |
---|---|---|
|
string |
The ID of the tool use that generated this table |
|
string |
The query id of the sql query that generated this data |
|
The SQL results to render a table. Matches the schema from Snowflake’s SQL API ResultSet (https://docs.snowflake.cn/en/developer-guide/sql-api/reference#resultset) |
|
|
string |
The title for this table |
Example
{
"tool_use_id": "toolu_123",
"query_id": "6ac75378-6337-48a6-80ab-6de48dd680eb",
"result_set": {
"statementHandle": "707787a0-a684-4ead-adb0-3c3b62b043d9",
"resultSetMetaData": {
"partition": 0,
"numRows": 0,
"format": "jsonv2",
"rowType": [
{
"name": "my_column",
"type": "VARCHAR",
"length": 0,
"precision": 0,
"scale": 0,
"nullable": false
}
]
},
"data": [
[
"row1 col1",
"row1 col2"
],
[
"row2 col1",
"row2 col2"
]
]
},
"title": "Revenue by Month"
}
ThinkingContent
¶
Field |
Type |
Description |
---|---|---|
|
string |
Thinking tokens from the agent |
Example
{
"text": "To answer your question I must..."
}
Tool
¶
Defines a tool that can be used by the agent. Tools provide specific capabilities like data analysis, search, or generic functions.
Field |
Type |
Description |
---|---|---|
|
The tool spec |
Example
{
"tool_spec": {
"type": "generic",
"name": "get_weather",
"description": "Fetch the delivery revenue for a location.",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
}
},
"required": [
"location"
]
}
}
ToolChoice
¶
Field |
Type |
Description |
---|---|---|
|
string |
Determines how tools are selected: - auto - Automatic tool selection (default) - required - Must use at least one tool - tool - Use specific named tools |
|
array of string |
List of specific tool names to use when type is ‘tool’ |
Example
{
"type": "auto",
"name": [
"analyst_tool",
"search_tool"
]
}
ToolInputSchema
¶
Field |
Type |
Description |
---|---|---|
|
string |
The type of the input schema object |
|
string |
A description of what the input is. |
|
map of ToolInputSchema |
Definitions of each input parameter, if type is |
|
If type is |
|
|
array of string |
List of required input parameter names, if type is object |
Example
{
"type": "object",
"description": "Input for my custom tool",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"items": {},
"required": [
"location"
]
}
ToolResource
¶
Configuration for text-to-SQL analysis tool. Provides parameters for SQL query generation and execution. Exactly one of semantic_model_file, semantic_view or semantic_model_inline must be provided.
Field
Type
Description
semantic_model_file
string
The path to a file stored in a Snowflake Stage holding the semantic model yaml.
semantic_view
string
The name of the Snowflake native semantic model object
semantic_model_inline
string
A semantic model yaml definition
execution_environment
Configuration for how to execute the generated SQL query.
Example
{ "semantic_model_file": "@db.schema.stage/semantic_model.yaml", "semantic_view": "db.schema.semantic_view", "semantic_model_inline": "name: my_semantic_model ...", "execution_environment": { "type": "warehouse", "warehouse": "MY_WAREHOUSE", "query_timeout": "60" } }Configuration for search functionality. Defines how document search and retrieval should be performed.
Field
Type
Description
search_service
string
The fully qualified name of the search service.
title_column
string
The title column of the document.
id_column
string
The ID column of the document.
filter
object
Filter query for search results.
Example
{ "search_service": "database.schema.service_name", "title_column": "account_name", "id_column": "account_id", "filter": { "@eq": { "<column>": "<value>" } } }
Field
Type
Description
type
string
If the tool is server-side executed, whether it is a Stored Procedure or a UDF.
execution_environment
identifier
string
Fully qualified name of the Stored Procedure or UDF
Example
{ "type": "function", "execution_environment": { "type": "warehouse", "warehouse": "MY_WAREHOUSE", "query_timeout": "60" }, "identifier": "MY_DB.MY_SCHEMA.MY_UDF" }
ToolResult
¶
Field |
Type |
Description |
---|---|---|
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (e.g. cortex_search, cortex_analyst_text2sql) |
|
string |
The unique identifier for this tool instance |
|
array of ToolResultContent |
The content on the tool result |
|
string |
The status of tool execution |
Example
{
"tool_use_id": "toolu_123",
"type": "cortex_analyst_text2sql",
"name": "my_cortex_analyst_semantic_view",
"content": [
{
"type": "json",
"json": {
"answer": 42
}
}
],
"status": "success"
}
ToolResultContent
¶
Field
Type
Description
type
string
The type of result (always
json
)
json
object
Structured output from a tool. The schema varies depending on the tool type.
Example
{ "type": "json", "json": { "answer": 42 } }
Field
Type
Description
type
string
The type of result (always
text
)
text
string
The result text
Example
{ "type": "text", "text": "The answer is 42" }
ToolSpec
¶
Specification of the tool’s type, configuration, and input requirements
Field |
Type |
Description |
---|---|---|
|
string |
The type of tool capability. Can be specialized types like ‘cortex_analyst_text_to_sql’ or ‘generic’ for general-purpose tools. |
|
string |
Unique identifier for referencing this tool instance. Used to match with configuration in tool_resources. |
|
string |
Description of the tool to be considered for tool use |
|
JSON Schema definition of the expected input parameters for this tool. This will be fed to the Agent so it knows the structure it should follow for when generating the input for ToolUses. Required for generic tools to specify their input parameters. |
Example
{
"type": "generic",
"name": "get_weather",
"description": "lorem ipsum",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": [
"location"
]
}
}
ToolUse
¶
Field |
Type |
Description |
---|---|---|
|
string |
Unique identifier for this tool use. Can be used to associated tool results. |
|
string |
The type of the tool (e.g. cortex_search, cortex_analyst_text2sql) |
|
string |
The unique identifier for this tool instance |
|
object |
The structured input for this tool. The schema of this object should will vary depending on the tool spec. |
|
boolean |
Whether the tool use is executed on the client side. |
Example
{
"tool_use_id": "toolu_123",
"type": "cortex_analyst_text2sql",
"name": "my_cortex_analyst_semantic_view",
"input": {
"location": "San Francisco, CA"
},
"client_side_execute": "true"
}