+
    iHàj½^  ã                  óP  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
Ht ^ RIHt ^ RIHtHtHtHt ]P&                  ! R4      t] ! R R	4      4       tR
 R ltR R ltR$R R lltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R lt R  R! lt!R" R# lt"R# )%aG  Turn-start compaction for ``build_turn_context`` plus the small compression-attempt
helpers shared with the pre-API / post-tool sites in ``turn_preflight``.

Three passes, in order: idle-triggered compaction (opt-in, wall-clock gap), preflight
context compression (token threshold), and the uncompressed-session overflow-warning
re-arm. ``run_turn_start_compaction`` mutates ``agent`` exactly as the inline prologue
did and returns a ``CompactionOutcome``. Predicates/estimators that tests patch on
``agent.turn_context`` are imported lazily through that module so patches intercept.)ÚannotationsN)Ú	dataclass)ÚAnyÚDictÚListÚOptional)Ú#automatic_compaction_status_message)ÚIDLE_COMPACTION_STATUS_TEMPLATEÚ%PREFLIGHT_COMPRESSION_STATUS_TEMPLATEÚcompression_skipped_due_to_lockÚ&conversation_history_after_compressionzagent.turn_contextc                  ó`   € ] tR t^t$ RtR]R&   R]R&   R]R&   R]R	&   R
tR]R&   R
tR]R&   RtR# )ÚCompactionOutcomezQLocals rebuilt by turn-start compaction (``build_turn_context`` reads them back).úlist[dict[str, Any]]ÚmessagesúOptional[str]Úactive_system_promptúOptional[list[dict[str, Any]]]Úconversation_historyÚintÚcurrent_turn_user_idxFÚboolÚ
compressedÚblocked© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   r   Ú__static_attributes__r   ó    ÚB/home/ubuntu/.hermes/hermes-agent/agent/turn_context_compaction.pyr   r      s1   ‡ á[à"Ó"Ø'Ó'Ø8Ó8ØÓà€J�Óà€GˆT×r"   r   c               ó    € V ^8„  d   QhRRRR/# ©é   Úagentr   ÚreturnÚNoner   )Úformats   "r#   Ú__annotate__r+   +   s   € ÷ ñ  ð ¨ñ r"   c                óT   € \        V RR4      p\        V4      '       d
   V! 4        R# R# )zMRe-arm the context-overflow warning dedup (test doubles may lack the method).Ú_clear_context_overflow_warnN)ÚgetattrÚcallable)r'   Ú_clear_warns   & r#   Ú_clear_overflow_warnr1   +   s(   € ô ˜%Ð!?ÀÓF€KÜ�×ÒÙŽñ r"   c               ó    € V ^8„  d   QhRRRR/# r%   r   )r*   s   "r#   r+   r+   :   s   € ÷ &ñ &¨sð &°tñ &r"   c                óL   € ^ V n         ^ V n        RV n        RV n        RV n        R# )zLGive the compacted request a fresh chance: clear retry/empty-response state.NF)Ú_empty_content_retriesÚ_thinking_prefill_retriesÚ_last_content_with_toolsÚ$_last_content_tools_all_housekeepingÚ_mute_post_response©r'   s   &r#   Ú#_reset_retry_state_after_compactionr:   :   s*   € à#$€EÔ Ø&'€EÔ#Ø%)€EÔ"Ø16€EÔ.Ø %€EÖr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r&   Ú
compressorr   Útokensr   Úattempts_spentzOptional[int]r(   r   r   )r*   s   "r#   r+   r+   C   s,   € ÷ ñ ØðØ ðØ2?ðàñr"   c                ó²   € \        V RR4      p\        V4      '       g   R#  V! V4      w  rETe   T'       d   T'       g   RT 2# T#   \         d     R# i ; i)uš  Why an over-threshold request is blocked (``None`` below threshold or when the
engine lacks ``should_compress_info`` / raises).

