Skip to content

Classify Intent

POST
/api/divinity/intent/classify

Classify a free-text query into top-K agent + handler routes.

Returns 429 when another classify call is already in-flight for the same session — the frontend treats this as “leave the prior prediction in place” so rapid keystroke triggers don’t queue overlapping inference.

Returns 503 when the intent classifier service has not been constructed (typically: the bundled prototypes file is missing because scripts/train_intent_classifier.py has not been run yet).

IntentClassifyRequest

Request body for POST /api/divinity/intent/classify.

The optional context slot is reserved for M11.1’s context-aware re-ranker. M11 ignores it; defining the field now keeps the wire shape forward-compatible so M11.1 lands without a schema migration.

object
query
required
Query
string
>= 1 characters <= 4000 characters
topK
Topk
integer
default: 3 >= 1 <= 10
minConfidence
Minconfidence
number
0 <= 1
context
Any of:
object
key
additional properties
any

Successful Response

IntentClassifyResponse

Response body for POST /api/divinity/intent/classify.

object
predictions
required
Predictions
Array<object>
IntentPrediction

One classifier prediction returned to a caller.

confidence is the calibrated, normalized score in [0, 1]. raw_cosine is the underlying cosine similarity preserved for debugging and to let the UI render alternative-confidence bars based on the unbounded raw value when desired. handler_id is null for no-route intents — see :class:IntentDefinition.

object
intentId
required
Intentid
string
label
required
Label
string
agent
required
Agent
string
handlerId
Any of:
string
confidence
required
Confidence
number
<= 1
rawCosine
required
Rawcosine
number
appliedParameters
required
IntentAppliedParameters

Three-knob disambiguation echo per M11 plan §1.4a.

There are three threshold-like values interacting: the UI gate (user_threshold), the handler/strictness floor (handler_min_confidence), and the per-intent model calibration that produced the raw and normalized scores. Surfacing all three in every response lets callers (and future bug reports) see why a prediction was kept, dropped, or suppressed without reverse- engineering from summary strings.

object
userThreshold
required
Userthreshold
number
<= 1
handlerMinConfidence
required
Handlerminconfidence
number
<= 1
rawTopCosine
required
Rawtopcosine
number
normalizedTopConfidence
required
Normalizedtopconfidence
number
<= 1
filteredItems
required
Filtereditems
integer
stabilityFiltered
required
Stabilityfiltered
boolean
embeddingModel
required
Embeddingmodel
string
engineVersion
required
Engineversion
string

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object