fix(persona-chat): review fixes before merge

- Thread tools are bound server-side to the chat's own thread. The model
  used to pass contact_id, so practice mode could read any conversation it
  named; a model-supplied contact_id is now only checked, never trusted, and
  the prompts no longer hand it one.
- Practice chats need no persona. They're stored under PRACTICE_PERSONA_ID
  and run with an inert stand-in, so deleting or editing personas can't hide
  or break them. persona_id is optional on create for as_contact.
- The per-thread list filters in SQL (list_persona_chats_for_contact, served
  by idx_persona_chat_anchor_contact) instead of decoding every transcript.
- fetch_mms_image checks the content type and a 20 MB cap before reading
  the body, so a video attachment isn't downloaded in full.
- get_photos_near_time unions tags over every path sharing the content, per
  the multi-library model.
- look_at_photo only opens indexed photos, so an excluded folder can't be
  read by guessing a path.
- One date parser: get_photos_near_time uses date_info::parse_center.
- Practice prompt source rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 committed 2026-10-20 19:38:08 -04:00
1 parent 185a1b561a
commit e029c81274
8 files changed
+383 -116

No files matched your search

+5
View File
@@ -473,6 +473,7 @@ impl InsightChatService {
&normalized,
req.user_id,
&active_persona,
None,
)
.instrument(loop_span.clone())
.await;
@@ -1435,6 +1436,7 @@ impl InsightChatService {
normalized,
user_id,
active_persona,
None,
max_iterations,
entry,
fitter,
@@ -1990,6 +1992,7 @@ impl InsightChatService {
normalized,
user_id,
active_persona,
None,
)
.await;
let (result_preview, result_truncated) = truncate_tool_result(&result);
@@ -2624,6 +2627,7 @@ pub async fn run_streaming_agentic_loop_with_entry(
normalized: &str,
user_id: i32,
active_persona: &str,
thread_contact: Option<i64>,
max_iterations: usize,
entry: &Arc<TurnEntry>,
fitter: &mut ContextFitter,
@@ -2720,6 +2724,7 @@ pub async fn run_streaming_agentic_loop_with_entry(
normalized,
user_id,
active_persona,
thread_contact,
)
.await
} else {