What Jev sees
The state sent with each item, how to add context, and how to take full control.
Jev only knows what's in the request. For each item, Jev Events builds a small JSON state and asks your questions about it. By default the state for a Twitch chat message looks like this:
{
"message": {
"firstMessage": true,
"text": "is this the dlc boss?",
"author": "viewer_42"
},
"recent": [
{ "author": "viewer_7", "text": "LETS GO" },
{ "author": "viewer_19", "text": "he's so close" },
{ "author": "viewer_3", "text": "phase 2 incoming" }
]
}- The item sits under its noun (
message,line,item), with its text, author, roles and facts. Platform payloads initem.raware never sent. - Facts are lean, precomputed signals. Twitch adds
firstMessagefor first-time chatters andreplyingTofor replies, because both change what a message means. recentholds the messages just before it. Twitch shows three by default. Setcontext: { recent: 0 }to send the text alone.- Whenever there is context, each question is pointed at the item itself, so Jev judges the message and reads the rest as background.
Add what Jev can't know
context.about adds static facts about the stream to every request, such as the game, the rules, or what counts as a spoiler:
const chat = monitor({
source: twitch.chat(),
questions,
context: {
recent: 5,
about: {
game: "Elden Ring",
rules: ["No spoilers past Margit", "No backseating"],
},
},
});Keep it short: it's sent with every item and you pay for its tokens every time.
Say who it's for
When the monitor reads your users' accounts, the same email can matter to one user and not to another. profile adds what your product knows about the person behind each connection, and Jev reads it as context:
const invites = monitor({
source: google.calendar.invites(),
questions: { important: recipes.calendar.important },
profile: async (connection) => {
const user = await db.users.find(connection.userId);
return { role: user.role, team: user.team, focus: user.currentProject };
},
});The profile is read when a connection starts and again every 5 minutes while items arrive, so changes in your product reach Jev without a restart. It lands under profile in the state, next to the item and recent. As with about, every token of it is paid for on every item, so send the few facts that change the answer.
Take full control
Pass state to build the state yourself. It receives the item, plus the recent items, about, profile and the connection:
const support = monitor({
source: from(tickets),
questions,
state: (ticket, { recent }) => ({
ticket: { subject: ticket.facts?.subject ?? null, body: ticket.text },
previousTickets: recent.length,
}),
// Point every question at this key. false sends questions unchanged.
inspect: "ticket",
});Costs
You pay for input tokens only: the state plus your questions, for every item. Context is the lever you control. Every recent message adds its text to every request, and often helps with short, ambiguous messages. Measure the trade-off on your own stream with monitor.stats(), which reports tokens and estimated spend.