
    $j@                     
   d Z ddlmZmZ ddlmZmZ  G d de          Z G d de          Z G d d	e          Z	 G d
 de          Z
 G d de          Z G d de          Z G d de          Z G d de          ZdS )z(
Pydantic models for the reflect agent.
    )AnyLiteral)	BaseModelFieldc                       e Zd ZU dZ ed          Zeed<    ed          Zeed<    ee	d          Z
e	e         ed	<   d
S )ObservationSectionz=A section within an observation with its supporting memories.z'Section header (can be empty for intro)descriptiontitlez3Section content - no headers, use lists/tables/boldtextz"Memory IDs supporting this sectiondefault_factoryr
   
memory_idsN)__name__
__module____qualname____doc__r   r   str__annotations__r   listr        k/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/hindsight_api/engine/reflect/models.pyr   r   
   sx         GG#LMMME3MMM"WXXXD#XXX!E$DhiiiJS	iiiiir   r   c                   &   e Zd ZU dZ ed          Zed         ed<    edd          Ze	dz  ed	<    edd
          Z
e	dz  ed<    edd          Zedz  ed<    edd          Zee	         dz  ed<    edd          Zed         dz  ed<    edd          Zee         dz  ed<    edd          Ze	dz  ed<    eddd          Zee	         dz  ed<    eddd          Zee	         dz  ed<    edd          Ze	dz  ed<   dS )ReflectActionz)Single action the reflect agent can take.zKTool to invoke: list_observations, get_observation, recall, expand, or doner	   )list_observationsget_observationrecallexpanddonetoolNz"Observation ID for get_observationdefaultr
   observation_idzSearch query for recallqueryz,Max tokens for recall results (default 2048)
max_tokensz$Memory unit IDs for expand (batched)r   zExpansion depth for expand)chunkdocumentdepthzDObservation sections for done action (when output_mode=observations)observation_sectionsz.Well-formatted markdown answer for done actionanswerz Memory IDs supporting the answer)r#   r
   aliasanswer_memory_idsz&Mental model IDs supporting the answer	model_idsanswer_model_idszBrief reasoning for this action	reasoning)r   r   r   r   r   r!   r   r   r$   r   r%   r&   intr   r   r)   r*   r   r+   r-   r/   r0   r   r   r   r   r      s        33X]X]aY Y YD'T
U    "'tAe!f!f!fNC$Jfffd8QRRRE3:RRR"U4=klllJd
lll#(5Ci#j#j#jJS	D jjj16tQm1n1n1nE7&'$.nnn<AE"h= = =$12T9    t9ijjjFC$Jjjj*/%"DL+ + +tCy4'    */"JR]* * *d3i$&    "E$<]^^^IsTz^^^^^r   r   c                   B    e Zd ZU dZ ed          Zee         ed<   dS )ReflectActionBatchz(Batch of actions for parallel execution.z&List of actions to execute in parallelr	   actionsN)	r   r   r   r   r   r4   r   r   r   r   r   r   r3   r3   ,   s;         22#(55]#^#^#^GT- ^^^^^r   r3   c                       e Zd ZU dZ ed          Zeed<    edd          Zedz  ed<    ed	          Z	e
ed
<    ed          Ze
ed<    ed          Zeed<    edd          Zeed<   dS )ToolCallz'A single tool call made during reflect.z!Tool name: lookup, recall, expandr	   r!   Nz+Agent's reasoning for making this tool callr"   reasonzTool input parametersinputzTool output/resultoutputExecution time in millisecondsduration_msr   z4Iteration number (1-based) when this tool was called	iteration)r   r   r   r   r   r!   r   r   r7   r8   dictr9   r;   r1   r<   r   r   r   r6   r6   2   s         11"EFFFD#FFFt9fgggFC$Jggg%$;<<<E4<<<5%9:::FD:::u)IJJJKJJJU12hiiiIsiiiiir   r6   c                       e Zd ZU dZ ed          Zeed<    ed          Ze	ed<    edd	          Z
e	ed
<    edd	          Ze	ed<   dS )LLMCallz&A single LLM call made during reflect.z)Call scope: agent_1, agent_2, final, etc.r	   scoper:   r;   r   zInput tokens usedr"   input_tokenszOutput tokens usedoutput_tokensN)r   r   r   r   r   r@   r   r   r;   r1   rA   rB   r   r   r   r?   r?   =   s         00#NOOOE3OOOu)IJJJKJJJa5HIIIL#IIIq6JKKKM3KKKKKr   r?   c                   z    e Zd ZU dZ ed          Zeed<    ed          Zeed<    ed          Z	eed<   d	S )
DirectiveInfoz>Information about a directive that was applied during reflect.zDirective mental model IDr	   idzDirective namenamezDirective contentcontentN)
r   r   r   r   r   rE   r   r   rF   rG   r   r   r   rD   rD   F   sr         HHe ;<<<B<<<"2333D#3335%8999GS99999r   rD   c                       e Zd ZU dZ edd          Zeed<    edd          Zeed<    edd          Z	eed	<   d
S )TokenUsageSummaryz'Total token usage across all LLM calls.r   zTotal input tokens usedr"   rA   zTotal output tokens usedrB   zTotal tokens (input + output)total_tokensN)
r   r   r   r   r   rA   r1   r   rB   rJ   r   r   r   rI   rI   N   sx         11a5NOOOL#OOOq6PQQQM3QQQa5TUUUL#UUUUUr   rI   c                      e Zd ZU dZ ed          Zeed<    edd          Ze	ee
f         dz  ed<    ed	d
          Zeed<    ed	d          Zeed<    eed          Zee         ed<    eed          Zee         ed<    eed          Zeed<    eed          Zee         ed<    eed          Zee         ed<    eed          Zee         ed<    eed          Zee         ed<   dS )ReflectAgentResultzResult from the reflect agent.zFinal answer textr	   r   Nz>Structured output parsed according to provided response_schemar"   structured_outputr   zNumber of iterations taken
iterationszTotal number of tool calls madetools_calledzTrace of all tool calls mader   
tool_tracezTrace of all LLM calls made	llm_tracez&Total token usage across all LLM callsusagez,Validated memory IDs actually used in answerused_memory_idsz2Validated mental model IDs actually used in answerused_mental_model_idsz1Validated observation IDs actually used in answerused_observation_idsz5Directive mental models that affected this reflectiondirectives_applied)r   r   r   r   r   r   r   r   rM   r=   r   rN   r1   rO   r   rP   r6   rQ   r?   rI   rR   rS   rT   rU   rV   rD   r   r   r   rL   rL   V   s        (("5666D#666/4u"b0 0 0tCH~,    eA3OPPPJPPPa5VWWWL#WWW!&tIg!h!h!hJXhhh$uTGdeeeItG}eee$u)7_     E    "'tIw!x!x!xOT#Yxxx',u*^( ( (49    ',e*]' ' '$s)    /4e*a/ / /]+     r   rL   N)r   typingr   r   pydanticr   r   r   r   r3   r6   r?   rD   rI   rL   r   r   r   <module>rY      s             % % % % % % % %j j j j j j j j_ _ _ _ _I _ _ _4_ _ _ _ _ _ _ _j j j j jy j j jL L L L Li L L L: : : : :I : : :V V V V V	 V V V         r   