Control tables¶
WIRE keeps its configuration and history in the app's control schema. Anyone with the
wire_user application role can read these tables. Change configuration through the
Configuration app or the procedures rather than writing to the tables
directly. The procedures validate what you save.
| Table | Contents |
|---|---|
control.use_case |
Registered use cases. |
control.agent_config |
Agent definitions: type, prompt, model, input view, output table, and version. |
control.agent_type |
The available agent types, with their defaults. |
control.class_category |
Categories for triage agents, grouped by class name and version. |
control.agent_execution |
One row per agent run. |
control.work_item_feedback |
Feedback people leave on individual work items. |
control.app_feedback |
Product feedback submitted from the Configuration app. |
agent_execution¶
Every run of run_work_item_agent writes one row. Use it to monitor runs, investigate
errors, and attribute cost.
| Column | Description |
|---|---|
id |
Execution ID. Output rows carry it in agent_execution_id. |
use_case, agent_name, version |
What ran. |
execution_status |
RUNNING, COMPLETED, COMPLETED_WITH_ERRORS, or FAILED. |
execution_start_dtm, execution_end_dtm, execution_duration_sec |
When and how long. |
inserted_rows, updated_rows, total_upsert_rows |
Rows written. |
errored_rows |
Rows the model returned no result for. |
error_message |
The distinct row-level errors, or the error that stopped the run. |
prompt_tokens, completion_tokens, total_tokens |
Token usage. |
agent_query_ids |
Query IDs of the AI statements, for cost and warehouse lookups. |
param_* |
The options the run was called with. |
system_prompt, llm_model, parameters, response_format, input_view, output_table, ... |
The configuration the run used, as it was at the time. |
Find the warehouse a run used¶
Run from a worksheet, not from inside a procedure:
SELECT e.id, h.query_id, h.warehouse_name
FROM wire_native_app.control.agent_execution AS e,
LATERAL FLATTEN(input => e.agent_query_ids) AS q
JOIN TABLE(INFORMATION_SCHEMA.QUERY_HISTORY()) AS h
ON h.query_id = q.value::VARCHAR
WHERE e.id = <execution_id>;
Find the credits a run used¶
Cortex usage reaches ACCOUNT_USAGE after a delay of up to several hours:
WITH exec_queries AS (
SELECT e.id AS execution_id, q.value::VARCHAR AS query_id
FROM wire_native_app.control.agent_execution AS e,
LATERAL FLATTEN(input => e.agent_query_ids) AS q
)
SELECT eq.execution_id, SUM(u.token_credits) AS credits
FROM exec_queries AS eq
JOIN SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AISQL_USAGE_HISTORY AS u
ON u.query_id = eq.query_id
GROUP BY eq.execution_id;