- Categories:
Table functions (Cortex Agents)
GET_AI_RECORD_TRACE (SNOWFLAKE.LOCAL)¶
Retrieve a single trace record from a Cortex Agent evaluation run.
Call this function when you want to inspect a single record from a complete Cortex Agent evaluation. For more information, see Cortex Agent evaluations.
- See also:
EXECUTE_AI_EVALUATION , GET_AI_EVALUATION_DATA (SNOWFLAKE.LOCAL) , GET_AI_OBSERVABILITY_LOGS (SNOWFLAKE.LOCAL)
Syntax¶
Arguments¶
databaseName of the database containing the agent.
schemaName of the schema containing the agent.
agent_nameName of the agent to retrieve a record for.
agent_typeThe string constant
CORTEX AGENT. This value is case-insensitive.record_idThe record identifier to retrieve.
Returns¶
A table containing information for the requested trace, with the following columns:
Column |
Data type |
Description |
|---|---|---|
RECORD_ID |
VARCHAR |
The unique identifier assigned by Snowflake for this evaluation record. |
INPUT_ID |
VARCHAR |
The unique identifier assigned by Snowflake for this evaluation input. |
REQUEST_ID |
VARCHAR |
The unique identifier assigned by Snowflake for this request. |
TIMESTAMP |
TIMESTAMP_TZ |
The time (in UTC) at which the request was made. |
DURATION_MS |
INT |
The amount of time, in milliseconds, that it took for the agent to return a response. |
INPUT |
VARCHAR |
The query string used as input for this evaluation record. |
OUTPUT |
VARCHAR |
The response returned by the Cortex Agent for this evaluation record. |
ERROR |
VARCHAR |
Information about any errors that occurred during the request. |
GROUND_TRUTH |
VARCHAR |
The ground truth information used to evaluate this record’s Cortex Agent output. |
METRIC_NAME |
VARCHAR |
The name of the metric evaluated for this record. |
EVAL_AGG_SCORE |
NUMBER |
The evaluation score assigned for this record. |
METRIC_TYPE |
VARCHAR |
The type of metric being evaluated. For built-in metrics, the value is |
METRIC_STATUS |
VARIANT |
A map containing information about the agent’s HTTP response for this record, with the following keys:
|
METRIC_CALLS |
ARRAY |
An array of VARIANT values that contain information about the the computed metric. Each array entry contains the metric’s criteria, an explanation of the metric score, and metadata. The keys of each entry are:
|
TOTAL_INPUT_TOKENS |
INT |
The total number of tokens used to process the input query. |
TOTAL_OUTPUT_TOKENS |
INT |
The total number of output tokens produced by the Cortex Agent. |
LLM_CALL_COUNT |
INT |
Counts the number of times any LLM was called, either by the agent or an evaluation judge. |
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
Privilege |
Object |
Notes |
|---|---|---|
CORTEX_USER |
Database role |
|
USAGE |
Cortex Agent |
|
MONITOR |
Cortex Agent |
Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
For the full access control permissions required by Cortex Agent evaluations, see Cortex Agent evaluations – Access control requirements.
Examples¶
The following example displays the trace for the record 9346efc3-5dd6-4038-9b1a-72ca3d3b768c, where the agent is named evaluated_agent stored on the schema eval_db.eval_schema: