Persona and proactivity
A companion needs two things that a chat prompt cannot provide: a self that stays recognizable, and a reason to speak that is not “the user sent a message”.
The persona spec
A character card compiles into a reviewable PersonaSpec:
| Section | Holds |
|---|---|
| identity | Name, description, scenario |
| traits | Personality |
| voice | System prompt, style, post-history instructions, verbal tics |
| boundaries | NSFW flag, minimum age, blocked topics |
| relationships | Role and dynamics |
| canon | Fixed facts |
| examples | Dialogue samples |
| greeting | First message |
The compiler accepts native dicts and SillyTavern V1/V2/V3 cards, including character_book entries.
render_system_prompt(max_chars) emits the sections in a stable order and truncates at the character budget. Production assembles the sections through the harness so they can be cached and diffed.
The critic
score_reply is a deterministic baseline:
| Check | Penalty |
|---|---|
| Empty reply | Score 0 |
| OOC marker (English, plus localized ZH/JA/KO refusal phrases) | −30 each |
| Reply longer than 1600 characters | −10 |
| Blocked topic | −20 each |
| No canon keyword | −5 |
A reply passes at score >= 70. Markers are module-level data, so adding a language is a data change, not a new branch. Each marker is a phrase, never a bare ai or roleplay, so ordinary CJK prose passes.
The production critic adds a model judge with the same rubric plus repetition, voice, and emotional appropriateness.
Persona lock
“Persona lock” means the character survives a model swap:
- Compile the card once into
PersonaSpec. - Run a fixed eval set against every candidate model.
- Diff the outputs against the canon and the voice.
- Reject a model that drifts, even if its prose is prettier.
The goal is not a frozen character. It is a character whose changes are deliberate and reviewable.
Proactivity and the hearth
A proactive message is an interruption. The hearth decides whether it is worth it:
- candidates are scored by utility;
- quiet hours suppress delivery;
- per-day and per-conversation caps apply;
- delivery is deferred, not dropped;
- accept, ignore and mute feed back into the policy.
Proactive messages are opt-in, rate-limited, and quiet-hour aware. The failure mode to avoid is a companion that talks more because it can.
The runtime
The runtime tracks mood, energy, affinity, and life events. A relationship has affinity, a level, and milestones. The state advances between conversations, which is what makes presence different from a saved transcript.
The chat path never blocks on the agent path. If the runtime or the scheduler is slow, the reply still streams.
Safety runs twice
Safety gates run before generation and after generation. The reference gate is deterministic: a minor is blocked, self-harm gets a support response rather than roleplay, explicit sexual content is blocked when nsfw is false, and configured topics are blocked.
The production cascade adds a fast pre-classifier, a token-level streaming filter, post-generation classification, media moderation, and an audit record with the policy version.
Read next
- Operations: the service, tenancy, and the deployment checklist.