wakegate
Experimental gate where Jev decides whether a timer or incoming event is worth resuming a sleeping agent's LLM; code skips only when Jev is confident and always wakes on user…
# wakegate
Before you resume a sleeping agent, ask [Jev](https://vercel.com/ai-gateway/models/jev) whether the wakeup is worth a full LLM turn.
## Why
Long-running agents sleep. A timer fires every 30 minutes to re-check a price, or an email lands while the agent waits for one particular reply. Each wakeup usually resumes the LLM with its whole context, and many of them end in "nothing changed, back to sleep". That turn's tokens are spent anyway.
wakegate puts one Jev call in front of the resume. Jev is TypeSafe AI's judgment model: it reads JSON state and returns probabilities for typed questions without generating text. A call took about 250 ms in our runs. wakegate asks one question: given what the agent said it was waiting for, is this worth waking up for? Plain code handles everything else, including how long to sleep and when to force a wake.
## Install
Not on npm yet.
```sh
npm install github:shitianfang/wakegate ai
```
`ai` (the Vercel AI SDK, 7.0.105 or later) is a peer dependency. By default the model is `typesafe-ai/jev` on the Vercel AI Gateway, which reads `AI_GATEWAY_API_KEY`.
## Usage
```ts
import { shouldWake } from "wakegate";
// An email arrived while the agent slept.
const verdict = await shouldWake({
waitingFor: "A reply from Dana Li (HR at Acme) about scheduling my second-round interview",
event: { type: "email", from: "noreply@medium.com", subject: "Your Daily Digest: 7 stories about AI agents" },
skipped: 0, // skips in a row so far: store verdict.skipped and pass it back next time
});
// { wake: false, reason: "judged", probability: 0.01, skipped: 1 }
if (verdict.wake) await resumeAgent(); // your full LLM turn
```
| Field | |
|---|---|
| `waitingFor` | What the agent said it was waiting for when it went to sleep. |
| `event` |