{"slug": "routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake", "title": "Routing Japanese Support Tickets with a $0.04/M-Token Model in Snowflake", "summary": "A developer built a support-ticket routing layer that places Snowflake's snowflake-decision model, priced at $0.042 per million tokens, in front of an AI agent so that only tickets needing customer-specific data reach the Cortex Agent while refund and security issues go to humans. The demo, built around a fictional Japanese SaaS called TaskFlow with roughly 220 synthetic Japanese-language tickets, asks four questions per ticket in a single AI_COMPLETE call and routes on probability thresholds, with English prompts and no translation step.", "body_md": "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.\n\nSo 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.\n\nThe tickets, help articles, customer data, and replies are all in Japanese. The prompts are in English, and there's no translation step in between.\n\nThe stack:\n\n`snowflake-decision`, called through `AI_COMPLETE`\nBoth `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.\n\nThe 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.\n\nThe 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:\n\n| Route | Example tickets | Why | \n|---|---|---|\n| **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. | \n| **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. | \n| **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. | \n\nThe 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.\n\nTwo more design decisions:\n\n`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.\n\n``` js\nSELECT AI_COMPLETE(\n  model  => 'snowflake-decision',\n  prompt => TO_JSON({\n    'state': 'パスワードを忘れてログインできません。',\n    'questions': {\n      'category': {\n        'type': 'choice',\n        'instructions': 'What is this support ticket about?',\n        'criteria': {\n          'account_access': 'Login, password or SSO',\n          'billing':        'Invoices or payments',\n          'other':          'Anything else'\n        }\n      }\n    }\n  })\n);\n```\n\nThe 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).\n\nThere are three question types:\n\n`choice`` noul``score`\nYou can ask several questions in one call. My routing step asks four at once:\n\n| Question | Type | What it asks | \n|---|---|---|\n| `category` | choice | Ticket category (8 options) | \n| `kb_article` | choice | Which help article answers this (18 articles plus \"none\"). The options are the **Japanese article titles** , used as-is. | \n| `requires_human` | noul | Does this need a person's judgment, authority, or investigation? | \n| `needs_account_data` | noul | Do we need this customer's own data to answer? | \n\nThe 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?).\n\nWhen 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.\n\n`snowflake-decision` produces its numbers differently ([docs](https://docs.snowflake.com/user-guide/snowflake-cortex/snowflake-decision)):\n\n`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.\nOne 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.\n\nAccording 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):\n\n| Model | Input | Output | \n|---|---|---|\n| `snowflake-decision` | $0.042 | not billed | \n| `claude-sonnet-5` | 1.2 AI Credits = $2.40 | 6.0 AI Credits = $12.00 | \n\nAI 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.\n\nSonnet 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.\n\nBecause the model returns probabilities, the routing rules are just thresholds:\n\n`requires_human` ≥ 0.5`needs_account_data` < 0.3\nThe 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.\n\nHere's the flow one ticket goes through, conceptually:\n\nThe 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.\n\nThe real pipeline has 14 cards:\n\nAll 14 cards\n| Card | What it does | Runs when | \n|---|---|---|\n| T00_PICK_BATCH | Picks up the day's tickets | Always (root) | \n| T01_NO_TICKETS | Logs that there was nothing to do | T00 returned NO_TICKETS | \n| T10_CLASSIFY | Classifies tickets with snowflake-decision | T00 returned HAS_TICKETS | \n| T11_CLASSIFY_FALLBACK | Re-classifies with a general LLM | T10 failed | \n| T20_ROUTE | Decides auto / agent / human and stores it | T10 or T11 succeeded | \n| T30_AGENT_ANSWER | Cortex Agent answers agent tickets (Python) | After T20 (does nothing if there are no agent tickets) | \n| T31_OVERFLOW_TO_HUMAN | Sends tickets over the agent limit to humans | T20 returned AGENT_OVERFLOW | \n| T35_AGENT_FAILED | Sends agent tickets to humans | T30 failed | \n| T40_AUTO_ANSWER | Builds template answers and collects drafts to check | Any upstream card succeeded | \n| T41_QUALITY_CHECK | Checks drafts with snowflake-decision | After T40 | \n| T42_QUALITY_FALLBACK | Re-scores drafts with a general LLM | T41 failed | \n| T45_FINALIZE | Decides send vs. human for each draft | T41 or T42 succeeded | \n| T50_HUMAN_QUEUE | Queues tickets for staff with a handoff note | T45 returned REVIEW_NEEDED | \n| T99_RUNSUMMARY | Records the run (finalizer) | Always, last | \n\nYou 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.\n\nOn 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.\n\nPython 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.\n\n`manifest.yml` declares which files go into the bundle as an asset:\n\n```\nassets:\n  t30_agent_answer:\n    path: bundles/t30/**/*\n```\n\n`pipeline.yml` creates the code bundle from that asset:\n\n```\n  - resource: code_bundle\n    name: DECISION_PIPE_DB.SUPPORT.T30_CB\n    from:\n      type: asset\n      asset: t30_agent_answer\n```\n\nThe task definition says which bundle to use, which file to run, and where to run it:\n\n```\n    definition:\n      type: code_bundle\n      name: DECISION_PIPE_DB.SUPPORT.T30_CB\n      entrypoint: T30_AGENT_ANSWER.py\n      specification:\n        bundle:\n          type: custom\n          compute_type: compute_pool\n          compute_options:\n            runtime_version: V3-CPU-PY3.12\n            compute_pool: SYSTEM_COMPUTE_POOL_CPU\n            query_warehouse: DECISION_PIPE_WH\n          language: python\n```\n\nTo 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.\n\nA 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.\n\nA card gets one return value per run, not one per ticket. So the job is split like this:\n\nThe routing card returns `AGENT_OVERFLOW` when there are more agent tickets than the agent is allowed to handle in one run:\n\n```\nrv := CASE WHEN n_agent = 0 THEN 'ALL_AUTO'\n           WHEN n_agent <= max_rows THEN 'AGENT'\n           ELSE 'AGENT_OVERFLOW' END;\nCALL SYSTEM$SET_RETURN_VALUE(:rv);\n```\n\nThe overflow card only runs in that case:\n\n```\n    predecessors:\n      - DECISION_PIPE_DB.SUPPORT.T20_ROUTE\n    condition: SYSTEM$GET_PREDECESSOR_RETURN_VALUE('T20_ROUTE') = 'AGENT_OVERFLOW'\n```\n\nThere are three branch points in total:\n\n| After... | Return value | What happens next | \n|---|---|---|\n| Picking up tickets | `NO_TICKETS` if there are none | Skip classification, log \"nothing to do\", and stop | \n| Routing | `AGENT_OVERFLOW` if over the agent limit | A card that hands the extra tickets to humans runs in parallel with the agent | \n| Finalizing | `REVIEW_NEEDED` if anything goes to a human | The human-queue card runs and writes handoff notes | \n\nEach one boils down to: if no ticket needs this card, don't run it.\n\nCards 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.\n\nAs 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.\n\nYou 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:\n\n```\n-- Process the next unprocessed day\nEXECUTE TASK GRAPH DECISION_PIPE_DB.SUPPORT.SUPPORT_PROCESSING;\n\n-- Process all unprocessed days at once\nEXECUTE TASK GRAPH DECISION_PIPE_DB.SUPPORT.SUPPORT_PROCESSING\n  USING CONFIG = $${\"batch_mode\": \"all\"}$$;\n```\n\nWhen 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.\n\nYou 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.\n\nSo I kept the SQL inside the YAML and split the YAML into **one file per card**. I had Cortex Code (CoCo) do the split.\n\n`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.\n\nThe 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.\n\nTickets routed to **agent** go to a Cortex Agent with two tools:\n\n| Tool | Backed by | Looks up | \n|---|---|---|\n| `kb_search` | Cortex Search (managed hybrid vector and keyword search) | Help articles (18, in Japanese) | \n| `account_data` | Cortex Analyst (text-to-SQL over a semantic view) | Plans, seats, invoices, API usage, incidents | \n\nTwo things in the agent's instructions are worth calling out:\n\n`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`:\n\n```\nfor row in targets:\n    t0 = time.time()\n    try:\n        body = build_request(row[\"RECEIVED_AT\"], row[\"TICKET_TEXT\"])\n        resp = session.sql(\n            f\"SELECT SNOWFLAKE.CORTEX.DATA_AGENT_RUN('{AGENT_NAME}', ?)\", params=[body]\n        ).collect()[0][0]\n        answer, reply, resolution, sources, facts = parse_answer(resp)\n```\n\nIf 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.\n\nI ran 13 tickets through the pipeline.\n\nThe 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.\n\nFinal routes: 6 auto, 1 agent, 6 human.\n\nHere's one example per route, with English translations.\n\n**「パスワードを忘れました」 (I forgot my password) → auto**\n\nパスワードは、ログイン画面の「パスワードをお忘れの方」から再設定できます。登録済みのメールアドレスを入力すると、再設定用のリンクが届きます。リンクの有効期限は24時間です。…\n\n*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. …*\n\n**「ストレージの上限を知りたい」 (What's our storage limit?) → agent**\n\n貴社は現在「ビジネス」プランをご契約中です。ビジネスプランでは、ワークスペース全体のストレージ上限は1TBです。添付ファイルには1ファイルごとの上限もあり、ビジネスプランでは1ファイル500MBまでです。\n\n*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.*\n\nThe plan came from the customer data, and the limits came from a help article. The agent put the two together into one answer.\n\n**「身に覚えのないログインがある」 (A login I don't recognize) → human**\n\nThe router gave `requires_human` a probability of 0.95. Here's the handoff note staff received:\n\n株式会社あおばシステムズ（アカウントID 1010）。身に覚えのない海外からのログイン通知を受けたため、調査してほしいとの依頼。フォームの区分は「その他」。…\n\n*Aoba Systems Inc. (account ID 1010). Received a notification of an unrecognized login from overseas and is asking us to investigate. Form category: \"Other\". …*\n\nThe customer filed it under \"Other\", but the router read the text and treated it as a security issue.\n\nI also checked the routing against ground-truth labels. With only 13 tickets this is a sanity check, not an evaluation:\n\nIn other words, the thresholds need tuning on more data before they mean much. That's the kind of iteration a cheap router makes painless.\n\nFor this demo, yes. A few observations:\n\n`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.\nI 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.\n\nA 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.\n\nPipeline 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.\n\nThe code is on GitHub: [takimiko-gohan/sf-agent-workflow-pipeline](https://github.com/takimiko-gohan/sf-agent-workflow-pipeline)", "url": "https://wpnews.pro/news/routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake", "canonical_source": "https://dev.to/takimiko_gohan/routing-japanese-support-tickets-with-a-004m-token-model-in-snowflake-ha8", "published_at": "2026-11-30 12:40:49+00:00", "updated_at": "2026-11-30 12:45:10.932866+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-tools", "mlops"], "entities": ["Snowflake", "snowflake-decision", "Cortex Agent", "AI_COMPLETE", "Pipeline Builder", "TaskFlow"], "also_reported_by": [], "takeaway": "A cheap decision model called once per ticket with four simultaneous questions (category, KB article, requires_human, needs_account_data) and probability thresholds can route Japanese tickets to templates, an agent, or humans without any translation step.", "recommendation": {"advice": "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.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake", "markdown": "https://wpnews.pro/news/routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake.md", "text": "https://wpnews.pro/news/routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake.txt", "jsonld": "https://wpnews.pro/news/routing-japanese-support-tickets-with-a-0-04-m-token-model-in-snowflake.jsonld"}}