# Routing Japanese Support Tickets with a $0.04/M-Token Model in Snowflake

> Source: <https://dev.to/takimiko_gohan/routing-japanese-support-tickets-with-a-004m-token-model-in-snowflake-ha8>
> Published: 2026-11-30 12:40:49+00:00

**Recommendation:** Put a low-cost decision model in front of your agent and route on probability thresholds, sending refunds, permissions and security tickets to humans and only customer-data-dependent questions to the agent.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

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:

`snowflake-decision`, called through `AI_COMPLETE`
Both `snowflake-decision` and 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 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:

`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.

``` js
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`` noul``score`
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?).

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](https://docs.snowflake.com/user-guide/snowflake-cortex/snowflake-decision)):

`confidence` is computed from that distribution using entropy: `confidence = 1 − H / ln(n)`, where `H = −Σ p·ln(p)` and `n` is the number of options. It's close to 1 when the probability is concentrated on one option and 0 when it's spread evenly.`temperature` and `top_p` are 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.

According to the [release note](https://docs.snowflake.com/en/release-notes/2026/other/2026-11-20-ai-complete-snowflake-decision-public-preview), `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](https://docs.snowflake.com/en/user-guide/snowflake-cortex/pricing); 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.

Because the model returns probabilities, the routing rules are just thresholds:

`requires_human` ≥ 0.5`needs_account_data` < 0.3
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.

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 | 

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.

`manifest.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.

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 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.

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.

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"}$$;
```

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.

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:

`resolution`, `sources`, and `facts`, so downstream cards can parse it. The quality check uses 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.

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:

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.

For this demo, yes. A few observations:

`state`, with English instructions and options, and the routing makes sense.`AI_TRANSLATE` before calling the decision model. I removed that step, and the pipeline got simpler.`snowflake-arctic-embed-l-v2.0`, so Japanese help articles are searchable without translation.
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.

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](https://github.com/takimiko-gohan/sf-agent-workflow-pipeline)
