From 0859f77ff04d94811f2ec7c3f5b65d00a17d6ae2 Mon Sep 17 00:00:00 2001 From: adavyas Date: Fri, 12 Jun 2026 14:08:19 -0400 Subject: [PATCH] Optimize deriver prompt prefix caching --- src/deriver/prompts.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/deriver/prompts.py b/src/deriver/prompts.py index 683834bf..c10b7d84 100644 --- a/src/deriver/prompts.py +++ b/src/deriver/prompts.py @@ -31,6 +31,7 @@ def _custom_instructions_section(custom_instructions: str | None) -> str: return c( f""" CUSTOM INSTRUCTIONS: + These instructions apply to the target peer. {normalized_custom_instructions} """ ) @@ -54,26 +55,29 @@ def minimal_deriver_prompt( custom_instructions_section = _custom_instructions_section(custom_instructions) return c( f""" -Analyze messages from {peer_id} to extract **explicit atomic facts** about them. +Analyze messages to extract **explicit atomic facts** about the target peer. -[EXPLICIT] DEFINITION: Facts about {peer_id} that can be derived directly from their messages. +[EXPLICIT] DEFINITION: Facts about the target peer that can be derived directly from their messages. - Transform statements into one or multiple conclusions - Each conclusion must be self-contained with enough context - Use absolute dates/times when possible (e.g. "June 26, 2025" not "yesterday") RULES: -- Properly attribute observations to the correct subject: if it is about {peer_id}, say so. If {peer_id} is referencing someone or something else, make that clear. -- Observations should make sense on their own. Each observation will be used in the future to better understand {peer_id}. -- Extract ALL observations from {peer_id} messages, using others as context. +- Properly attribute observations to the correct subject: if it is about the target peer, say so. If the target peer is referencing someone or something else, make that clear. +- Observations should make sense on their own. Each observation will be used in the future to better understand the target peer. +- Extract ALL observations from the target peer's messages, using others as context. - Contextualize each observation sufficiently (e.g. "Ann is nervous about the job interview at the pharmacy" not just "Ann is nervous") EXAMPLES: -- EXPLICIT: "I just had my 25th birthday last Saturday" → "{peer_id} is 25 years old", "{peer_id}'s birthday is June 21st" -- EXPLICIT: "I took my dog for a walk in NYC" → "{peer_id} has a dog", "{peer_id} lives in NYC" -- EXPLICIT: "{peer_id} attended college" + general knowledge → "{peer_id} completed high school or equivalent" +- EXPLICIT: "I just had my 25th birthday last Saturday" → "The target peer is 25 years old", "The target peer's birthday is June 21st" +- EXPLICIT: "I took my dog for a walk in NYC" → "The target peer has a dog", "The target peer lives in NYC" +- EXPLICIT: "The target peer attended college" + general knowledge → "The target peer completed high school or equivalent" {custom_instructions_section} +Target peer: +{peer_id} + Messages to analyze: {messages}