Letting an AI agent answer every support ticket is expensive and risky. Refund requests and suspicious logins shouldn't get an AI reply at all, and password resets don't need an agent.
So I put a cheap decision model in front of the agent. Snowflake's snowflake-decision costs $0.042 per million tokens. For each ticket it returns probabilities: does this need a human, does it need the customer's own data, which help article answers it. Thresholds on those probabilities send each ticket to a template reply, a Cortex Agent, or a person.
The tickets, help articles, customer data, and replies are all in Japanese. The prompts are in English, and there's no translation step in between.
The stack:
- Router:
snowflake-decision, called throughAI_COMPLETE - Orchestration: Pipeline Builder, a new visual canvas for Snowflake task graphs where Python files and notebooks sit next to SQL
- Answers: Cortex Agent, with Cortex Search over help articles and Cortex Analyst over customer data
- Code: takimiko-gohan/sf-agent-workflow-pipeline
Both
snowflake-decisionand Pipeline Builder were in public preview when I wrote this (November 2026). UI details and behavior may change, so check the official docs before you build on them.
The scenario: a Japanese support desk
The demo is built around a fictional project-management SaaS called "TaskFlow" that sells to Japanese companies. Everything is in Japanese: the tickets, the help-center articles, and the customer data.
The synthetic dataset has about 220 tickets over October, about 15 per weekday. We want AI to take some of the load, but we don't want it answering everything. Each ticket goes down one of three routes:
| Route | Example tickets | Why |
|---|---|---|
| auto (template answer) | 「パスワードを忘れてログインできません」 I forgot my password and can't log in. | A help article answers it, and the answer is the same for everyone. |
| agent (Cortex Agent researches and answers) | 「うちのプランでSSOは使えますか」 Can we use SSO on our plan? 「ストレージの上限を知りたい」 What's our storage limit? | The answer depends on the customer, so you have to look up their plan, invoices, or usage. |
| human (support staff) | 「先月分を返金してほしい」 Please refund last month. 「身に覚えのないログイン履歴があります」 There's a login I don't recognize. | Money, permissions, or security is involved. The AI shouldn't promise anything here. |
The SSO question looks like something a help article could answer, since the article says "SSO is available on the Business plan and above." But you can't say yes or no until you know which plan this customer is on. That's why it goes to the agent.
Two more design decisions:
- Ignore the category the customer picked on the form. Customers often pick "How to use" for what is really a billing question, so routing has to read the ticket text itself.
- Check AI answers before sending them. Auto and agent replies go through a quality check. A draft that isn't grounded in its sources, doesn't answer the question, or makes a promise that needs approval (a refund, a deadline) is sent to a human along with the draft.
Part 1: Routing with snowflake-decision
What it is
snowflake-decision is a model you call through AI_COMPLETE. You pass a state (the situation) and a set of questions, and instead of free text you get back probabilities for each option.
SELECT AI_COMPLETE( model => 'snowflake-decision', prompt => TO_JSON({ 'state': 'パスワードを忘れてログインできません。', 'questions': { 'category': { 'type': 'choice', 'instructions': 'What is this support ticket about?', 'criteria': { 'account_access': 'Login, password or SSO', 'billing': 'Invoices or payments', 'other': 'Anything else' } } } }) ); The state is Japanese, and the instructions and options are English. That mix works fine. The response is JSON. For a choice question you read answers.category.choice (the selected option), answers.category.confidence, and answers.category.probabilities (one probability per option).
There are three question types:
-
choice: which option fits? You get the selected option, a confidence, and a probability for every option. -
noul: is this statement true? (The name looks like a typo, but that's what the docs call it.) You get the probability that it's true. -
score: where on a scale does this fall? You get a probability-weighted expected value.
You can ask several questions in one call. My routing step asks four at once:
| Question | Type | What it asks |
|---|---|---|
category | choice | Ticket category (8 options) |
kb_article | choice | Which help article answers this (18 articles plus "none"). The options are the Japanese article titles, used as-is. |
requires_human | noul | Does this need a person's judgment, authority, or investigation? |
needs_account_data | noul | Do we need this customer's own data to answer? |
The quality check uses the same model with a score question (is the draft grounded?) and two noul questions (does it answer the question? does it make a risky promise?).
Why probabilities beat "how confident are you?"
When you ask a general LLM how confident it is, it writes "0.9" token by token, the same way it writes the rest of its answer. That number is generated text. Nothing ties it to the other options.
snowflake-decision produces its numbers differently (docs):
- Every option gets a probability, not just the one it picked.
-
confidenceis computed from that distribution using entropy:confidence = 1 − H / ln(n), whereH = −Σ p·ln(p)andnis the number of options. It's close to 1 when the probability is concentrated on one option and 0 when it's spread evenly. -
scoreis an expected value. If levels 0, 1, and 2 have probabilities 0.1, 0.2, and 0.7, the score is 1.6. -
temperatureandtop_pare ignored.
One thing to watch: confidence is not the top probability. With three options at 0.91 / 0.06 / 0.03, confidence is about 0.67. It also shrinks as you add options. My help-article question has 19 options. If the top option has 0.9 and the remaining 0.1 is spread evenly over the other 18, confidence comes out around 0.79, which is just below the 0.8 threshold I use. When you set thresholds, look at real distributions, not just the top pick.
Pricing
According to the release note, snowflake-decision costs $0.042 per million tokens. For reference, here's claude-sonnet-5, the general-purpose model my pipeline falls back to when the decision model fails (per million tokens):
| Model | Input | Output |
|---|---|---|
snowflake-decision | $0.042 | not billed |
claude-sonnet-5 | 1.2 AI Credits = $2.40 | 6.0 AI Credits = $12.00 |
AI Credits are converted at the global routing rate of $2.00 per AI Credit; regional routing is $2.20.
Sonnet is a large model, so this isn't a like-for-like comparison, and a smaller general model would narrow the gap. Only input tokens are billed. Even so, at about 57x cheaper on input than the fallback, running it on every ticket is easy to justify.
Routing rules
Because the model returns probabilities, the routing rules are just thresholds:
- human:
requires_human≥ 0.5 - auto: help-article confidence ≥ 0.8 and
needs_account_data< 0.3 - agent: everything else
The thresholds live in a config table, so you can tune them without touching code. Lower the human threshold to play it safer, or lower the auto threshold to automate more.
Part 2: Orchestrating with Pipeline Builder
The flow
Here's the flow one ticket goes through, conceptually:
The pipeline doesn't actually push tickets through cards one at a time. Each run processes a whole day's batch. The per-ticket route (auto / agent / human) is written to a column in a table, and each downstream card filters on that column to pick up its own tickets.
The real pipeline has 14 cards:
All 14 cards| Card | What it does | Runs when |
|---|---|---|
| T00_PICK_BATCH | Picks up the day's tickets | Always (root) |
| T01_NO_TICKETS | Logs that there was nothing to do | T00 returned NO_TICKETS |
| T10_CLASSIFY | Classifies tickets with snowflake-decision | T00 returned HAS_TICKETS |
| T11_CLASSIFY_FALLBACK | Re-classifies with a general LLM | T10 failed |
| T20_ROUTE | Decides auto / agent / human and stores it | T10 or T11 succeeded |
| T30_AGENT_ANSWER | Cortex Agent answers agent tickets (Python) | After T20 (does nothing if there are no agent tickets) |
| T31_OVERFLOW_TO_HUMAN | Sends tickets over the agent limit to humans | T20 returned AGENT_OVERFLOW |
| T35_AGENT_FAILED | Sends agent tickets to humans | T30 failed |
| T40_AUTO_ANSWER | Builds template answers and collects drafts to check | Any upstream card succeeded |
| T41_QUALITY_CHECK | Checks drafts with snowflake-decision | After T40 |
| T42_QUALITY_FALLBACK | Re-scores drafts with a general LLM | T41 failed |
| T45_FINALIZE | Decides send vs. human for each draft | T41 or T42 succeeded |
| T50_HUMAN_QUEUE | Queues tickets for staff with a handoff note | T45 returned REVIEW_NEEDED |
| T99_RUNSUMMARY | Records the run (finalizer) | Always, last |
Building it
You create a pipeline from the Workspaces "new" menu. That creates a DCM project (Snowflake's Database Change Management project, which stores object definitions as files and deploys them). Pipeline Builder is the visual editor; the DCM project is where the result lives.
On the canvas, you drag a SQL file in to make a card, connect cards, and set each card's source, schedule, and warehouse in the panel on the right.
Python cards work a little differently. The card that calls Cortex Agent is a Python file, and you don't paste Python into a card. You package it as a code bundle first, then point the card at the bundle.
How the code bundle is defined in the DCM projectmanifest.yml declares which files go into the bundle as an asset:
assets: t30_agent_answer: path: bundles/t30/**/* pipeline.yml creates the code bundle from that asset:
- resource: code_bundle name: DECISION_PIPE_DB.SUPPORT.T30_CB from: type: asset asset: t30_agent_answer The task definition says which bundle to use, which file to run, and where to run it:
definition: type: code_bundle name: DECISION_PIPE_DB.SUPPORT.T30_CB entrypoint: T30_AGENT_ANSWER.py specification: bundle: type: custom compute_type: compute_pool compute_options: runtime_version: V3-CPU-PY3.12 compute_pool: SYSTEM_COMPUTE_POOL_CPU query_warehouse: DECISION_PIPE_WH language: python To deploy, you run Plan on the DCM project first. It lists every object that will be created or changed, down to which role will own each new object, and then you Deploy.
Branching on return values
A card can set a return value, and a downstream card can run only when its predecessor returned a specific value. You set this under Dependencies: the predecessor card and an additional condition.
A card gets one return value per run, not one per ticket. So the job is split like this:
- The per-ticket route goes in a table column.
- The return value answers a batch-level question: "Does anything downstream need to run today?"
The routing card returns AGENT_OVERFLOW when there are more agent tickets than the agent is allowed to handle in one run:
rv := CASE WHEN n_agent = 0 THEN 'ALL_AUTO' WHEN n_agent <= max_rows THEN 'AGENT' ELSE 'AGENT_OVERFLOW' END; CALL SYSTEM$SET_RETURN_VALUE(:rv); The overflow card only runs in that case:
predecessors: - DECISION_PIPE_DB.SUPPORT.T20_ROUTE condition: SYSTEM$GET_PREDECESSOR_RETURN_VALUE('T20_ROUTE') = 'AGENT_OVERFLOW' There are three branch points in total:
| After... | Return value | What happens next |
|---|---|---|
| Picking up tickets | NO_TICKETS if there are none | Skip classification, log "nothing to do", and stop |
| Routing | AGENT_OVERFLOW if over the agent limit | A card that hands the extra tickets to humans runs in parallel with the agent |
| Finalizing | REVIEW_NEEDED if anything goes to a human | The human-queue card runs and writes handoff notes |
Each one boils down to: if no ticket needs this card, don't run it.
Cards can also run on failure. If the decision-model card fails, a fallback card re-classifies with a general LLM, and the routing card runs as soon as either of them succeeds. The same pattern backs up the agent and the quality check.
Logging the run with a finalizer
As with regular task graphs, you can add a finalizer that always runs last, even if something upstream failed. Mine records which path the run took, how many tickets went where, and which days are done.
Passing config at run time
You can pass JSON config when you run the graph. I use it to switch between processing one day at a time and catching up on every unprocessed day:
-- Process the next unprocessed day EXECUTE TASK GRAPH DECISION_PIPE_DB.SUPPORT.SUPPORT_PROCESSING; -- Process all unprocessed days at once EXECUTE TASK GRAPH DECISION_PIPE_DB.SUPPORT.SUPPORT_PROCESSING USING CONFIG = $${"batch_mode": "all"}$$; Making Pipeline Builder Git-friendly
When you build in the GUI, every card's definition, SQL included, ends up in a single pipeline.yml. With 14 cards, mine came to over 1,000 lines. That's a merge-conflict magnet for a team.
You can point cards at separate SQL files instead, but those files have to live in a workspace or on a stage. If you manage code in Git, you end up keeping two copies in sync: the repo and the workspace or stage. It gets worse when dev and prod are separate accounts, because each account needs its own copy.
So I kept the SQL inside the YAML and split the YAML into one file per card. I had Cortex Code (CoCo) do the split.
pipeline.yml now only holds graph-level settings (root, finalizer, task defaults) and the code bundle. Each card's file holds its predecessors, its condition, and its body.
The GUI kept working after the split. I make small edits and check the shape of the graph in the GUI, and review diffs per card in Git.
Part 3: Answering with Cortex Agent
Tickets routed to agent go to a Cortex Agent with two tools:
| Tool | Backed by | Looks up |
|---|---|---|
kb_search | Cortex Search (managed hybrid vector and keyword search) | Help articles (18, in Japanese) |
account_data | Cortex Analyst (text-to-SQL over a semantic view) | Plans, seats, invoices, API usage, incidents |
Two things in the agent's instructions are worth calling out:
- The agent can escalate too. If the router missed something, such as a refund request or a possible security incident, the agent declines to answer and hands it off. That gives you a second safety net.
- The last line of every reply is a JSON object with
resolution,sources, andfacts, so downstream cards can parse it. The quality check usessourcesandfactsas the evidence to check against.
Pipeline Builder calls the agent from the Python card, one ticket at a time, through SNOWFLAKE.CORTEX.DATA_AGENT_RUN:
for row in targets: t0 = time.time() try: body = build_request(row["RECEIVED_AT"], row["TICKET_TEXT"]) resp = session.sql( f"SELECT SNOWFLAKE.CORTEX.DATA_AGENT_RUN('{AGENT_NAME}', ?)", params=[body] ).collect()[0][0] answer, reply, resolution, sources, facts = parse_answer(resp) If one call fails, the card logs it and moves on to the next ticket. If too many fail, the card raises an error, and Pipeline Builder's failure branch sends the agent's tickets to humans.
Running it
I ran 13 tickets through the pipeline.
The run history shows each card's state and return value. Some tickets needed a human, so finalizing returned REVIEW_NEEDED and the human-queue card ran. The fallback and overflow cards weren't needed, so they show as Skipped.
Final routes: 6 auto, 1 agent, 6 human.
Here's one example per route, with English translations.
「パスワードを忘れました」 (I forgot my password) → auto
パスワードは、ログイン画面の「パスワードをお忘れの方」から再設定できます。登録済みのメールアドレスを入力すると、再設定用のリンクが届きます。リンクの有効期限は24時間です。…
You can reset your password from "Forgot your password?" on the login screen. Enter your registered email address and you'll receive a reset link, valid for 24 hours. …
「ストレージの上限を知りたい」 (What's our storage limit?) → agent
貴社は現在「ビジネス」プランをご契約中です。ビジネスプランでは、ワークスペース全体のストレージ上限は1TBです。添付ファイルには1ファイルごとの上限もあり、ビジネスプランでは1ファイル500MBまでです。
Your company is on the Business plan. The Business plan has a 1 TB storage limit per workspace, and a per-file attachment limit of 500 MB.
The plan came from the customer data, and the limits came from a help article. The agent put the two together into one answer.
「身に覚えのないログインがある」 (A login I don't recognize) → human
The router gave requires_human a probability of 0.95. Here's the handoff note staff received:
株式会社あおばシステムズ(アカウントID 1010)。身に覚えのない海外からのログイン通知を受けたため、調査してほしいとの依頼。フォームの区分は「その他」。…
Aoba Systems Inc. (account ID 1010). Received a notification of an unrecognized login from overseas and is asking us to investigate. Form category: "Other". …
The customer filed it under "Other", but the router read the text and treated it as a security issue.
I also checked the routing against ground-truth labels. With only 13 tickets this is a sanity check, not an evaluation:
- All 4 tickets that truly needed a human were sent to a human. None slipped through to an AI reply.
- 2 tickets that didn't need a human were escalated anyway, so the router leans cautious at the default 0.5 threshold.
- 1 ticket that needed customer data scored 0.27 on
needs_account_data, under the 0.3 cutoff, so it went to a template reply instead of the agent. Lowering that threshold to about 0.2 would have caught it.
In other words, the thresholds need tuning on more data before they mean much. That's the kind of iteration a cheap router makes painless.
Does it really work in Japanese?
For this demo, yes. A few observations:
- Japanese ticket text goes straight into
state, with English instructions and options, and the routing makes sense. - Japanese help-article titles work as
choiceoptions without translating them. - An earlier version of this pipeline translated tickets into English with
AI_TRANSLATEbefore calling the decision model. I removed that step, and the pipeline got simpler. - The Cortex Search service uses the multilingual embedding model
snowflake-arctic-embed-l-v2.0, so Japanese help articles are searchable without translation. - The semantic view has Japanese synonyms and comments on tables and columns (for example 「何月分」 for billing month and 「契約プラン」 for plan), so Cortex Analyst can map the customer's wording to the right column.
- The agent's instructions are written in Japanese, and so are its replies.
I couldn't find an official list of supported languages for snowflake-decision, so treat this as one data point rather than a guarantee. If your data isn't in English, it's worth trying before you build a translation step.
Wrapping up
A cheap decision model decides who should handle each ticket, and Pipeline Builder turns that into a visual, Git-friendly pipeline, with no translation step for Japanese data.
Pipeline Builder can also run dbt projects as cards (for example EXECUTE DBT PROJECT ...), so you could trigger agents right after your transformations finish. Both features are still new, and I'm curious what else people build with them.
The code is on GitHub: takimiko-gohan/sf-agent-workflow-pipeline










