Running agents¶
Run an agent¶
run_work_item_agent runs an agent's active version over every work item in its input view
that has changed since it was last processed:
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets',
agent_name => 'ticket_triage'
);
It returns a summary of the run. The full record, including errors and the configuration
used, is in control.agent_execution.
Common options¶
-- Process one work item
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets', agent_name => 'ticket_triage', work_item_id => 'TKT-12345'
);
-- Limit to items updated in a date range, and cap the row count
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets', agent_name => 'ticket_triage',
min_date => '2026-09-01', max_date => '2026-09-30', max_rows => 500
);
-- Reprocess items even if they haven't changed
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets', agent_name => 'ticket_triage', reload_ind => TRUE
);
| Parameter | Default | Purpose |
|---|---|---|
use_case |
Required | The agent's use case. |
agent_name |
Required | The agent to run. |
version |
Active version | Run a specific version instead. |
work_item_id |
None | Process a single work item. |
process_name |
None | Process only the IDs stored under this name in control.process_control. |
data_filter |
None | An extra SQL condition on the input view, which is aliased i, such as i.work_item_info:region::STRING = 'EMEA'. |
min_date, max_date |
None | Limit to items whose UPDATED_DTM is in this range. |
max_rows |
10000 |
The most rows processed in one run. |
cycle_rows |
1000 |
Rows per batch. Each batch is a separate AI statement. |
model |
Agent's model | Override the model for this run. |
reload_ind |
FALSE |
Reprocess rows even if they haven't changed. |
Running on a schedule¶
Use a Snowflake task to run agents in order:
CREATE TASK my_db.my_schema.run_ticket_triage
WAREHOUSE = wire_xs_wh
SCHEDULE = 'USING CRON 0 * * * * UTC'
AS
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets', agent_name => 'ticket_triage'
);
CREATE TASK my_db.my_schema.run_ticket_analysis
WAREHOUSE = wire_xs_wh
AFTER my_db.my_schema.run_ticket_triage
AS
CALL wire_native_app.main.run_work_item_agent(
use_case => 'tickets', agent_name => 'ticket_analysis'
);
Resume the tasks, child first, with ALTER TASK ... RESUME. The task owner's role needs
the wire_user application role.
Read the results¶
The structured result for each work item is in the output table's RESULTS column:
SELECT id,
COALESCE(override_category, results:category::STRING) AS category,
results:confidence::STRING AS confidence,
results:reason::STRING AS reason,
engine_type
FROM my_db.my_schema.triage_output;
COALESCE with the override columns gives you a person's correction where one exists, and
the agent's result otherwise.
Experiment without changing configuration¶
run_agent runs a prompt and model over any data, without saving an agent or writing to an
output table. It returns the raw model response, so you can compare prompts or models
side by side:
CREATE TABLE my_db.my_schema.experiment_a AS
SELECT i.id, r.engine_type, r.response, r.cat_labels, r.etl_created_dtm
FROM my_db.my_schema.triage_input AS i,
TABLE(wire_native_app.main.run_agent(
i.work_item_info, i.insights::VARIANT, i.rule_engine_results,
'claude-haiku-4-5', 'tickets', 'ticket_triage', 'v1'
)) AS r;
Then parse the stored response:
SELECT id,
response['structured_output'][0]['raw_message']::OBJECT AS results,
response['usage'] AS usage,
response['model']::STRING AS model
FROM my_db.my_schema.experiment_a;
Run it again with a different model or version into a second table, and join the two on
id to compare.
Save the raw response first, then parse it
Snowflake makes one AI call for each distinct expression in a statement that uses the
model's response. Selecting response once costs one call per row. Deriving two
columns from it in the same statement costs two. Always store the raw response
first, then parse it in a second statement, as shown above.
Cost¶
Agent runs use your warehouse and Cortex AI credits. To see what a run cost, see Reference: control tables.