Persona Suggestions (Persona Templates)

Overview

Persona Templates are a creator-defined entity type that provides role suggestions for package users. Unlike user personas (which are personal roleplay identities owned by the player), templates are authored by the creator and describe suggested roles a user can play when starting a conversation from a package.

A package can suggest multiple templates (N:M). At conversation start, the user picks one of those templates — or "empty" to skip — and the choice is attached to the conversation (1:1).

Implementation Status

Status re-verified against the tree 2026-09-29 (KB audit): every layer below is built. The rows that said Not built / Partial were stale; the evidence for each is in the row.

Layer Status
persona_templates table Shipped
package_persona_template_bindings (N:M) Shipped
Creator workbench CRUD + edit form Shipped
Project item type, entity changelog, graph node Shipped
Package-save end-to-end N:M (multiple templates per package) Shipped — fn_save_package_full(p_persona_template_uuids UUID[]) (database/v1/functions/47e_package_authorship_functions.sql)
Conversation attachment (persona_template_id on web_conversations) Shipped — database/v1/26_tables_persona_templates.sql; carried on branch
Conversation-start modal ("Select role / Empty") Shipped — the role pick raised on Start (StartExperienceModal, 2026-07-24 5419bad5)
Pipeline injection (the template's name, description and prompt appended to the persona content slot as a "Suggested role") Shipped — Core/Pipeline/Providers/PersonaContentProvider.cs
Detach control mid-conversation Shipped — Who drawer Suggested Role → Remove role (chat-v2/components/WhoDrawer.tsx)
The role in a story on chat. (the role row, Your role details, Remove role) Built — the persona panel (PERSONA_SURFACE.md M3)
Choosing a role on chat. at start Shipped — chat.'s package start offers the package's roles and Just my persona (PackageStartPage.tsx, 2026-11-17 0c53a7ab5)
Choosing a role again on chat. after removing it Planned — see Planned: roles with the package experience on chat.

How It Works (Target State)

The Appendix Model

A persona template acts as a read-only appendix layered alongside the user's own persona:

  1. Creator creates templates describing roles (e.g., "The Knight", "The Healer", "The Merchant").
  2. Templates are bound to packages via N:M relationships — a package can suggest multiple roles.
  3. User starts a conversation from a package and sees the bound templates plus an "Empty" option in a modal.
  4. User picks one template (or empty). The choice is stored on the conversation.
  5. User can detach the template at any point during the conversation.
  6. User can edit their own persona freely; the template stays read-only.

The template is appended to the user's persona card inside the same persona content slot the mode already injects — no new content key, no mode edits required. The mode's sub_prompts.provider_key = 'persona' slot does all the work. The model reads it under a "Suggested role:" heading as the template's name, description and prompt, each left out when blank — so a template with only a name and a description is still a role. {{user}} stays the persona's name: the role is what the reader plays, not who they are.

Key Principles

How Templates Differ from User Personas

Aspect User Persona Persona Template
Owner User (player) Creator
Purpose Personal RP identity Suggested role for a package
Editable by user Yes No (read-only)
Lorebook bindings Yes (N:M) No
Token counting Yes (cached) Yes (cached, chars * 2 / 7)
Visibility Private to user Public via bound packages
Managed via Vault › Personas Creator Projects › Workbench
Lifecycle Permanent until deleted Attached/detached per conversation

Creator Workflow

  1. Open a project in the Creator Workbench.
  2. Create persona templates via the "+ Create" expandable section.
  3. Each template has: name, description, prompt text, optional avatar (gallery image).
  4. Templates appear in the project's entity list, filterable by the "Templates" tab.
  5. When building a package, bind one or more templates to the package (multi-select; N:M).
  6. Users see all bound templates in the conversation-start modal.

Database Schema (Shipped)

persona_templates Table

Column Type Description
id SERIAL PK Internal identifier
uuid UUID Public-facing identifier (used in API routes)
created_by_user_id INTEGER FK Creator who owns this template
name VARCHAR(100) Template name (e.g., "The Knight")
description VARCHAR(500) Short description of the role
prompt TEXT Full prompt text appended to the persona slot
avatar_image_id INTEGER FK Optional gallery_images.id (resolved via image-link pattern)
character_count INTEGER Cached prompt character count
token_count_approx INTEGER Generated: character_count * 2 / 7
is_deleted BOOLEAN Soft-delete flag
created_at TIMESTAMPTZ Creation timestamp
updated_at TIMESTAMPTZ Last update timestamp

The legacy avatar_url VARCHAR column was replaced by the shared entity_avatar_image_links pattern. Avatars are minted through IImageUrlSigner.PreferredUrl(uuid, ImageVariant.Avatar) at read time.

package_persona_template_bindings Table (N:M)

Column Type Description
id SERIAL PK Unique identifier
package_id INTEGER FK Package this binding belongs to
persona_template_id INTEGER FK Template being suggested
sort_order INTEGER Display order within the package

Unique constraint on (package_id, persona_template_id). Both FKs cascade-delete.

Planned column on web_conversations

ALTER TABLE web_conversations
    ADD COLUMN IF NOT EXISTS persona_template_id INTEGER
    REFERENCES persona_templates(id) ON DELETE SET NULL;

Nullable: NULL means "no template" (the user picked "Empty" or started outside a package).

API Endpoints

Shipped — Creator CRUD

All routes require authentication and verify creator ownership. Routes use the template UUID, not the integer ID.

Method Route Description
GET /api/creator/persona-templates List the caller's templates
GET /api/creator/persona-templates/{templateId:guid} Get a single template
POST /api/creator/persona-templates Create a template
PUT /api/creator/persona-templates/{templateId:guid} Update a template (surgical)
DELETE /api/creator/persona-templates/{templateId:guid} Soft-delete a template

Create / Update request

{
  "name": "The Knight",
  "description": "A sworn protector of the realm",
  "prompt": "You are Sir Aldric, a veteran knight...",
  "avatarImageUuid": "..."  // gallery_images.uuid; Guid.Empty clears on PUT
}

Response

{
  "id": "9f1c…",
  "name": "The Knight",
  "description": "A sworn protector of the realm",
  "prompt": "You are Sir Aldric, a veteran knight...",
  "avatarImageUuid": "...",
  "avatarUrl": "/api/img/.../best/avatar",
  "characterCount": 245,
  "estimatedTokens": 70,
  "createdAt": "2026-03-01T10:00:00Z",
  "updatedAt": "2026-03-01T10:00:00Z",
  "creatorSlug": "...",
  "creatorUsername": "...",
  "creatorGlobalName": "..."
}

Planned — Conversation attachment

Extend the existing conversation endpoints; no new route group needed.

Pipeline Integration (Planned)

Templates re-use the existing persona content slot. Implementation lives in two files:

  1. IWebConversationRepository.GetPersonaForConversationAsync — extend to also fetch the attached template in the same round-trip (return shape becomes (IPersona?, PersonaTemplate?)).
  2. Core/Pipeline/Providers/PersonaContentProvider.cs — concatenate the template prompt after the user's persona card. When the user has no persona but did pick a template, render just the template. When both are absent, return empty as today.

Modes do not need to change. Any mode whose prompt template already includes a provider_key='persona' sub-prompt will pick up the appendix automatically. No new ContextKeys entry, no new sub-prompt content type.

Project Integration

Persona templates are a project item type (persona_template, ContentEntityType = 8), meaning they:

Content Entity Type

PersonaTemplate = 8 in the ContentEntityType enum:

Value Type
0 Character
1 Mode
2 Lorebook
3 Creator
4 Conversation
5 Persona
6 Package
7 Project
8 PersonaTemplate

Outstanding Work

The following items remain before the feature is end-to-end usable.

Package N:M save path

The schema is N:M but the save layer is 1:1:

Conversation attachment + modal

Pipeline injection

Planned: roles with the package experience on chat.

(Owner, 2026-10-16: Remove role is planned together with chat.'s package support, so removing and choosing a role read as one package experience.)

Where it stands.

What gets built with chat.'s package start.

Done when:

Future Considerations