+
    iHàj  ã                  ó˜   € R t ^ RIHt ^ RIt^ RIHtHt ]'       d   ^ RIHt Rt	Rt
RR R lltR	 R
 lt]P                  R R l4       tR# )ar  Compression time limits: the configured idle and total limits, and the fence deadline shared live
with the summary stream (sibling of ``conversation_compression``).

Compression waits a total time limit for its summary. That limit stops a summary that trickles
out a token at a time; on a laptop GPU, reading a 150K-token conversation alone can take longer
than the whole limit. Time llama-server spends reading the prompt therefore pushes the fence
deadline back (``CompressionCommitFence.extend_deadline``), and hosts read the deadline from the
fence instead of adding the configured limit to the time they started waiting.
)ÚannotationsN)ÚTYPE_CHECKINGÚOptional)ÚCompressionCommitFenceg      ^@g     À‚@c               ó    € V ^8„  d   QhRRRR/# )é   Úcompression_cfgzOptional[dict]Úreturnztuple[float, float]© )Úformats   "ÚL/home/ubuntu/.hermes/hermes-agent/agent/conversation_compression_deadline.pyÚ__annotate__r      s   € ÷ !ñ !¸.ð !ÐTgñ !ó    c                óì  € \         p\        pT pVf   / p\        P                  ! \        4      ;_uu_ 4        ^ RIHp V! 4       p\        V\        4      '       d   VP                  R/ 4      M/ p\        V\        4      '       d   TM/ pRRR4       \        V\        4      '       dÂ   \        P                  ! \        \        4      ;_uu_ 4        VP                  R4      e   \        VR,          4      pRRR4       \        P                  ! \        \        4      ;_uu_ 4        VP                  R4      e*   \        VR,          4      ^ 8”  d   \        VR,          4      pRRR4       V^ 8”  dK   \        W!4      p^ RIHp \        V! RR4      4      pV^ 8”  d!   \        W(4      p\        V\!        W‚4      4      pW3#   + '       g   i     EL<; i  + '       g   i     Lä; i  + '       g   i     L‹; i)zÑReturn ``(idle_timeout_seconds, total_ceiling_seconds)``.
``idle_timeout_seconds <= 0`` disables the progress-aware wrapper. The ceiling is clamped to at least one
idle window when the idle budget is positive.N)Úload_configÚcompressionÚcontext_timeout_secondsÚcontext_total_ceiling_seconds)Ú_effective_aux_timeout)ÚDEFAULT_CONTEXT_TIMEOUT_SECONDSÚ%DEFAULT_CONTEXT_TOTAL_CEILING_SECONDSÚ
contextlibÚsuppressÚ	ExceptionÚhermes_cli.configr   Ú
isinstanceÚdictÚgetÚ	TypeErrorÚ
ValueErrorÚfloatÚmaxÚagent.auxiliary_clientr   Úmin)	r   ÚidleÚceilingÚcfgr   ÚrawÚmayber   Ú_aux_budgets	   &        r   Ú$resolve_context_compression_timeoutsr*      su  € ô +€DÜ3€GØ
€CØ
‚{ØˆÜ× Ò ¤×+Õ+Ý5Ù“-ˆCÜ2<¸SÄ$×2GÒ2G�C—G‘G˜M¨2Ô.ÈRˆEÜ% e¬T×2Ò2‘%¸ˆC÷	 ,ô
 �#”t×Òä× Ò ¤¬J×7Õ7Ø�w‰wÐ0Ó1Ò=Ü˜SÐ!:Õ;Ó<�÷ 8ô × Ò ¤¬J×7Õ7Ø�w‰wÐ6Ó7ÒCÌÈcÐRqÕNrÓHsÐvwÔHwÜ Ð$CÕ DÓE�÷ 8ð ˆa„xÜ�gÓ$ˆõ
 	BÜÑ2°=À$ÓGÓHˆØ˜Œ?Ü˜'Ó/ˆGÜ�tœS Ó6Ó7ˆDØˆ=Ð÷1 ,×+Ð+ú÷ 8×7ú÷ 8×7ús$   ·AF<Ã&GÄ#=G#Æ<G	ÇG 	Ç#G3	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úfencer   r%   r    Úwait_startedr	   r
   )r   s   "r   r   r   <   s1   € ÷ Rñ RÐ3ð R¸eð RÐSXð RÐ]bñ Rr   c                óJ   € V P                   pVf   V# \        WV,
          4      # )zšThe total limit for a host that started waiting at *wait_started*: the configured
*ceiling*, or longer once prompt reading pushed the fence deadline back.)Údeadline_monotonicr!   )r,   r%   r-   Údeadlines   &&& r   Úeffective_ceilingr1   <   s)   € ð ×'Ñ'€HØÒ&ˆ7ÐQ¬C°ÀLÕ9PÓ,QÐQr   c               ó   € V ^8„  d   QhRR/# )r   r,   z Optional[CompressionCommitFence]r
   )r   s   "r   r   r   D   s   € ÷ ñ Ð&Fñ r   c           	   #  ó  a "  € ^ RI Hp ^ RIHp S f   Rx € R# V! V 3R l4      ;_uu_ 4        V! S P                  4      ;_uu_ 4        Rx € RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i5i)záShare *fence*'s deadline with the summary stream, live, and push it back while the
server reads the prompt. A stream checks the deadline as it reads, so a later summary
call in the same attempt sees the extended deadline too.)Úaux_stream_deadline)Úprompt_reading_hookNc                 ó   <€ S P                   # ©N)r/   )r,   s   €r   Ú<lambda>Ú,compression_deadline_scope.<locals>.<lambda>N   s   ø€  U×%=Ò%=r   )r"   r4   Úagent.local_prompt_progressr5   Úextend_deadline)r,   r4   r5   s   f  r   Úcompression_deadline_scoper<   C   sW   øé € õ
 ;Ý?à‚}ÛÙÙ	Ô=×	>Õ	>Ñ@SÐTY×TiÑTi×@jÕ@jÛ÷ Ak×	>Ñ	>×@j×@jú×	>×	>Ð	>üs4   ƒ+B®A3Á	A 	ÁA3Á
BÁ A0Á+A3Á3B	Á>	Br7   )Ú__doc__Ú
__future__r   r   Útypingr   r   Úagent.conversation_compressionr   r   r   r*   r1   Úcontextmanagerr<   r
   r   r   Ú<module>rB      sO   ðñõ #ã ß *çÝEð #(Ð Ø(-Ð %÷!õHRð ×Ñôó òr   