Gate

Replace a hand-picked confidence threshold with a calibrated accept or escalate decision that carries a stated, auditable guarantee: a bound on expected risk, a high-probability bound on risk, or a false-discovery-rate bound on the decisions it approves.

Request

from cli_sdk import AnthropicBackend, CLIClient, Gate
 
with CLIClient() as client:
    result = client.evaluate(
        context={"transfer_request": "Send 4,800 EUR to the supplier on file.", "account_id": "acct_1042"},
        backend=AnthropicBackend(model="claude-sonnet-5"),
        queries={
            "approve": Gate(
                instructions="Should this transfer be auto-approved?",
                calibration_profile="high-stakes-transfers",
                guarantee="risk_high_probability",
                target=0.01,
                delta=0.05,
            ),
        },
    )
 
gate = result.answers["approve"]
if gate.approved and not gate.is_heuristic:   # decision == "auto_approve"
    execute_transfer()
else:                                         # "escalate"
    route_to_human()

Response

{
  "approve": {
    "type": "gate",
    "decision": "escalate",
    "confidence": 0.93,
    "threshold": 0.98,
    "guarantee": {
      "type": "risk_high_probability",
      "target": 0.01,
      "delta": 0.05,
      "method": "RCPS",
      "statement": "With 95% confidence, the rate of decisions that are auto-approved and wrong is at most 0.01 (RCPS, Hoeffding-Bentkus, n=2400).",
      "calibration_profile": "high-stakes-transfers",
      "calibration_n": 2400,
      "profile_version": 1,
      "stats_version": "cci-sdk/0.1.1+hosted.1"
    }
  }
}

decision is auto_approve when the evidence model’s confidence clears the calibrated threshold, and escalate otherwise. The SDK’s vocabulary also has abstain, but neither the hosted service nor local mode returns it today. The SDK fails closed: any other value in a response is read as escalate, never as approval.

Guarantee modes

The loss on one request is 1 when the gate auto-approves it and the approved action is wrong, and 0 otherwise (escalated requests incur no loss). This 0/1 loss is the only one the hosted engine implements: any other loss is refused with 422 unsupported_option. The two risk modes therefore bound the rate of wrong auto-approvals per request; "fdr" bounds the wrong fraction among approved decisions. If a gate approves a fraction π\pi of requests, a per-request risk of at most target allows an error rate among approvals of up to target/π\text{target}/\pi.

guaranteeStatementMethod
"risk"E[loss]≤target\mathbb{E}[\text{loss}] \le \text{target}, over the calibration draw and the requestConformal risk control (CRC)
"risk_high_probability"With probability ≥1−δ\ge 1-\delta over the calibration draw, the deployed threshold’s risk is ≤target\le \text{target}RCPS (Hoeffding-Bentkus)
"fdr"With probability ≥1−δ\ge 1-\delta over the calibration draw (δ\delta = 0.10 unless you set it), the fraction of auto-approved decisions that are wrong is ≤target\le \text{target}Selective Learn-then-Test (LTT-selective); for a batch decided together in local mode, conformal selection with Benjamini-Hochberg, whose bound is on the expected fraction

"risk" bounds an expectation. "risk_high_probability" is the stronger, audit-friendly statement most compliance reviews want: it bounds the risk of the threshold you actually deployed, with a stated confidence over the calibration draw, at the cost of a larger calibration set. At target=0.01, delta=0.05, no threshold can be certified with fewer than 300 calibration examples (⌈ln⁡(1/δ)/target⌉\lceil \ln(1/\delta)/\text{target} \rceil), even if none of them is an error.

Different gates for different stakes

Calibrate a separate profile for each action type rather than reusing one threshold everywhere:

from cli_sdk import Gate
 
balance_check = Gate(
    instructions="Can this read-only request be completed without confirmation?",
    calibration_profile="low-stakes-actions",
    guarantee="risk",
    target=0.15,
)
wire_transfer = Gate(
    instructions="Should this transfer be auto-approved?",
    calibration_profile="high-stakes-transfers",
    guarantee="risk_high_probability",
    target=0.01,
    delta=0.05,
)

Each profile carries its own labelled examples, its own target and δ\delta, and its own audit history, so every threshold is the output of a calibration procedure a risk committee can evaluate, not a number picked by feel. The high-stakes approvals guide builds this end to end.

Answer attributes

AttributeTypeMeaning
decisionstr"auto_approve" or "escalate" ("abstain" is reserved)
raw["confidence"], raw["threshold"]floatThe evidence model’s score, and the calibrated threshold it was compared with
approvedbooldecision == "auto_approve"
guarantee, is_heuristicThe guarantee card, and whether it is heuristic

Parameters

ParameterTypeDescription
instructionsstr | dict | listRequired. The accept / escalate decision to make.
calibration_profilestrRequired.
guarantee"risk" | "risk_high_probability" | "fdr"Default "risk".
targetfloatRequired, in (0,1)(0, 1). The risk bound, or the FDR level for "fdr".
deltafloatRequired for "risk_high_probability"; optional for "fdr" (0.10). Failure probability over the calibration draw.
lossstr, optionalThe 0/1 error on approved decisions ("zero_one"), the default and the only loss the hosted engine accepts.

The constructor raises ConfigurationError (a ValueError) when instructions or calibration_profile is missing, target is outside (0,1)(0, 1), or guarantee="risk_high_probability" has no delta.