Calibrate confidence & abstention thresholds

Use Kai's normalized confidence score to act automatically on settled decisions and escalate uncertain cases to human review or Zen.

An uncalibrated classifier fails silently on ambiguous inputs. Kai returns both answer_confidence (p_max) and normalized confidence ((n·p_max - 1)/(n - 1)), so one abstention threshold works identically across 3-class and 30-class decisions.

Architecture & contract

When confidence is 0, every option is equally likely; when confidence is 1, one option carries all probability mass. Set a conservative threshold (such as >= 0.70) for automated actions and route everything below it to a human queue or zen6.

Primary endpoint: POST /v1/decisions · Status: shipped · Level: practitioner

Run it across all four surfaces

hanzo decisions create --model kai --data '{
  "state": "Please check whether our EU VAT exemption applies to last month and also reset Alice login.",
  "questions": {
    "route": {
      "type": "choice",
      "instructions": "Pick the single primary queue for this ticket.",
      "criteria": {
        "tax_compliance": "VAT, W-8, W-9, and tax exemptions",
        "account_access": "Password, SSO, and login resets",
        "billing": "Invoices and payment retries"
      }
    }
  }
}' | jq '.answers.route | if .confidence >= 0.7 then {action: "auto", queue: .choice} else {action: "escalate", confidence: .confidence} end'
import { Configuration, AiApi } from 'hanzoai';

const ai = new AiApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await ai.postDecisions({
  model: 'kai',
  state: 'Check our EU VAT exemption and also reset Alice login.',
  questions: {
    route: {
      type: 'choice',
      instructions: 'Pick the single primary queue.',
      criteria: {
        tax_compliance: 'VAT and tax exemptions',
        account_access: 'Password and login resets',
        billing: 'Invoices and payment retries',
      },
    },
  },
});
const ans = data.answers.route;
const action = ans.confidence >= 0.7 ? ans.choice : 'human_review';
console.log({ action, confidence: ans.confidence, probs: ans.probabilities });
import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AiApi

api = AiApi(ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"])))
res = api.post_decisions({
    "model": "kai",
    "state": "Check our EU VAT exemption and also reset Alice login.",
    "questions": {
        "route": {
            "type": "choice",
            "instructions": "Pick the single primary queue.",
            "criteria": {
                "tax_compliance": "VAT and tax exemptions",
                "account_access": "Password and login resets",
                "billing": "Invoices and payment retries",
            },
        }
    },
})
ans = res["answers"]["route"]
print("auto:" + ans["choice"] if ans["confidence"] >= 0.7 else "escalate:human_review")
curl -s https://api.hanzo.ai/v1/decisions \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kai",
    "state": "Check our EU VAT exemption and also reset Alice login.",
    "questions": {
      "route": {
        "type": "choice",
        "instructions": "Pick the single primary queue.",
        "criteria": {
          "tax_compliance": "VAT and tax exemptions",
          "account_access": "Password and login resets",
          "billing": "Invoices and payment retries"
        }
      }
    }
  }' | jq '.answers.route | {choice, confidence, action: (if .confidence >= 0.7 then "auto" else "escalate" end)}'
curl -s -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "ai",
      "arguments": {"op": "post_decisions", "input": {"model": "kai", "state": "Ambiguous mixed ticket", "questions": {"route": {"type": "choice", "instructions": "Queue?", "criteria": ["tax", "account", "billing"]}}}}
    }
  }'

Verify the outcome

  • Multi-intent tickets should drop below 0.70 confidence and trigger escalate.
  • Single-intent tickets should exceed 0.85 confidence and route automatically.

Production guardrails

  • Tune thresholds empirically on held-out org datasets (/v1/eval/datasets) rather than guessing.
  • Pin routing.calibration beside your thresholds so calibration shifts drop to shadow.

Next steps & Hanzo University

Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.
Last updated Nov 25, 2026