``attempts_spent``: when given and the engine says compression SHOULD run
(``(True, None)``) yet the caller skipped it, the per-turn attempt budget is
spent â€” name it ``attempts_exhausted:<n>`` instead of dropping the
``(True, None)`` on the floor (silent-lockout case, #101889).Úshould_compress_infoNzattempts_exhausted:)r.   r/   Ú	Exception)r<   r=   r>   Ú_infoÚ_should_nowÚ_reasons   &&&   r#   Ú_blocked_compress_reasonrE   C   sc   € ô �JÐ 6¸Ó=€EÜ�E�?Š?ÙðÙ$ V›}Ñˆð Ò!§k¿'Ø$ ^Ð$4Ð5Ð5Ø€Nøô	 ô Úðús   ¢
A ÁAÁAc               ó(   € V ^8„  d   QhRRRRRRRR/# )r&   r'   r   r<   Úgrownr   r(   r)   r   )r*   s   "r#   r+   r+   Y   s(   € ÷ ñ ˜sð °ð ¸Cð ÀDñ r"   c                ó(  € TP                  V P                  T\        V RR4      ;'       g    R\        V RR4      ;'       g    R\        V RR4      ;'       g    R\        V RR4      ;'       g    RR7       V P                  RVR,           R	24       R
# )zLA managed local runtime granted a bigger window: recalibrate the compressor.Úbase_urlÚ Úapi_keyÚproviderÚapi_mode)rI   rK   rL   rM   u   ðŸ“ˆ Context window grown to i   z4K (local model; conversation continues uncompressed)N)Úupdate_modelÚmodelr.   Ú_buffer_status)r'   r<   rG   s   &&&r#   Ú_apply_grown_windowrQ   Y   s’   € à×ÑØ�‰�U¤W¨U°JÀÓ%C×%IÐ%IÀrÜ˜˜y¨"Ó-×3Ð3°Ü˜ 
¨BÓ/×5Ð5°2Ü˜ 
¨BÓ/×5Ð5°2ð	 ô ð 
×ÑØ
'¨°­ ð 7=ð 	>ör"   c               ó$   € V ^8„  d   QhRRRRRR/# )r&   r'   r   Úapi_call_countr   r(   r   )r*   s   "r#   r+   r+   g   s!   € ÷ 
ñ 
˜Cð 
°ð 
¸ñ 
r"   c                óX   € V^,          pWn         V P                  P                  4        V# )z¤Refund the call count and iteration budget for a pass that should not consume it:
one that never reached the provider (preflight) or a provider-switch fallback hop.)Ú_api_call_countÚiteration_budgetÚrefund)r'   rS   s   &&r#   Ú_refund_api_callrX   g   s,   € ð �aÕ€NØ*ÔØ	×Ñ×!Ñ!Ô#ØÐr"   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r&   r'   r   r   ú	list[Any]Úuser_messager(   r   r   )r*   s   "r#   r+   r+   t   s(   € ÷ ñ �Sð  Ið ¸Sð ÀSñ r"   c                ó.   € ^ RI Hp V! W4      pW@n        V# )z–Compaction rebuilt ``messages``: re-anchor this turn's user index so the
api_content stamp, injection site and persist-override row hit the same dict.)Úreanchor_current_turn_user_idx)Úagent.turn_contextr]   Ú_persist_user_message_idx)r'   r   r[   r]   Úidxs   &&&  r#   Ú	_reanchorra   t   s   € õ Bá
(¨Ó
@€CØ&)Ô#Ø€Jr"   c               ó<   € V ^8„  d   QhRRRRRRRRRR	R
RRRRRRR/	# )r&   r'   r   r   r   Úsystem_messager   r   r   r   r   r   r[   Úeffective_task_idÚstrr(   r   r   )r*   s   "r#   r+   r+   �   s^   € ÷ ñ ØðØ1ðØCPðà'ðà?]ðð ðð /2ðð GJðð ñ	r"   c               óT   € \        WWER7      p\        WW&V4       \        WW&V4       V# )zHIdle compaction, then preflight compression (or the uncompressed guard).)r   r   r   r   )r   Ú_idle_compactionÚ_preflight_compression)	r'   r   rc   r   r   r   r[   rd   Úouts	   &$$$$$$$ r#   Úrun_turn_start_compactionrj   �   s5   € ô ØØ1ô€Cô �U Ð?PÔQÜ˜5 ~ÐEVÔWØ€Jr"   c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# ©r&   r'   r   ri   r   rc   r   r[   rd   re   r(   r)   r   )r*   s   "r#   r+   r+   �   sN   € ÷ FQñ FQØðFQØ&ðFQØ8EðFQØUXðFQàðFQð 
ñFQr"   c           
     ó$  € ^ RI Hp VP                  p\        V R^ 4      pV P                  '       d   V^ 8”  d	   V'       g   R# \
        P
                  ! 4       \        V R\
        P
                  ! 4       4      ,
          pW‡8  d   R# V P                  p	\        \        V	RR4      4      '       d   R# TP                  YVP                  ;'       g    R4      p
