
    yj              	           d Z ddlmZ ddlmZ ddlmZ dedz  dedz  fdZ	dedz  defd	Z
	 dd
edededz  defdZedefd            Zdedz  defdZdS )z
Minimal prompts for the deriver module optimized for speed.

This module contains simplified prompt templates focused only on observation extraction.
NO peer card instructions, NO working representation - just extract observations.
    )cache)cleandoc)estimate_tokenscustom_instructionsNreturnc                 :    | dS |                                  }|pdS )z,Return stripped custom instructions, if any.N)strip)r   
normalizeds     ;/DATA/AppData/hermes/projects/honcho/src/deriver/prompts.py_normalized_custom_instructionsr      s)    "t$**,,J    c                 N    t          |           }|dS t          d| d          S )z;Render optional custom instructions for the deriver prompt.N z&
        CUSTOM INSTRUCTIONS:
        z	
        )r   c)r   normalized_custom_instructionss     r   _custom_instructions_sectionr      sK    %D& &" &-r		'	 	 	  r   peer_idmessagesc                     t          |          }t          d|  d|  d|  d|  d|  d|  d|  d|  d	|  d
|  d|  d|  d| d| d          S )a'  
    Generate minimal prompt for fast observation extraction.

    Args:
        peer_id: The ID of the user being analyzed.
        messages: All messages in the range (interleaving messages and new turns combined).

    Returns:
        Formatted prompt string for observation extraction.
    z
Analyze messages from zV to extract **explicit atomic facts** about them.

[EXPLICIT] DEFINITION: Facts about aR   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 z, say so. If z 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 z".
- Extract ALL observations from u    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" → "z is 25 years old", "uM   's birthday is June 21st"
- EXPLICIT: "I took my dog for a walk in NYC" → "z has a dog", "z lives in NYC"
- EXPLICIT: "u,    attended college" + general knowledge → "z' completed high school or equivalent"

z"

Messages to analyze:
<messages>
z
</messages>
)r   r   )r   r   r   custom_instructions_sections       r   minimal_deriver_promptr   '   s    #??R"S"S		 	 %,	 	 KR	 	 ah	 	 ry	 	 ")	 	 ?F	 	 \c	 	  5<!	 	  LS!	 	" #	 	" DK#	 	& '	 	. 
/	 	 	  r   c                  D    t          ddd          } t          |           S )zGEstimate the static minimal deriver prompt without custom instructions.r   Nr   r   r   )r   r   )prompts    r   &estimate_minimal_deriver_prompt_tokensr   U   s1     $   F
 6"""r   c                     t          |           }|t                      S t          dd|          }t          |          S )zQEstimate minimal deriver prompt tokens, including custom instructions if present.Nr   r   )r   r   r   r   )r   r   r   s      r   estimate_deriver_prompt_tokensr   `   sV    %D& &" &-5777#:  F
 6"""r   )N)__doc__	functoolsr   inspectr   r   src.utils.tokensr   strr   r   r   intr   r    r   r   <module>r%      s5          ! ! ! ! ! ! , , , , , ,t d
    cDj S    & '++ +++ t+ 		+ + + +\ # # # # ##d
 #s # # # # # #r   