+
    iHàjÌ  ã                  ó†   € R t ^ RIHt ^ RIt^ RIHt ^tRt]P                  ! R4      t	R R lt
R R	 ltR
 R ltR R ltR# )zjLean-mode stale-tail demotion for ContextCompressor: old tail tool results become one-line recovery stubs.)ÚannotationsN)ÚAnyiÜ  uW   \[[^\s\]]* output demoted at compaction â€” [\d,]+ chars preserved in session history\.c               ó    € V ^8„  d   QhRRRR/# )é   ÚcontentÚstrÚreturnÚbool© )Úformats   "ÚB/home/ubuntu/.hermes/hermes-agent/agent/context_compressor_tail.pyÚ__annotate__r      s   € ÷ Pñ P˜Sð P Tñ Pó    c                ó\   € \        V 4      R8  ;'       d    \        P                  V 4      RJ# )ziTrue for a tail tool result already replaced by ``_lean_recovery_stub`` (plus an optional reload marker).iè  N)ÚlenÚ_DEMOTED_STUB_REÚmatch)r   s   &r   Úis_demoted_stubr      s*   € äˆw‹<˜%Ñ×OÐOÔ$4×$:Ñ$:¸7Ó$CÈ4Ð$OÐOr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	tool_namer   Úcontent_lenÚintÚ
session_idr   r
   )r   s   "r   r   r      s(   € ÷ ñ  3ð °Sð Àcð Ècñ r   c                óP   € V'       d   RV R2MRpRT ;'       g    R RVR RV R	2# )
z4One-line replacement for a demoted tail tool result.z4 Recover with session_search(query=..., session_id='z')Ú Ú[Útoolu"    output demoted at compaction â€” Ú,z$ chars preserved in session history.Ú]r
   )r   r   r   Úhints   &&& r   Ú_lean_recovery_stubr       sF   € çT^ÐAÀ*ÀÈRÑPÐdf€Dà
ˆI×Ð˜Ð Ð BÀ;ÈqÀ/ð R.Ø.2¨V°1ð	6ðr   c               ó    € V ^8„  d   QhRRRR/# )r   Úmessagesúlist[dict[str, Any]]r   zdict[str, str]r
   )r   s   "r   r   r   !   s   € ÷ ñ Ð*>ð À>ñ r   c           
     ó�  € ^ RI HpHp / pV  Fµ  pVP                  R4      R8w  d   K  VP                  R4      ;'       g    .  F{  pV! VR/ 4      pV! VR4      R8X  d   V! V! VR4      4      P                  R4      MR	p\	        V\
        4      '       g   KS  V'       g   K]  Ys\        V! VR
4      ;'       g    R4      &   K}  	  K·  	  V# )zAMap each ``skill_view`` tool-call id to the skill name it loaded.)Ú
_json_dictÚ_tc_getÚroleÚ	assistantÚ
tool_callsÚfunctionÚnameÚ
skill_viewÚ	argumentsNÚidr   )Úagent.context_compressorr%   r&   ÚgetÚ
isinstancer   )r"   r%   r&   ÚnamesÚmsgÚtcÚfnÚskills   &       r   Úskill_view_names_by_call_idr7   !   s·   € ç<à€EÛˆØ�7‰7�6‹?˜kÔ)ÙØ—'‘'˜,Ó'×-Ð-¨2Ò-ˆBÙ˜˜Z¨Ó,ˆBÙHOÐPRÐTZÓH[Ð_kÔHk‘J™w r¨;Ó7Ó8×<Ñ<¸VÔDÐquˆEÜ˜%¤×%Ô%¯%©%Ø6;”c™' " dÓ+×1Ð1¨rÓ2Ó3ó	 .ñ ð €Lr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r"   r#   Ú
tail_startr   r   r   r   z tuple[list[dict[str, Any]], int]r
   )r   s   "r   r   r   1   s,   € ÷ $ñ $Ø"ð$Ø03ð$ØADð$à%ñ$r   c                óØ  a € ^ RI HpHpHpHpHp ^ p\        4       p	Rp