\        V	P                  V	P                  ,          4      p\        V	RR	 4      ! 4       p\        V	R
^ 4      p\        V\        4      '       d   \        V\        4      '       d   ^ pVP                  V P                  VWŠV\        V4      VR7      '       g   R# \        P!                  R\        V4      YzR VR V^ 8”  d   VR MRV P"                  ;'       g    R4       \%        V	R\&        P(                  ! \        V4      V
R7      V
\        V4      V P*                  R7      pV'       d   V P-                  V4       V P/                  WbW¤RR7      w  Vn        Vn	        VP                  VJdC   \1        WP                  VP2                  4      Vn        \5        WP                  V4      Vn        R# R# )z¢Idle-triggered compaction (opt-in; ``idle_compact_after_seconds``): fires on the
wall-clock gap since ``_last_activity_ts``; a cheap gap check gates the estimate.©Úturn_contextÚ&compression_idle_compact_after_secondsNÚ_last_activity_tsÚ%awaiting_real_usage_after_compressionFrJ   Ú'get_active_compression_failure_cooldownc                 ó   € R # ©Nr   r   r"   r#   Ú<lambda>Ú"_idle_compaction.<locals>.<lambda>­   ó   € Ér"   Úlast_compression_rough_tokens)ÚenabledÚidle_after_secondsÚidle_gap_secondsr=   Úfloor_tokensÚcooldown_activeÚlast_compaction_tokenszcIdle compaction: %ss idle >= %ss, ~%s tokens > %s floor (last compaction produced ~%s) (session %s)Ú,zn/aÚnoneÚidle)Úidle_secondsr=   )ÚphaseÚdefault_messageÚapprox_tokensrƒ   rO   ©r†   Útask_idÚtrigger)r'   ro   r   r.   Úcompression_enabledÚtimeÚcontext_compressorr   Ú_preflight_request_tokensr   r   Úthreshold_tokensÚsummary_target_ratioÚ
isinstanceÚ_should_idle_compactÚloggerÚinfoÚ
session_idr   r	   r*   rO   Ú_emit_statusÚ_compress_contextr   r   ra   r   )r'   ri   rc   r[   rd   Ú_tcr   Ú_idle_afterÚ	_idle_gapÚ_compressorÚ_idle_tokensÚ_idle_floorÚ_idle_cooldownÚ_idle_last_compactionÚ_idle_statuss   &&&&&          r#   rg   rg   �   sK  € õ *à�|‰|€HÜ˜%Ð!IÈ1ÓM€KØ×%×%Ð%¨+¸¬/¿hÙÜ—	’	“œg eÐ-@Ä$Ç)Â)Ã+ÓNÕN€IØÔÙØ×*Ñ*€Kô ŒG�KÐ!HÈ%ÓP×QÒQÙð ×0Ñ0Ø˜×1Ñ1×7Ð7°Ró€Lô �k×2Ñ2°[×5UÑ5UÕUÓV€KÜØÐ>Áôó €Nô $ KÐ1PÐRSÓTÐÜÐ+¬S×1Ò1´ZÐ@UÔW[×5\Ò5\Ø !ÐØ×#Ñ#Ø×)Ñ)¸kØ"ÀkÜ˜^Ó,ÐEZð $÷ ò ñ
 	Ü
