Skip to main content

Decide First, Then Respond: Bytedesk Starts Validating Spring AI Decision Models for Customer Service

· 9 min read
Jack Ning
Maintainer of Bytedesk

A customer writes, "The shoes are the wrong size, I want to return them." Most of what the service system does next is not "write a paragraph." It is a chain of judgments: is this a return request? how does the customer feel? should a human take over? is there enough in the knowledge base to answer?

Until now those judgments were handled either by keyword rules or as a by-product of a chat LLM. Bytedesk has now got a Spring AI 2.1 decision model (DecisionModel) running locally, built for exactly this kind of "pick plus probability" judgment. It is a demo only; the business integration plan is still a proposal awaiting approval. This article explains what the model is, where it fits in Bytedesk, and three boundaries we found while testing locally.

What a decision model is: triage, not scripts​

A chat LLM is good at organizing language, explaining problems, and writing replies. A decision model does one thing: choose among a fixed, finite set of outcomes and report how likely each one is. It produces no text, so there is no "made-up answer," but it is far from infallible.

Spring AI's DecisionModel defines three question types, supported by every provider:

QuestionAsksReturns
Yes/No (YesNoQuestion)Whether something holds; optional criteria for when it counts as yesprobability of yes
Choice (ChoiceQuestion)Which option fits the input; each option may carry a descriptionselected option + per-option probabilities
Score (ScoreQuestion)Which level of an ordered scale appliesnearest level + expected value + per-level probabilities

One request can carry several questions, and the input can be plain text, named fields, or a conversation.

What Bytedesk has built: a runnable demo​

Under the Ollama provider in modules/ai, we added a set of demo-only endpoints covering every usage in the official documentation. They are off by default, available only when bytedesk.debug=true and Ollama chat is enabled, and they write nothing to the database or to business routing:

EndpointInputDemonstrates
/ollama/decision/triageone messagethree question kinds in one call: is a defect reported (yes/no), what is it about (choice), how satisfied (score)
/ollama/decision/fieldsmessage + order count, late deliveriesstructured field input
/ollama/decision/conversationuser message + assistant messageconversation input: did the assistant answer the question
/ollama/decision/guardrailone messageguardrail: detect prompt injection, act only at a high threshold (0.9)
/ollama/decision/models—list locally available models

For triage on "My new headphones arrived, but the left side doesn't work. Can I get my money back?", the local d1-omni:600m model returned the following in about 190 ms:

{
"defect": { "kind": "yes_no", "probability": 0.95, "isYes": true },
"topic": { "kind": "choice", "value": "product",
"rankedOptions": ["product", "other", "delivery", "account"] },
"satisfaction": { "kind": "score", "nearestLevelLabel": "unhappy",
"expectedValue": 0.30 }
}

The useful part is not "it picked product." It is who the runner-up is and by how much. When the top two options are close, the message is ambiguous and should go to a person rather than be routed by force.

Two implementation details are worth noting. First, all four runtime profiles set spring.ai.model.decision=none explicitly, because Spring AI's auto-configuration conflicts with the project's custom OllamaApi; the model instance is therefore built by hand. Second, SystemOneClient defaults to a hosted endpoint and two retries. Business code must set the Ollama URL explicitly and tighten the retry policy, or a single upstream failure stretches into tens of seconds.

Where it fits in a customer-service system​

We walked through the existing judgment points in Bytedesk and sorted them into three tiers by feasibility.

Ready to implement (choice / score)

  • Conversation intent classification. Bytedesk's intent settings already hold a business category list (product inquiry, pricing, order status, complaints, returns, and so on: 13 categories). It can serve directly as the options of a choice question, returning a probability per category. Compared with a chat model self-reporting a confidence number, a probability distribution makes "unsure" a signal the workflow can act on for the first time.
  • Emotion recognition. The existing happy / angry / sad / other categories also fit a choice question. Testing also showed that asking intent and emotion in the same request gives almost identical probabilities to asking them separately, so one call yields both.
  • Ticket priority suggestions. Low / medium / high / urgent is an ordered scale and suits a score question. Local samples ranked sensibly, but priority drives SLA, so it should remain a reference for the agent.

