shipwithjev

Catalog / Tools & apps

0401GitHub

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…

shitianfang/wakegateREADME ↗
# 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` |

Also filed under Tools & apps

  1. 0573

    Support chat: agent offered a human escalation path

    A frustrated customer hits a bot loop twice; the judge checks whether a human handoff was offered.

    everyai-com · Tools & apps

  2. 0572

    Subscription cancel: effective date is explicit

    An agent cancels a subscription; the judge checks the exact date the cancellation takes effect.

    everyai-com · Tools & apps

  3. 0571

    Sales quote: numbers match the official price list

    An agent quotes $29/seat against a price list; the judge checks the quote matches exactly.

    everyai-com · Tools & apps

  4. 0570

    Refund chat: agent stated the amount before issuing it

    A support agent issues a $42.50 refund; the judge checks the exact amount was stated before the refund was confirmed.

    everyai-com · Tools & apps