‡K�KØmÜˆI‹˜°QÐ'7¸[È¸OØ(=ÀÔ(AÐ  Ñ
#ÀuØ×Ñ×"Ð"˜Fô	ô 7ØØÜ7×>Ò>Ü˜Y›°ô
ð #Ü˜“^Ø�k‰kô	€L÷ Ø×Ñ˜<Ô(Ø-2×-DÑ-DØ°Ðagð .Eó .Ñ*€C„L�#Ô*ð
 ‡|�|˜8Ó#Ü#IØ—<‘< ×!9Ñ!9ó$
ˆÔ ô %.¨e·\±\À<Ó$PˆÖ!ñ	 $r"   c               ó    € V ^8„  d   QhRRRR/# )r&   r'   r   r(   r   r   )r*   s   "r#   r+   r+   Ù   s   € ÷ 
ñ 
¨ð 
°ñ 
r"   c                ó”   € \        V RR4      R8H  ;'       d2    \        \        V RR4      ;'       g    R4      P                  4       R9   # )ztCodex app-server threads are compacted by the codex agent itself; Hermes only
initiates compaction in "hermes" mode.rM   NÚcodex_app_serverÚ codex_app_server_auto_compactionÚnative>   Úoffr¤   )r.   re   Úlowerr9   s   &r#   Ú_codex_native_auto_compactionr§   Ù   sQ   € ô
 	��z 4Ó(Ð,>Ñ>÷ 	ð 	ÜÜ�EÐ=¸xÓH×TÐTÈHó
ç
‰%‹'Øñðr"   c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# rl   r   )r*   s   "r#   r+   r+   æ   sN   € ÷ wQñ wQØðwQØ&ðwQØ8EðwQØUXðwQàðwQð 
ñwQr"   c           	     ó°  € ^ RI Hp RV n        RV n        V P                  '       g#   \        WP                  VP                  4       R# V P                  p\        VRR4      p\        V4      '       d   V! \        VP                  4      4       VP                  V 4      '       gC   VP                  VP                  VP                  VP                  VP                   4      '       g   R# TP#                  YP                  VP                  ;'       g    R4      p\        VRR4      p	\        V	4      '       d:   V	! 4       p
\%        V
\&        4      '       d   \%        V
\(        4      '       g   W n        \        V RR4      '       * ;'       d    \        VRR	 4      ! V4      p\+        V 4      pV'       g'   \        VR
R4      p\        V4      '       d	   V! V4       \        VRR 4      ! 4       pRpRpV'       d4   \,        P/                  RVR VP                   R VP0                  R 4       MÃV'       dn   \,        P/                  R\'        VP3                  RR4      4      V P4                  ;'       g    R4       W†P                   8¼  d   VP3                  RR4      pRVR 2pMNV'       d#   \,        P/                  R\        V RR4      4       M$VP7                  V4      pV'       g   \9        Wh4      pV'       d6    ^ RIHp V! WV4      pV'       d   \A        WV4       VP7                  V4      pV'       d   \C        WWhW$4       MUV'       d   V PE                  VW†P                   4       M0\G        V 4       V'       g   V'       g   V'       g   \I        WWhW$4       VPJ                  '       d   \M        WP                  V4      Vn'        R# R#   \>         d    Rp LÐi ; i)z‰Preflight context compression; the cheap pre-check gates the full estimate
(see ``_should_run_preflight_estimate`` for the OR semantics).rn   FNÚ lift_structural_backoff_if_grownrJ   Ú!snapshot_preflight_display_tokensÚ_request_pressure_anchoredÚ$should_defer_preflight_to_real_usagec                ó   € R # )Fr   )Ú_tokenss   &r#   rv   Ú(_preflight_compression.<locals>.<lambda>  s   € ÉUr"   Ú#maybe_seed_preflight_display_tokensrs   c                 ó   € R # ru   r   r   r"   r#   rv   r°     rx   r"   z•Skipping preflight compression: rough estimate ~%s >= %s is not anchored on real usage (last real provider prompt %s); deferring to the next responser€   z`Skipping preflight compression: same-session cooldown active (~%s seconds remaining, session %s)Úremaining_secondsg        r�   z	cooldown:z.0fzsSkipping Hermes preflight compression for codex app-server (mode=%s); Hermes will not start thread compaction here.r£   r¤   )Ú_maybe_grow_local_window)(r'   ro   Ú _turn_received_provider_responseÚ _turn_preflight_display_snapshotrŠ   Ú!_rearm_uncompressed_overflow_warnr   r   rŒ   r.   r/   ÚlenÚ"_review_fork_first_request_pendingÚ_should_run_preflight_estimateÚprotect_first_nÚprotect_last_nrŽ   r�   r�   r   r   r§   r’   r“   Úlast_real_prompt_tokensÚgetr”   Úshould_compressrE   Úagent.conversation_loopr´   rA   rQ   Ú_run_preflight_passesÚ_warn_context_overflow_blockedr1   Ú_engine_preflight_maintenancer   ra   r   )r'   ri   rc   r[   rd   r—   rš   Ú_liftÚ_preflight_tokensÚ_snapshot_fnÚ_snapshot_valÚ_preflight_deferredÚ_codex_native_autoÚ_maybe_seedÚ_compression_cooldownÚ_should_compress_nowÚ_compress_block_reasonÚ_cooldown_secsr´   Ú_growns   &&&&&               r#   rh   rh   æ   so  € õ *à-2€EÔ*Ø-1€EÔ*Ø×$×$Ð$Ü)¨%·±¸s×?WÑ?WÔXÙØ×*Ñ*€Kô �KÐ!CÀTÓJ€EÜ�‡‚ÙŒc�#—,‘,ÓÔ Ø
×-Ñ-¨e×4Ò4¸C×<^Ñ<^Ø�‰�k×1Ñ1°;×3MÑ3MØ×$Ñ$÷=ò =ñ 	à×5Ñ5Ø�|‰|˜S×5Ñ5×;Ð;¸óÐô
 ˜;Ð(KÈTÓR€LÜ�×ÒÙ$›ˆô �m¤S×)Ò)´*¸]ÌD×2QÒ2QØ5BÔ2ä% eÐ-IÈ5ÓQÔQ÷ ð ÔV]ØÐ;Ñ=RôWàóWÐô 7°uÓ=Ðçô ˜kÐ+PÐRVÓWˆÜ�K× Ò ÙÐ)Ô*ä#ØÐ>Áôó Ðð !ÐØ!ÐßÜ�‰ðXà  Ð#¨×)EÑ)EÀaÐ(HØ×2Ñ2°1Ð5õ		
