feat(persona-chat): practice mode — play the contact

An anchored conversation now has a mode. 'about' is the existing behaviour (a
persona talks with the user about the thread). 'as_contact' has the model play
the contact so the user can rehearse the conversation: its own prompt (stay in
the contact's voice, don't invent facts, coach on 'out of character'), no
persona prompt, and only the thread tools — no memory, library, calendar or
other-thread access, and no knowledge writes.

The shared persona/file-chat loop now refuses tool calls that weren't in the
turn's catalog, so the gates hold even when a model names a tool it wasn't
offered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 committed 2026-10-17 18:39:27 -04:00
1 parent 4ac574d4d2
commit 3f1bf42f1c
8 files changed
+284 -29

No files matched your search

@@ -1,4 +1,5 @@
DROP INDEX IF EXISTS idx_persona_chat_anchor_contact;
ALTER TABLE persona_chat_conversations DROP COLUMN anchor_mode;
ALTER TABLE persona_chat_conversations DROP COLUMN anchor_context;
ALTER TABLE persona_chat_conversations DROP COLUMN anchor_ts;
ALTER TABLE persona_chat_conversations DROP COLUMN anchor_message_id;
@@ -11,6 +11,10 @@
-- prefix byte-stable for KV-cache reuse and keeps the persona's view of the
-- thread fixed even if SMS-API is re-imported underneath it.
--
-- `anchor_mode` is how the chat relates to the thread: 'about' (a persona
-- talks with the user about it) or 'as_contact' (the model plays the
-- contact so the user can practise the conversation). NULL reads as 'about'.
--
-- All nullable: an unanchored (open) persona chat leaves them NULL.
ALTER TABLE persona_chat_conversations ADD COLUMN anchor_contact_id BIGINT;
@@ -18,6 +22,7 @@ ALTER TABLE persona_chat_conversations ADD COLUMN anchor_contact_name TEXT;
ALTER TABLE persona_chat_conversations ADD COLUMN anchor_message_id BIGINT;
ALTER TABLE persona_chat_conversations ADD COLUMN anchor_ts BIGINT;
ALTER TABLE persona_chat_conversations ADD COLUMN anchor_context TEXT;
ALTER TABLE persona_chat_conversations ADD COLUMN anchor_mode TEXT;
CREATE INDEX idx_persona_chat_anchor_contact
ON persona_chat_conversations (user_id, anchor_contact_id, updated_at DESC);