V 3R l\        \        S 4      ^,
          V^,
          R4       4        F@  pYŠRJ ;'       g    W«,
          ^8„  ,          pTp
V\        8”  d    MV	P                  V4       KB  	  \        S 4      p^ pRp\        V\        S 4      4       EF0  pS V,          pVP                  R4      pVP                  R4      R8w  g   W¹9   g   \        V\        4      '       g   KR  \        V4      \        8  g   VV9   g   V! V4      '       d   K}  \!        VP                  R4      ;'       g    R\        V4      V4      pVf   \#        S 4      MTpTP                  \        VP                  R	4      ;'       g    R4      4      ;p'       d%   V! V4      '       g   VR
V! V4      ,           ,          pV! VV4      WË&   V^,          pEK3  	  WÍ3# )a‚  Demote tail tool results older than the newest ``_LEAN_TAIL_KEEP_TOOL_ROUNDS`` rounds to recovery stubs;
skill-marker rows untouched. A demoted ``skill_view`` body carries the canonical reload marker, as its
Phase-1 stub does, so the model does not act on instructions it no longer has (#32106). Returns a new list
(untouched rows shared, demoted copied) and the number of rows demoted.)ÚSKILL_PRUNED_MARKER_PREFIXÚ_is_summary_stubÚ_result_failure_suffixÚ
_rewrittenÚ_skill_pruned_markerNc              3  óf   <"  € T F&  pSV,          P                  R 4      R8X  g   K"  Vx € K(  	  R# 5i)r'   r   N)r0   )Ú.0Úir"   s   & €r   Ú	<genexpr>Ú*demote_stale_tail_tools.<locals>.<genexpr>?   s,   øé € ÐkÑE�AÈÐRSÍÏÉÐY_ÓI`ÐdjÑIj�aŠaÓEùs   ƒ1§
1r   r'   r   r   r   Útool_call_idÚ éÿÿÿÿ)r/   r;   r<   r=   r>   r?   ÚsetÚranger   Ú_LEAN_TAIL_KEEP_TOOL_ROUNDSÚaddÚlistr0   r1   r   Ú_LEAN_TAIL_DEMOTE_MIN_CHARSr    r7   )r"   r9   r   r;   r<   r=   r>   r?   Úrounds_seenÚ	protectedÚprev_idxrB   ÚresultÚdemotedÚskillsr3   r   Ústubr6   s   f&&                r   Údemote_stale_tail_toolsrU   1   s©  ø€ ÷õ ð €KÜ›%€IØ€HÜkœœs 8›}¨qÕ0°*¸qµ.À"ÔEÖkˆØ 4Ð'×;Ð;¨8­<¸!Ñ+;Õ;ˆØˆØÔ4Ô4ÙØ�‰�aÖñ lô �(‹^€FØ€GØ$(€FÜ�:œs 8›}×-ˆØ�q�kˆØ—'‘'˜)Ó$ˆØ�7‰7�6‹?˜fÔ$¨¬¼jÈÔRU×>VÒ>VÙÜˆw‹<Ô5Ô5Ð9SÐW^Ô9^ÑbrÐsz×b{Òb{ÙÜ" 3§7¡7¨;Ó#7×#=Ð#=¸2¼sÀ7»|ÈZÓXˆØ:@º.Ô,¨XÔ6ÈfˆØ—Z‘Z¤ C§G¡G¨NÓ$;×$AÐ$A¸rÓ BÓCÐCˆEÖCÑMcÐdk×MlÒMlØ�CÑ.¨uÓ5Õ5Õ5ˆDÙ˜s DÓ)ˆ‰	Ø�1�‹ñ .ð ˆ?Ðr   )Ú__doc__Ú
__future__r   ÚreÚtypingr   rJ   rM   Úcompiler   r   r    r7   rU   r
   r   r   Ú<module>r[      sF   ðÙ på "ã 	Ý ð  Ð Ø#Ð ð
 —:’:ÐxÓyÐ õPõ
õ÷ $r   