Recipe catalog / handoff
Check handoff rules
handoff is a Jev recipe from the jev-recipes TypeScript package. Decide whether a request matches your human escalation rules. Use it when you need to decide whether your escalation rules call for a human.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use handoff in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { handoff } from 'jev-recipes/handoff';
const result = await handoff({
"request": "Please connect me with a person.",
"rules": [
{
"id": "requested-human",
"description": "The customer explicitly asks to speak with a human support representative."
}
]
});
console.log(result);
What input does handoff take?
| Field | Type | Needed |
|---|---|---|
| request | string | Required |
| context | string | Optional |
| rules | array | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"request": {
"type": "string"
},
"context": {
"type": "string"
},
"rules": {
"minItems": 1,
"maxItems": 50,
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"id",
"description"
]
}
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"request",
"rules"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"decision": {
"type": "string",
"enum": [
"human",
"continue",
"review"
]
},
"matchedRules": {
"type": "array",
"items": {
"type": "string"
}
},
"uncertainRules": {
"type": "array",
"items": {
"type": "string"
}
},
"checks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"matches",
"does_not_match",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"matches",
"does_not_match",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"matches",
"does_not_match",
"unclear"
]
}
},
"required": [
"id",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}
},
"required": [
"model",
"usage",
"status",
"decision",
"matchedRules",
"uncertainRules",
"checks"
],
"additionalProperties": false
}
}What does a handoff result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo handoff.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"decision": "human",
"matchedRules": [
"requested-human"
],
"uncertainRules": [],
"checks": [
{
"id": "requested-human",
"status": "ready",
"verdict": "matches",
"confidence": 0.96,
"probabilities": {
"matches": 0.97,
"does_not_match": 0.015,
"unclear": 0.015
}
}
]
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
Result
| Decision | Condition |
|---|---|
human |
At least one rule confidently matches. |
review |
No confident match exists and at least one rule is unclear or below the confidence threshold. |
continue |
Every rule confidently does not match. |
checks preserves each rule ID with its verdict (matches, does_not_match, or unclear), status, confidence, and probabilities. Check status reflects the confidence threshold. A high-confidence unclear verdict still describes uncertainty about whether the rule applies.
matchedRules contains confident matches. uncertainRules contains unclear and low-confidence checks. One confident match is enough for decision: "human" and status: "ready", even when other rules are uncertain. A review decision always has review status.
The result includes model and token usage. Inspect the outcome as well as its review status.
Reuse and calls
Uses the shared item-check helper. This folder owns the rule criteria and human, continue, or review decision. All rule questions are sent in one request. A live invocation makes one logical Jev request; SDK retries can add transport attempts.
Limits
Write observable rules and supply the facts needed to evaluate them. Compute exact amounts, deadlines, and permissions in code. This recipe does not contact anyone, execute actions, or enforce access controls.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo handoff shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe handoff to inspect the input and result schemas.
How accurate is handoff?
jev-1.13.0 / 2026-10-04 / 60 development cases
Scoring revision 2.
47 ready decisions, with 96% accuracy among those decisions.
95% case-level interval: 82% to 96%. Related synthetic cases are correlated.
This measures the recorded dataset, not general readiness. Label sources: author-synthetic: AI-authored synthetic boundary cases for jev-recipes; labels have not had independent human review.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of handoff?
- Does not contact a person, execute actions, or enforce permissions.
- Provide 1 to 50 rules with unique IDs; uncertain rules require review unless another rule confidently matches.
Which recipes are related to handoff?
- route: Use route to choose a handler when escalation is not the decision.