Shadow mode only (yes/no)

  • Human-handoff detection, tool-call intent, "is the knowledge base sufficient to answer," and input guardrails. On the local small model these have no evidence of usability yet (see the next section), so for now the wiring goes in and only records, never acts.
  • Handoff deserves particular care. A wrong handoff interrupts a bot that was helping; a missed one leaves the customer stuck in the wrong self-service flow. Both directions are costly.

Not recommended

  • Automatic QA deductions, automatic SLA changes, automatic tool execution, or replacing deterministic business rules. These either have compliance and authorization boundaries or should be guaranteed by code, not by a model.

Three boundaries found in local testing​

We ran a small-sample probe on Ollama 0.40.18 with d1-omni:600m (a decision-capable model of roughly 380 million parameters). The sample size is single digits, so it shows shape and boundaries, not quality. Three findings materially changed the design.

1. The question language must match the message language​

The same yes/no question, "Does the customer explicitly ask for a human agent?", behaved very differently across four combinations:

QuestionMessageExplicit handoffReturn policyChit-chat
EnglishEnglish0.9950.690.15
EnglishChinese0.9970.970.68
ChineseChinese0.9990.260.06

With an English question and Chinese messages, the model answered "yes" to almost everything and lost all discriminative power; switching the question to Chinese restored it immediately. "Write the question in English" is not a general rule. Every task has to be evaluated with messages in the target language.

2. Some judgments are beyond a small model for now​

Even with the right question language, handoff itself stays unreliable on this model: "AI is fascinating, what can you do?" scored 0.97 for wanting a human, and "What hours is the human support team available?" scored 0.99. That is a semantic error, not a language one, and no threshold fixes it.

We also found that the optional "when it counts as yes" criteria on a yes/no question made no difference at all: with or without them the output probabilities were identical. You cannot rely on a criteria text to define the boundary. The boundary has to come from option design and thresholds, and then be locked in through evaluation.

3. Confident probabilities are not accurate ones​

Adding Chinese descriptions to the options was inconsistent: for a return request the score rose from 0.88 to 0.98, but for a clear complaint it fell from 0.94 to 0.27. A second model we compared, laya, gave extreme 1.00 / 0.00 distributions on clear samples and near-uniform ones on ambiguous samples. It is less well calibrated than d1-omni.

The numbers say: the threshold is a business decision, not a model parameter. It has to be calibrated per task and per language on your own service transcripts, with the calibration set kept separate from the acceptance set.

Why shadow mode comes first​

Given those boundaries, the integration plan follows a few rules:

  • Off by default. The global switch and every per-task switch start at off; when off, every code path behaves exactly as it does today.
  • Shadow before active. With shadow on, the model runs alongside and records its judgments, latency, and disagreement with the existing path. It writes no business fields and triggers no actions.
  • Per-task rollout. Intent and emotion classification go active per bot or per workgroup only after the shadow period accumulates enough samples and passes the quality gate. Yes/no scenarios wait for a model that passes evaluation before anyone discusses going live.
  • No cross-provider fallback. When the local model fails, customer messages are never sent to another cloud provider without authorization.
  • The model advises; the business decides. Tool arguments, order facts, refund permissions, and approvals stay with the existing business validation.

Architecturally, the decision capability will live in modules/ai as a provider-neutral contract: business modules say "this task, this input," and an adapter layer decides whether to call Ollama or another provider. Changing the model later becomes a configuration change rather than a rewrite of intent recognition and routing.

Next​

The plan and implementation record for the demo are in the repository at docs/plans/2026-11-26-ollama-decision-model-demo-plan.md. The overall business integration proposal is at docs/plans/2026-11-26-decision-model-customer-service-application-plan.md; its status is pending approval and it is not published to the documentation site. No business code will be written before the plan is approved.

Open questions include: should intent classification keep the existing four-value enum or adopt the 13 business categories; which model route to take for yes/no scenarios; should the switch be global or per bot; and whether a decision audit table is needed.

References​

Latency and probability figures in this article come from small single-machine samples. They illustrate the shape and the feasibility boundary, not production quality or performance.