÷ 
Ü�‰ð2äÐ%×)Ñ)Ð*=¸sÓCÓDØ×Ñ×&Ð& ô		
ð × <Ñ <Ô<à2×6Ñ6Ð7JÈCÓPˆNØ'0°ÀÐ0DÐ%EÐ"øß	Ü�‰ðGä�EÐ=¸xÓHõ	
ð  +×:Ñ:Ð;LÓMÐß#Ü%=¸kÓ%]Ð"ßð	ÝHá-¨eÐBSÓTˆF÷ Ü °FÔ;Ø#.×#>Ñ#>Ð?PÓ#QÐ ßÜØ˜¸õ	
÷ 
 ð 	×,Ñ,Ø"Ð$5×7SÑ7Sõ	
ô
 	˜UÔ#÷ &×)<×@RÜ)Ø˜K¸Nôð ‡~‡~€~ô %.¨e·\±\À<Ó$PˆÖ!ñ øô3 ô 	ØŠFð	ús   Ë5O ÏOÏOc               ó4   € V ^8„  d   QhRRRRRRRRRR	R
RRR/# ©r&   r'   r   ri   r   rš   rÅ   r   rc   r   rd   re   r(   r)   r   )r*   s   "r#   r+   r+   `  sO   € ÷ Qñ QØðQØ&ðQØ58ðQØMPðQà!ðQà69ðQð 
ñQr"   c           
     ób  € ^ RI Hp RVn        \        V 4       \        P                  RVR VP                  R V P                  VP                  R 4       \        VR\        P                  ! W2P                  R7      VVP                  VP                  V P                  R7      pV'       d   V P                  V4       \        ^\        \        V R^4      ;'       g    ^4      4      p\!        V4       EF·  p	VP"                  p
