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:
- Creator creates templates describing roles (e.g., "The Knight", "The Healer", "The Merchant").
- Templates are bound to packages via N:M relationships — a package can suggest multiple roles.
- User starts a conversation from a package and sees the bound templates plus an "Empty" option in a modal.
- User picks one template (or empty). The choice is stored on the conversation.
- User can detach the template at any point during the conversation.
- 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
- Templates are read-only for users — only the creator can edit them.
- Users attach/detach freely — no permanent commitment to a role.
- Templates are additive — they supplement, never replace, the user's persona.
- One template per conversation. Multiple templates per package (the modal picks one).
- Templates re-use the existing
personapipeline slot — no schema change to modes.
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
- Open a project in the Creator Workbench.
- Create persona templates via the "+ Create" expandable section.
- Each template has: name, description, prompt text, optional avatar (gallery image).
- Templates appear in the project's entity list, filterable by the "Templates" tab.
- When building a package, bind one or more templates to the package (multi-select; N:M).
- 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 VARCHARcolumn was replaced by the sharedentity_avatar_image_linkspattern. Avatars are minted throughIImageUrlSigner.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.
POST /api/chat/conversationsacceptspersonaTemplateId: Guid?on both the standard path and the package-start path. On the package path, the value must be present inpackage_persona_template_bindingsfor that package or the call returns 400.PATCH /api/chat/conversations/{id}acceptspersonaTemplateIdwith the same three-state semantics asuserPersonaId(omit = leave, value = set,null= detach).GET /api/packages/{id}returns the array of bound templates (currently returns a single template — see Outstanding Work below).
Pipeline Integration (Planned)
Templates re-use the existing persona content slot. Implementation lives in two files:
IWebConversationRepository.GetPersonaForConversationAsync— extend to also fetch the attached template in the same round-trip (return shape becomes(IPersona?, PersonaTemplate?)).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:
- Appear in the project entity list alongside characters, modes, lorebooks, packages.
- Are filterable via the "Templates" tab in the workbench.
- Are testable from the workbench Sandbox: a role picker next to the opening picker attaches any of the saved package's bound templates (or none) to the sandbox conversation, the same choice a reader makes at start.
- Are tracked in the entity changelog (add/remove events).
- Use synthetic IDs with the
PT#prefix in the workbench graph. - Participate in the proposal workflow (
project_item_proposals.entity_type = 8).
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:
fn_save_package_fulltakes a singlep_persona_template_uuid UUID— needsUUID[]to actually exercise the binding table.PackageRepository.SavePackageFullAsyncsignature collapses to one UUID — needsGuid[].PackageDetailContentand the package DTO carrypersonaTemplate: LinkedPackagePersonaOverview | null— needs to become an array.- The workbench package binding UI currently picks one template — needs multi-select.
Conversation attachment + modal
- Add
persona_template_idcolumn toweb_conversations(see SQL snippet above). - Wire
personaTemplateIdthroughCreateConversationRequest(both standard and package paths). Validate package-bound templates server-side. - Wire detach via
PATCH /api/chat/conversations/{id}using the existing surgical-update pattern. - Build the conversation-start modal: shown when a package has one or more bound templates. Options are the bound templates plus an "Empty / use only my persona" choice. Submitting the modal calls
POST /api/chat/conversationswith the chosenpersonaTemplateId(or null). - Add a chat-header detach control next to the existing persona-swap UI.
Pipeline injection
- Extend
IWebConversationRepository.GetPersonaForConversationAsyncto return the attached template alongside the persona. - Update
PersonaContentProvider.GetContentAsyncto append the template's prompt to the persona card inside the existingpersonaslot.
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.
- chat. shows a story's role in its persona panel: the role row, the Your role details, and Remove role.
- chat.'s package start shipped 2026-11-17 (
0c53a7ab5): it offers the package's roles plus Just my persona, so the first box under Done when holds in code (not ticked: not driven live here). Choosing a role again mid-story is what remains. - Remove role is one press and final for that story, on both surfaces. Neither offers the role again mid-story,
and the Who drawer says so (
PersonaSection.tsx: "users would need to start a new conversation"). That contradicts this page's own principle, Users attach/detach freely. - The server already allows choosing again.
PUT /api/conversations/{id}takespersonaTemplateIdand authorizes it as the start does (fn_user_can_use_persona_template, and for a protected readerfn_protected_reader_template_allowed). What's missing is the UI and the story's package roles to pick from.
What gets built with chat.'s package start.
- One role picker. The start offers the package's roles plus No role (the writing client's modal, rebuilt on chat.).
- The story uses the same picker in its persona panel. A story from a package offers its roles there: Choose a role when none is attached, and the same picker after Remove role.
- Remove role then needs no confirm in a story from a package: choosing the role again undoes it.
- A story with no package roles to offer keeps a final Remove. That's a story whose package is gone, or no longer offers the attached role. That Remove asks first, in the picker's words.
- One shared definition. The picker and Remove go through the shared persona controls (
usePersonaControls), so the writing client's Who drawer gets choose again the same day.
Done when:
- As a reader starting a package on chat., I pick one of its roles or No role, and the story plays it.
- As a reader in a story from a package, I can remove its role and choose it, or another of the package's roles, again from the persona panel, and the next reply plays the role I chose.
- As a reader in a story with no package roles to offer, I see no role picker. Remove role, when a role is attached, asks first and then removes it.
- A protected reader is offered only the roles the start would allow them (§7.4). A role picked mid-story is authorized exactly as at start.
- The writing client's Who drawer offers the same choose-again, and its "start a new conversation" line goes.
Future Considerations
- Template inheritance — a base template that variants inherit from.
- AI-assisted generation — propose templates from a package description.
- Template previews — show users a sample of how the template shifts the conversation.
- Template analytics — track which templates get picked per package.
- Character-direct templates — today templates only bind to packages; extending to characters would let direct-character starts surface role suggestions too.