AI analysis & drafting

How Selyf's AI classification and draft generation actually work.

Providers

The configured AI provider (Anthropic or Gemini) — one is active at a time, chosen server-side. Both run the exact same prompts and are validated against the exact same schema, so which one is active doesn’t change what fields you get back.

What triggers a call

A call to the AI provider only happens when you explicitly ask for analysis or a draft on a specific thread. There is no background or bulk analysis of your inbox.

Caching

An analysis result is stored and reused — the same message is never re-sent to the AI provider a second time, which also keeps repeated views instant and avoids unnecessary cost.

Prompt-injection handling

Email content is data, never an instruction. It’s placed inside an escaped, delimited block in the request, separate from the fixed system prompt that defines the task — so a message that says "ignore your instructions" is just more content to analyze, not something the model treats as a command.

Output validation

Every AI response is checked against a strict schema before it’s shown to you or stored: priority is one of a fixed set of values, confidence is a number between 0 and 1, and so on. A malformed response is rejected rather than passed through.

Budgets

Every AI call is checked against a per-account daily and monthly token budget before it’s made, so usage has a hard ceiling rather than growing unbounded.

What AI cannot do

An AI result has no authority to act. It cannot send, delete, or modify anything — its entire output is a label, a reason, and (optionally) draft text shown to you for your own decision.