\%        V
4      pTpV P'                  W¤VVR	R
7      w  Vn        Vn        VP"                  V
J d?   \+        V 4      '       d.   \        P                  RV P,                  ;'       g    R4        R# TP/                  YP"                  VP(                  ;'       g    R4      pVP1                  V\%        VP"                  4      WÃ4      '       g-   VP3                  W4       VP5                  W4       RVn         R# \9        WP"                  VP:                  4      Vn        \=        V 4       VP?                  V4      '       g    R# VPA                  WÃVP                  4      '       d   EK„  RVn        \        PC                  RVR VR 4       VP5                  W4        R# 	  R# )zkThreshold-triggered preflight passes (honor ``compression.max_attempts`` like
the loop's sites, default 3).rn   TzDPreflight compression: ~%s tokens >= %s threshold (model %s, ctx %s)r€   Ú	preflight)r=   Ú	threshold)r„   r…   r†   rŽ   Úcontext_lengthrO   Úmax_compression_attemptsÚturn_start_thresholdr‡   zRPreflight compression deferred: compression lock held by another path (session %s)r�   rJ   zgPreflight compression made insufficient progress: ~%s -> ~%s request tokens; skipping additional passesN)"r'   ro   r   r1   r’   r“   rŽ   rO   rÕ   r   r
   r*   r•   Úmaxr   r.   Úranger   r¸   r–   r   r   r”   r�   Úcompression_made_progressÚ$_fail_closed_after_preflight_timeoutÚ%_fail_closed_on_insufficient_progressr   r   r   r:   r¿   Ú,_compression_warrants_another_preflight_passÚwarning)r'   ri   rš   rÅ   rc   rd   r—   Ú_preflight_statusÚ_max_preflight_passesÚ_passÚ_preflight_inputÚ	_orig_lenÚ_orig_tokenss   &&&&&&       r#   rÁ   rÁ   `  s{  € õ *à€C„Nô ˜ÔÜ
