Routing decisions
How plugins influence routing today — contributeFamilyPivot, contributeIntentToolMap and contributeIntentClassifiers — and what a plugin cannot override.
An intent in
@pleach/coreis a plain string,"<plugin>.<intent>"by convention, to avoid collisions between plugins. There's nothing to register first. Plugins influence model fallback throughcontributeFamilyPivot, tool schemas throughcontributeIntentToolMap, and the turn's intent throughcontributeIntentClassifiers.
The hooks
| Hook | What it does |
|---|---|
contributeFamilyPivot | Supplies the two operations a fallback retry uses: deriveFamilyFromModelId(modelId) and pickNextInFamily(family, currentModel, triedModels). With several contributors, the last non-null one wins. |
contributeIntentToolMap | Maps an intent to priority tools, which keep their full schema when tool schemas are condensed. |
contributeIntentClassifiers | Contributes classifiers that can set the turn's intent. See Intent classifiers. |
Intent classifiers
On a turn that host classification and keyword classification left
ambiguous, the runtime runs every contributed classifier before it asks
the utility model. Each classify call is synchronous and returns the
classifications it can make, or []. The top result is adopted as the
turn's intent when its confidence is 0.7 or higher, and the utility call
is then skipped. Below 0.7, or on a tie between different intents, the
turn continues as it would without classifiers. Host and keyword
classification rank above plugin classifiers.
contributeIntentClassifiers: () => [{
id: "my-plugin.refund",
classify: ({ userText }) =>
/refund|chargeback/i.test(userText)
? [{ intent: "my-plugin.refund", confidence: 0.8, toolAlignment: ["refund_lookup"] }]
: [],
}],A classifier's intent must be namespaced "<plugin>.<intent>"; other results are discarded. Tools in toolAlignment reach the
planner as non-binding evidence. You can also read the contributions
through runtime.plugins.collectIntentClassifiers().
What a plugin can't override
- Seam-level routing.
callClassliterals are seam-only — see Plugin contract — what a plugin cannot do. - Registration timing. Plugins register at construction time, before
SessionRuntimeboots.
How a fallback picks a model
When a retry falls back, the runtime calls your
deriveFamilyFromModelId on the current model, then your
pickNextInFamily with that family, the current model and the set of
models tried this turn. Return a model from the same family, or null
when the family is exhausted. Neither operation sees a call class. See
Call classes and Family lock.
With @pleach/gateway, each routed call carries a RoutingDecision.
The type is exported from @pleach/core/model-family.
For a starting point, see the
@pleach/recipes verticalAgent factory.
What this is NOT
- Not a per-call model picker. Plugins can't choose between GPT-4 and Claude on a per-call basis outside the family lock. The family is locked at session start; pivots route within the family.
- Not a cost-aware router. Cost routing lives in
@pleach/gatewayand reads from the substrate's family-strict cascade. Plugins don't override gateway-level cost decisions.
Where to go next
Family lock
Why model family is locked at session start and how cascade pivots work within it.
Call classes
The four canonical call classes — utility, reasoning, converse, synthesize.
Model resolution matrix
The substrate's (Family × CallClass) → model resolution table.
Authoring
The full HarnessPlugin hook surface.
Stream observers
The contributeStreamObservers hook — verdict ladder, factory pattern, and worked examples for canonicalizing tool-call dialects and stopping on refusal patterns.
Post-tool tier
The contributePostToolTier hook — uniform enrichment across tool batches for citations, entities, quality scores, and safety flags.