Recipe catalog / wake-gate
Decide whether an event should wake a waiting agent
Should event wake an agent that is paused until waitingFor happens: wake now, keep waiting, or ignore it as unrelated?
A paused or sleeping agent receives a timer tick, webhook, message, or file change and you must decide whether to resume its model loop.
Explore this recipe interactively ยท Source and implementation guide
Use wake-gate 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 { wakeGate } from 'jev-recipes/wake-gate';
const result = await wakeGate({
"waitingFor": "The CI pipeline for pull request #418 finishes, so the agent can read the results and either merge or fix failures.",
"event": "GitHub webhook: check_suite completed for PR #418 with conclusion \"failure\". 2 of 14 jobs failed: unit-tests (node 22) and lint.",
"context": "The agent opened PR #418 twenty minutes ago and paused until CI completes.",
"minConfidence": 0.8
});
console.log(result);
Input contract
| Field | Type | Needed |
|---|---|---|
| waitingFor | string | Required |
| event | string | Required |
| context | string | Optional |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"waitingFor": {
"type": "string"
},
"event": {
"type": "string"
},
"context": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"waitingFor",
"event"
]
},
"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"
]
},
"verdict": {
"type": "string",
"enum": [
"wake",
"not_yet",
"unrelated",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"wake",
"not_yet",
"unrelated",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"wake",
"not_yet",
"unrelated",
"unclear"
]
}
},
"required": [
"model",
"usage",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}Saved example result
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo wake-gate.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"verdict": "wake",
"confidence": 0.95,
"probabilities": {
"wake": 0.95,
"not_yet": 0.02,
"unrelated": 0.01,
"unclear": 0.02
}
}
Evaluation evidence
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
Limitations
- Judges only the supplied event against the stated wait condition. It does not know about earlier events or the agent's full history unless context supplies them.
- A wake verdict means the condition appears met or materially changed; the resumed agent still has to verify the actual state.
Related recipes
- goal-drift: Use goal-drift to check whether a resumed agent's next step still serves its goal.
- progress-stall: Use progress-stall to detect an agent that keeps waking without making progress.