‡K�KØNØ˜QÐ
 [×%AÑ%AÀ!Ð$DÀuÇ{Á{Ø×%Ñ% aÐ
(ôô
 <ØØÜ=×DÒDØ$×0LÑ0Lô
ð (Ø$×5Ñ5Ø"×1Ñ1Ø�k‰kô
Ð÷ Ø×ÑÐ,Ô-Ü ¤3¤w¨uÐ6PÐRSÓ'T×'YÐ'YÐXYÓ#ZÓ[ÐÜÐ,×-ˆØŸ<™<ÐÜÐ(Ó)ˆ	Ø(ˆØ16×1HÑ1HØÐ<MØ%Ð/Eð 2Ió 2
Ñ.ˆŒ�cÔ.ð �<‰<Ð+Ó+Ô0OÐPU×0VÒ0Vô �K‰Kð
4à× Ñ ×*Ð* Fôò ð  ×9Ñ9Ø—<‘< ×!9Ñ!9×!?Ð!?¸Ró
Ðð ×,Ñ,Ø”s˜3Ÿ<™<Ó(¨,÷
ò 
ð ×4Ñ4°UÔNØ×5Ñ5°eÔOØˆCŒKÚÜ#IØ—<‘< ×!9Ñ!9ó$
ˆÔ ô 	,¨EÔ2Ø×*Ñ*Ð+<×=Ò=ÚØ×?Ñ?Ø¨[×-IÑ-I÷
õ 
ð ˆCŒKÜ�N‰NðHà Ð"Ð(9¸!Ð'<ôð ×5Ñ5°eÔOÚóe .r"   c               ó4   € V ^8„  d   QhRRRRRRRRRR	R
RRR/# rÑ   r   )r*   s   "r#   r+   r+   ´  sF   € ÷ (3ñ (3Øð(3Ø&ð(3Ø58ð(3ØMPð(3à!ð(3à69ð(3ð 
ñ(3r"   c           
     óP  € \        VRR4      p\        V4      '       g   R#  \        V! VP                  4      4      pT'       g   R# \
        P                  R\        TR\        T4      P                  4      TR \        TR^ 4      R 4       TP                  p	T P                  Y”Y5RR	7      w  Tn        Tn        TP                  T	Jd/   R
Tn        \        YP                  4      Tn        \        T 4       R# R#   \         d"   p\
        P                  RT4        Rp?R# Rp?ii ; i)z­Engine-driven sub-threshold preflight maintenance: engines overriding
``should_compress_preflight()`` get exactly ONE ``compress()`` pass; a no-op never
touches ``blocked``.Úshould_compress_preflightNzQshould_compress_preflight raised %s; skipping engine-driven preflight maintenancez_Engine-driven preflight maintenance: %s requested compress() at ~%s tokens (below %s threshold)Únamer€   rŽ   Úengine_preflightr‡   T)r.   r/   r   r   rA   r’   Údebugr“   Útyper   r–   r   r   r   r   r:   )
r'   ri   rš   rÅ   rc   rd   Ú_engine_preflightÚ_wants_engine_preflightÚ_preflight_excÚ_engine_inputs
   &&&&&&    r#   rÃ   rÃ   ´  s  € ô   Ð-HÈ$ÓOÐÜÐ%×&Ò&Ùð	Ü"&Ñ'8¸¿¹Ó'FÓ"GÐ÷ #ÙÜ
‡K�Kð	8ä�˜V¤T¨+Ó%6×%?Ñ%?Ó@Ø˜QÐ
¤W¨[Ð:LÈaÓ%PÐQRÐ$Sô	ð —L‘L€MØ-2×-DÑ-DØÐ5FØ"ð .Eó .Ñ*€C„L�#Ô*ð ‡|�|˜=Ó(ØˆŒÜ#IØ—<‘<ó$
ˆÔ ô 	,¨EÖ2ñ )øô/ ô ä�‰ð2àô	
õ
 	ûðús   ¢C9 Ã9D%ÄD Ä D%c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r&   r'   r   r   rZ   r   r   r(   r)   r   )r*   s   "r#   r+   r+   ß  s,   € ÷ !$ñ !$Øð!$Ø#ð!$Ø;Hð!$à	ñ!$r"   c                óæ  € ^ RI Hp \        \        V RR4      RR4      p\        V\        4      '       d   V^ 8”  g   R# ^ pV Fi  p\        V\
        4      '       g   K  VP                  R4      p\        V\        4      '       d   V\        V4      ,          pKV  V'       g   K`  V^,           p M	  WT8:  d   \        V 4       R# TP                  YT;'       g    R4      pW„8:  d   \        V 4       R# R# )z…Uncompressed session guard: the warning fires from the loop's pre-API site;
here we only RE-ARM the dedup once back under the window.rn   rŒ   NrÕ   ÚcontentrJ   )r'   ro   r.   r�   r   Údictr¾   re   r¸   r1   r�   )	r'   r   r   r—   Ú_ctx_lenÚ
_raw_charsÚ_mÚ_cÚ_uncompressed_tokenss	   &&&      r#   r·   r·   ß  sÛ   € õ
 *ä”w˜uÐ&:¸DÓAÐCSÐUYÓZ€HÜ�x¤×%Ò%¨(°Q¬,ÙØ€JÛˆÜ˜"œd×#Ò#ÙØ�V‰V�IÓˆÜ�bœ#×ÒØœ#˜b›'Õ!ŠJß‰Rð " A�ˆJÙñ ð ÔÜ˜UÔ#Ùð ×8Ñ8ØÐ-×3Ð3°óÐð Ô'Ü˜UÖ#ñ (r"   ru   )#r   Ú
__future__r   Úloggingr‹   Údataclassesr   Útypingr   r   r   r   Úagent.context_enginer   Úagent.conversation_compressionr	   r
   r   r   Ú	getLoggerr’   r   r1   r:   rE   rQ   rX   ra   rj   rg   r§   rh   rÁ   rÃ   r·   r   r"   r#   Ú<module>r      s¢   ðñXõ #ã Û Ý !ß ,Ó ,å D÷ó ð
 
×	Ò	Ð/Ó	0€ð ÷
ð 
ó ð
õ õ&÷õ,õ
õõõFQõR
õwQõtQõh(3÷V!$r"   