+
    iHàjÂ„ ã                  óª  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
HtHt ^ RIHtHtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHtHt ^ R
IH t H!t! ^ RI"H#t# ^ RI$H%t%H&t& ^ RI'H(t(H)t)H*t*H+t+ ^ RI,H-t-H.t. ^ RI/H0t0 ^ RI1H2t2H3t3H4t4H5t5 ^ RI6H7t7H8t8 ^ RI9H:t:H;t; ^ RI<H=t= ^ RI>H?t?H@t@ ^ RIAHBtBHCtCHDtD ^ RIEHFtF ^ RIGHHtH ^ RIIHJtJHKtKHLtLHMtM ^ RINHOtO ^ RIPHQtQ ^ RIRHStSHTtTHUtUHVtV ^ RIWHXtX ^ RIYHZtZ ^ RI[H\t\ ^ RI]H^t^ ^ R I_H`t` ^ R!IaHbtb ^ R"IcHdtd ^ R#IeHftf ^ R$IgHhth ]PÒ                  ! ]j4      tk]PØ                  ! R%4      tmR&tnR'toR( R) ltpR* R+ ltqR, R- ltrR. R/ ltsR0 R1 lttR2tuR3tvR4twR5 R6 ltx]y! 0 RÂm4      tz]y! R704      t{^t|R8 R9 lt}R: R; lt~^ tR< R= lt€R> R? lt�R@ RA lt‚RB RC ltƒRD RE lt„RF RG lt…RH RI lt†RJ RK lt‡RL RM ltˆRN t‰RORP/RQ RR lltŠRS RT lt‹RU RV ltŒRW RX lt�RY RZ ltŽR[RP/R\ R] llt�RÃR[RP/R^ R_ lllt�R` Ra lt‘RÄRb Rc llt’RdRReRÅ/Rf Rg llt“R[RP/Rh Ri llt”Rj Rk lt•RlRP/Rm Rn llt–Ro Rp lt—Rq Rr lt˜Rs t™Rt Ru ltšRvt›RwtœRxt�RytžRÄRz R{ lltŸR|t R}t¡R~t¢Rt£R€t¤/ t¥R�]¦R‚&   Rƒt§RÆt¨^ s©R„ R… ltªR† t«R‡ Rˆ lt¬R‰ RŠ lt­R‹ RŒ lt®R� RŽ lt¯RÇR� R� llt°R‘ R’ lt±R“ R” lt²R• t³R– t´RÄR— R˜ lltµR™ Rš lt¶R›RRœRR�R/Rž RŸ llt·R  R¡ lt¸R¢ R£ lt¹R¤R/R¥ R¦ lltºR§ t»R¨ R© lt¼]
 ! Rª R«4      4       t½]y! 0 RÈm4      t¾/ t¿R¬]¦R­&   R®]y! R¯04      /tÀR° R± ltÁR² R³ ltÂR´ Rµ ltÃRÉR¶ R· lltÄRÉR¸ R¹ lltÅRºtÆR» R¼ ltÇR½ R¾ ltÈR¿ RÀ ltÉRÁ.tÊR# )Êue  The agent conversation loop â€” extracted from ``run_agent.AIAgent``.

``run_conversation(agent, ...)`` drives one user turn (model call, tool dispatch,
retries, fallbacks, compression, post-turn hooks). Symbols that callers patch on
``run_agent`` (``handle_function_call``, ``_set_interrupt``, ``OpenAI``) resolve via
``_ra`` so those patches keep working.)ÚannotationsN)Ú	dataclassÚfieldÚfields)ÚAnyÚDictÚListÚOptional)Ú hidden_interrupt_placeholder_row)Ú_summarize_user_message_for_log)Ú
begin_turn)Úappend_messageÚwithout_persistence_fields)Ú_repair_tool_call_argumentsÚ_sanitize_surrogates)ÚMINIMUM_CONTEXT_LENGTHÚ_estimate_tools_tokens_rough)Ú_install_safe_stdio)ÚRUNTIME_ENVIRONMENT_ENDÚRUNTIME_ENVIRONMENT_HEADING)Úbuild_prompt_cache_planÚeffective_cache_ttlÚstrip_anthropic_cache_controlÚ"strip_anthropic_tool_cache_control)ÚREPETITION_LOOP_INTERRUPTEDÚis_runaway_repetition)Úresolve_agent_cwd)Úidentity_line_valueÚnote_inert_pinned_toolsÚruntime_host_valueÚstage_surface_switch_note)ÚPreflightCompressionTimedOutÚbuild_turn_context)Úrecord_cache_breakÚrecord_prompt_rebuild)ÚTurnRetryState)ÚPreludeÚplay_prelude)Úhandle_api_interruptÚnous_rate_limit_guardÚperform_api_call)Úhandle_api_error)Úbuild_api_request)ÚFAILED_TURN_DISPLAY_KINDÚOPEN_TURN_TAIL_ROLESÚfailed_turn_noticeÚ	site_copy)Úfinish_text_response)Úfinalize_turn)Úannounce_api_callÚapply_retry_restartsÚbegin_iterationÚprepare_iteration)Úhandle_outer_loop_error)Úrun_preflight_gate)Úassemble_api_request)Úcheck_api_response)Únormalize_model_response)Úrun_tool_round)Úset_session_context)Úset_current_write_origin)Úbase_url_host_matchesz^\[[A-Za-z_][A-Za-z0-9_.-]*\]$z5[This response was interrupted by a user correction.]u   [SYSTEM NOTICE â€” run time budget nearly exhausted] Run time budget nearly exhausted. Stop new discovery/verification work now. Produce the required final deliverable (answer/JSON/summary) from the state you already have, completing only mandatory writes.c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
é   Úagentr   Úapi_messagesúlist[dict[str, Any]]Úeffective_systemÚstrÚapprox_tokensÚintÚreturn© )Úformats   "Ú</home/ubuntu/.hermes/hermes-agent/agent/conversation_loop.pyÚ__annotate__rM   S   s;   € ÷ ]ñ ]Øð]Ø2ð]ØFIð]ØZ]ð]àñ]ó    c           
     óˆ  €  ^ RI Hp T! YT;'       g    R\        V RR4      ;'       g    RR7      p\        V\        4      '       d    \        V\
        4      '       g
   V^ 8¼  d   V# Y0P                  '       d   \        T P                  4      ,           # ^ ,           #   \         d    \        P                  RRR7        LYi ; i)	aV  Token figure the mid-turn pre-API compression guard compares: the pruned
native-Responses estimate when native compaction eligibility is proven (the generic
estimate overstates the wire on compacted sessions, #96995), else messages+tools.
The system prompt is counted exactly once.

When the upcoming request is eligible for native Responses compaction the transport will
checkpoint-prune the payload before sending, so the generic durable-history estimate overstates the wire
by orders of magnitude on a compacted session and fires a 600s local compression the main request never
needed (#96995).
)Ú*estimate_native_responses_preflight_tokensÚ ÚtoolsN)Úsystem_promptrR   zQnative Responses mid-turn estimate unavailable; using generic transcript estimateT©Úexc_info)Úagent.codex_responses_adapterrP   ÚgetattrÚ
isinstancerH   ÚboolÚ	ExceptionÚloggerÚdebugrR   r   )rB   rC   rE   rG   rP   Únatives   &&&&  rL   Ú _midturn_request_pressure_tokensr^   S   s«   € ð
Ý\Ù;ØÐ/?×/EÐ/EÀ2Ü˜% ¨$Ó/×7Ð7°4ô
ˆô �fœc×"Ò"¬:°f¼d×+CÒ+CÈÐRSÌØˆMð ÏÏÈÔ8¸¿¹ÓEÕ\Ð\ÐZ[Õ\Ð\øô ô 
Ü�‰Ø_Øð 	ö 	
ð
ús   ‚B ”B ª<B Â"CÃ Cc               ó    € V ^8„  d   QhRRRR/# ©rA   rB   r   rI   rY   rJ   )rK   s   "rL   rM   rM   p   s   € ÷ 	Sñ 	S¨#ð 	S°$ñ 	SrN   c                ó  € \        V RR4      p\        V\        4      '       d   \        V\        4      '       g   V^ 8:  d   R# \        V R^ 4      p\        V\        4      ;'       d"    \        V\        4      '       * ;'       d    W!8¬  # )zñTrue when a detached review fork has replayed its aggregate input budget.

Only forks with an explicit ``_review_input_token_budget`` are gated (#93057). Fires
at the top of the NEXT iteration, so the budget-crossing request completes first.Ú_review_input_token_budgetNFÚsession_input_tokens)rW   rX   rH   rY   )rB   ÚbudgetÚuseds   &  rL   Ú_review_input_budget_exhaustedrf   p   sm   € ô
 �UÐ8¸$Ó?€FÜ�fœc×"Ò"¤j°¼×&>Ò&>À&ÈAÄ+ÙÜ�5Ð0°!Ó4€DÜ�dœCÓ ×RÐR¬°D¼$Ó)?Ô%?×RÐRÀDÁNÐRrN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rB   r   ÚmessagesrD   rI   rY   rJ   )rK   s   "rL   rM   rM   |   s#   € ÷  ñ  ¨3ð  Ð:Nð  ÐSWñ  rN   c                ó  € \        V RR4      p\        V RR4      pV'       dM   V'       dE   \        V RR4      '       g2   \        P                  ! 4       V,
          R\        V4      ,          8  d   R# ^ RIHp \        V4       Fç  p\        V\        4      '       g   K  VP                  R4      R	8X  g   K3  VP                  V4      '       d    R# VP                  R
R4      p\        V\        4      '       d   VR\         2,           VR
&   M . T;'       g    . ORRR\        /NVR
&   RV n        \        P                  R\        V4      \        P                  ! 4       V,
          4        R# 	  R#   \         d      R# i ; i)zÕInject the one-time wall-clock wrap-up notice when past 80% of budget.

Appends to the NEWEST ``role:"tool"`` message (cache-safe, like /steer); latches
``_run_budget_wrapup_injected`` only on a successful append.Úrun_budget_secondsNÚ_run_budget_started_atÚ_run_budget_wrapup_injectedFgš™™™™™é?)Ú_DB_PERSISTED_MARKERÚroleÚtoolÚcontentrQ   ú

ÚtypeÚtextTz@Run budget wrap-up notice injected (budget=%.0fs, elapsed=%.0fs))rW   ÚtimeÚfloatÚagent.context_compressorrm   ÚreversedrX   ÚdictÚgetrF   ÚRUN_BUDGET_WRAPUP_NOTICErZ   rl   r[   Úinfo)rB   rh   rd   Ústartedrm   ÚmsgÚexistings   &&     rL   Ú_maybe_inject_run_budget_wrapupr   |   s@  € ô
 �UÐ0°$Ó7€FÜ�eÐ5°tÓ<€GßŸ¤G¨EÐ3PÐRW×$XÒ$XÜ	�Š‹�wÕ	 #¬¨f«Õ"5Ô5áÝ=Ü˜Ö!ˆÜ�cœ4× Ô  S§W¡W¨V£_¸Ö%>ð �w‰wÐ+×,Ò,ÚØ—w‘w˜y¨"Ó-ˆHÜ˜(¤C×(Ò(Ø!)¨dÔ3KÐ2LÐ,MÕ!M��I’ð!Ø%l¨¯¨°BÐ%l¸&À&È&ÔRjÐ9kÐ%l�C˜	‘Nð 15ˆEÔ-Ü�K‰KØRÜ�f“œtŸyšy›{¨WÕ4ôò ñ' "ñ( øô !ô !Û ð!ús   Ä	E/ÄE/Å/E?Å>E?c               ó$   € V ^8„  d   QhRRRRRR/# ©rA   rh   rD   Úuser_messager   rI   rY   rJ   )rK   s   "rL   rM   rM   Ÿ   s$   € ÷ ñ Ø"ðØ25ðà	ñrN   c                óŽ  € \        V\        4      '       d   \        VP                  4       4      pM#\        V\        4      ;'       d    \        V4      pV'       g   R# V '       d
   V R,          MRp\        V\
        4      '       d/   VP                  R4      R8X  d   VP                  R4      V8X  d   R# \        V RRRV/4       R# )z~Re-append this turn's real user ask when compaction left only a handoff (#80622).
Returns True when a restore append happened.FNrn   Úuserrp   Téÿÿÿÿ)rX   rF   rY   ÚstripÚlistrx   ry   r   )rh   r‚   Ú
restorableÚlasts   &&  rL   Ú%_restore_user_after_reference_handoffrŠ   Ÿ   s—   € ô
 �,¤×$Ò$Ü˜,×,Ñ,Ó.Ó/‰
ä ¬dÓ3×JÐJ¼¸\Ó8Jˆ
ßÙß#ˆ8�BŽ<¨€DÜ�$œ×Ò $§(¡(¨6Ó"2°fÔ"<ÀÇÁÈ)ÓATÐXdÔAdÙÜ�8˜f f¨i¸ÐFÔGÙrN   c               ó$   € V ^8„  d   QhRRRRRR/# r�   rJ   )rK   s   "rL   rM   rM   ±   s$   € ÷ 	ñ 	Ø"ð	Ø25ð	à	ñ	rN   c                óN   € ^ RI Hp V! V 4      ;'       d    \        W4      '       * # )zKGuard post-compaction continues against sole-handoff active turns (#80622).)Ú-reference_handoff_would_drive_next_model_call)rv   r�   rŠ   )rh   r‚   r�   s   && rL   Ú-_should_skip_model_call_for_reference_handoffrŽ   ±   s/   € õ Wñ 9¸ÓB÷ ð Ü-¨hÓEôHð rN   uX   Context was compacted. The previous response is complete â€” awaiting your next message.z¶Context compression timed out without reducing this conversation. No messages were dropped. Start a fresh session with /new, or check auxiliary.compression before retrying /compress.z3Operation interrupted: waiting for model response (c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )rA   Úcompression_attemptsrH   Úcompleted_compaction_pendingrY   Úprompt_tokensÚthreshold_tokensrI   rJ   )rK   s   "rL   rM   rM   Õ   s4   € ÷ ñ ØðØ@DðØUXðØloðà	ñrN   c               óp   € \        T ;'       d%    T;'       d    ^ Tu;8  ;'       d
    V8  4      # u 4      # )zÐTrue once a provider proves a completed compaction worked: rough estimates cannot
rearm the anti-thrash budget, only the completed-compaction latch plus a positive
normalized prompt count below the threshold.)rY   )r�   r‘   r’   r“   s   &$$$rL   Ú _should_rearm_compression_budgetr•   Õ   s@   € ô Ø×fÐfÐ!=×fÐfÀ!Àm×BfÔBfÐVfÑBfóð ÙBfóð rN   Úchat_completion_helpersc               ó    € V ^8„  d   QhRRRR/# )rA   ÚexcrZ   rI   rY   rJ   )rK   s   "rL   rM   rM   ð   s   € ÷ ñ ¨	ð °dñ rN   c                óN   € \        V \        4      '       d   ^ RIHp V! V 4      # R# )z–True for a fatal interpreter-shutdown RuntimeError. The RuntimeError type gate
stays here: a ValueError carrying similar text must not match (#93269).)Úinterpreter_shutting_downF)rX   ÚRuntimeErrorÚtools.interpreter_shutdownrš   )r˜   rš   s   & rL   Ú_is_interpreter_shutdown_errorr�   ð   s%   € ô �#”|×$Ò$õ 	IÙ(¨Ó-Ð-ÙrN   c               ó    € V ^8„  d   QhRRRR/# )rA   Úclientr   rI   rY   rJ   )rK   s   "rL   rM   rM   ÿ   s   € ÷ ;ñ ;°#ð ;¸$ñ ;rN   c                ó^   € \        \        V RR4      RR4      p\        \        VRR4      4      # )zÐTrue when ``client`` is the in-process MoA facade (only ``MoAChatCompletions`` exposes
``prepare()``; other clients raise TypeError on ``_moa_prepared_request`` even while
``agent.provider`` stays ``"moa"``).ÚchatNÚcompletionsÚprepare)rW   Úcallable)rŸ   r¢   s   & rL   Ú%_moa_client_consumes_prepared_requestr¥   ÿ   s/   € ô œ' &¨&°$Ó7¸ÈÓM€KÜ”G˜K¨°DÓ9Ó:Ð:rN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   ÚpreviousrF   ÚcontinuationrI   rH   rJ   )rK   s   "rL   rM   rM   
  s&   € ÷ Bñ B¨3ð B¸cð BÀcñ BrN   c                ó”  € \        V 4      \        8  g   \        V4      \        8  d   ^ # ^ .\        V4      ,          p^ p\        ^\        V4      4       FQ  pV'       d%   W,          W,          8w  d   W#^,
          ,          pK,  W,          W,          8X  g   KD  V^,          pW2V&   KS  	  ^ p\        V 4      ^,
          p\        V 4       Fn  w  rFV'       d   WaV,          8w  d   W#^,
          ,          pK&  WaV,          8X  g   K:  V^,          pV\        V4      8X  g   KU  WE8X  d   Vu # W#^,
          ,          pKp  	  V\        8¼  d   V# ^ # )zHReturn the longest continuation prefix that repeats the previous suffix.)ÚlenÚ_MIN_CONTINUATION_OVERLAPÚrangeÚ	enumerate)r§   r¨   Úprefix_lengthsÚmatchedÚindexÚ
last_indexÚchars   &&     rL   Ú_continuation_overlap_lengthr³   
  s  € ä
ˆ8ƒ}Ô0Ô0´C¸Ó4EÔHaÔ4aÙà�Sœ3˜|Ó,Õ,€NØ€GÜ�qœ#˜lÓ+Ö,ˆß˜,Õ-°Õ1FÔFØ$¨q¥[Õ1ŠGØÕ ,Õ"7Ö7Ø�q�LˆGØ$+˜5Ó!ñ -ð €GÜ�X“ Õ"€JÜ  Ö*‰ˆß˜$¨wÕ"7Ô7Ø$¨q¥[Õ1ŠGØ Õ(Ö(Ø�q�LˆGØœ#˜lÓ+Ö+ØÔ&Ø"’NØ(°1­Õ5’ñ +ð Ô!:Ô:ˆ7ÐAÀÐArN   c               ó    € V ^8„  d   QhRRRR/# )rA   Úpartsúlist[tuple[str, bool]]rI   rF   rJ   )rK   s   "rL   rM   rM   &  s   € ÷ ñ Ð!7ð ¸Cñ rN   c                óF  € RpRpV  F–  w  r4V'       d-   V'       d%   V'       d   V\        V\        V4      ) R V4      R pV'       dL   VR,          P                  4       '       g/   V'       d'   V^ ,          P                  4       '       g
   VR,          pW,          pTpK˜  	  V# )zDJoin continuation fragments, deduping only interrupted-stream seams.rQ   FNÚ
r…   )r³   rª   Úisspace)rµ   ÚjoinedÚprevious_was_partial_stubÚpartÚis_partial_stubs   &    rL   Ú_join_truncated_partsr¾   &  s‡   € à€FØ %ÐÛ!&Ñˆß$¯·DàÔ4°V¼SÀ»Y¸J¸KÐ5HÈ$ÓOÐPÐQˆDß˜& �*×,Ñ,×.Ò.·4ÀÀQÅÇÁ×@QÒ@QØ�d�NˆFØ�ˆØ$3Ò!ñ "'ð €MrN   c               ó    € V ^8„  d   QhRRRR/# )rA   rB   r   rI   rJ   )rK   s   "rL   rM   rM   5  s   € ÷ 
ñ 
¨3ð 
°3ñ 
rN   c                ó�   € \        V RR4      p\        VRR4      p\        V4      '       g   R#  V! 4       #   \         d     R# i ; i)z›Per-advisor metrics for post_api_request, or None off the MoA path (a plugin only
sees the aggregator generation; this carries the per-slot advisor spend).rŸ   NÚlast_reference_metrics)rW   r¤   rZ   )rB   rŸ   Úgetters   &  rL   Ú_moa_reference_metrics_for_hookrÃ   5  sM   € ô �U˜H dÓ+€FÜ�VÐ5°tÓ<€FÜ�F×ÒÙðÙ‹xˆøÜô Úðús   ¯6 ¶AÁAc               ó(   € V ^8„  d   QhRRRRRRRR/# )	rA   rB   r   rh   rD   rs   rF   rI   ÚNonerJ   )rK   s   "rL   rM   rM   B  s+   € ÷ '%ñ '% sð '%Ð6Jð '%ÐRUð '%ÐZ^ñ '%rN   c           	     óò  € T P                  \        V RR4      ;'       g    R4      P                  4       p\        .p\	        V4      '       d   VP                  \        4       RpMV'       d   VRV.,          pRP                  V4      pRV RV 2pV'       d   VR,          P                  R4      R8X  g"   \        Y'       d   RRRV/M	\        4       4       \        VRR	RVR
V/4       RV n        RV n        R# )a¾  Append a provider-safe checkpoint and correction to the live turn so role alternation
holds and cached messages stay byte-identical. INVARIANTS: raw chain-of-thought never enters
replayable content (inlined CoT reads as a prefill jailbreak and bricks the session with
empty-response storms); the interruption scaffold is replay text carried only in the user
correction's ``api_content``; an on-screen-empty placeholder is ``display_kind=hidden``.Ú _current_streamed_assistant_textrQ   z)Visible response before the interruption:rq   z2[Context from the interrupted assistant response]
rn   Ú	assistantrp   r„   Úapi_contentTNr…   )Ú_strip_think_blocksrW   r†   Ú_INTERRUPT_SCAFFOLD_MARKERr   Úappendr   Újoinry   r   r
   rÇ   Ú_stream_needs_break)rB   rh   rs   ÚvisibleÚcheckpoint_partsÚ
checkpointÚ
corrections   &&&    rL   Ú_apply_active_turn_redirectrÓ   B  sô   € ð ×'Ñ'¬°Ð7YÐ[]Ó(^×(dÐ(dÐbdÓe×kÑkÓm€Gä2Ð3ÐÜ˜W×%Ò%ð 	×ÑÔ ;Ô<Ø‰ß	ØÐHÈ'ÐRÕRÐØ—‘Ð-Ó.€JØFÀzÀlÐRVÐW[ÐV\Ð]€J÷ ˜ "�×)Ñ)¨&Ó1°[Ô@ô 	�xÎg &¨+°yÀ'Ñ!JÔ[{Ó[}Ô~ä�8˜f f¨i¸¸}ÈjÐYÔZð .0€EÔ*Ø $€EÖrN   c               ó    € V ^8„  d   QhRRRR/# r`   rJ   )rK   s   "rL   rM   rM   l  s   € ÷ 

ñ 

 ð 

¨ñ 

rN   c                óÄ   €  \        V P                  4       4      #   \         d:    \        T RR4      ;'       g    RP	                  4       P                  4       R9   u # i ; i)zœDelegate to ``AIAgent._is_copilot_provider``; the fallback keeps the ``github-copilot`` /
``github`` aliases so credential recovery is not skipped for them.ÚproviderrQ   >   ÚgithubÚcopilotúgithub-copilot)rY   Ú_is_copilot_providerrZ   rW   r†   Úlower)rB   s   &rL   rÚ   rÚ   l  s`   € ð
Ü�E×.Ñ.Ó0Ó1Ð1øÜô 
Ü˜˜z¨2Ó.×4Ð4°"×;Ñ;Ó=×CÑCÓEð J
ñ 
ò 	
ð
ús   ‚ ›Aº"AÁAc               ó$   € V ^8„  d   QhRRRRRR/# )rA   Ústatus_codeúOptional[int]Úerror_messagerF   rI   rY   rJ   )rK   s   "rL   rM   rM   y  s#   € ÷ ñ °Mð ÐRUð ÐZ^ñ rN   c                óÌ   a€ T;'       g    RP                  4       oV R8w  d
   RS9  d   R# \        ;QJ d    V3R lR 4       F  '       g   K   R# 	  R# ! V3R lR 4       4      # )zÝDetect a Copilot 400 that is really a STALE / DEGRADED credential (status 400 AND an
integrator/model-not-supported marker, so a wrong model name never triggers the
single-shot re-exchange). Caller enforces scoping/guard.rQ   i�  zerror code: 400Fc              3  ó,   <"  € T F	  qS9   x € K  	  R # 5i©NrJ   )Ú.0ÚmarkerÚlowereds   & €rL   Ú	<genexpr>Ú5_is_stale_copilot_credential_error.<locals>.<genexpr>€  s   øé € ð ñ 0 V˜Ö ó 0ùs   ƒT)Ú"model_not_available_for_integratorznot available for integratorÚmodel_not_supportedz$the requested model is not supported)rÛ   Úany)rÝ   rß   rå   s   &&@rL   Ú"_is_stale_copilot_credential_errorrë   y  sm   ø€ ð ×"Ð" ×)Ñ)Ó+€GØ�cÔÐ/°wÔ>Ùß‹3ô ñ 0ó �3Œ3ð Š3ð ˆ3ô ñ 0ó ó ð rN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   Ú
compressorr   Úrough_tokensrH   rI   rJ   )rK   s   "rL   rM   rM   ˆ  s!   € ÷ ñ ¨#ð ¸Sð ÀSñ rN   c                ó|   € \        \        V R^ 4      ;'       g    ^ 4      pW!8”  d   \        V RR4      '       g   V# V# )aÃ  Floor the ROUGH pre-API pressure estimate at the last REAL prompt size.

Applied only on the fallback path -- when ``anchored_context_tokens`` has
no valid anchor (first request, transcript rewritten under the anchor,
provider never reported usage). A valid anchor is provider-exact and is
used as-is; in particular on MoA turns the anchor deliberately uses the
pre-fold aggregator usage while ``last_real_prompt_tokens`` holds the
folded figure, so flooring an anchored value would re-add fan-out tokens
the anchor exists to exclude.

On the rough path, non-ASCII text (Cyrillic, Greek, Polish, ...)
under-counts by up to ~2x, so a session can sit at the provider's real
context ceiling while the rough figure stays under the compaction
threshold -- on silent-clip providers (ollama /v1) that is a truncation
death spiral the reactive overflow handler never sees (observed live:
real prompts 64,842->64,995 against a 55,705 threshold). The provider's
last reported prompt_tokens is authoritative; never let the rough figure
fall below it. Skipped for exactly one turn after a compaction, when
last_real_prompt_tokens still holds the stale pre-compression value
(#36718's awaiting_real_usage_after_compression window).
Úlast_real_prompt_tokensÚ%awaiting_real_usage_after_compressionF)rH   rW   )rí   rî   Ú	last_reals   && rL   Ú_pressure_with_real_floorró   ˆ  sH   € ô, ”G˜JÐ(AÀ1ÓE×JÐJÈÓK€IØÔ¬ØÐ;¸U÷)ò )ð ÐØÐrN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rB   r   Úrequest_tokensrH   rI   úOptional[str]rJ   )rK   s   "rL   rM   rM   ¦  s!   € ÷ ñ  sð ¸Cð ÀMñ rN   c                óî  € \        V RR4      p\        V RR4      '       d.   \        V\        4      '       d   ^ Tu;8  d   \        8  g    R#  R# \        V RR4      ;'       g    Rp\        P                  RT\        V RR4      ;'       g    R	\        V R
R4      ;'       g    RT\        T\        \        V RR4      ;'       g    . 4      \        V RR4      ;'       g    R4	       RV RVR R\        R R2# )zIReturn a user-facing error when Ollama is loaded with too little context.Ú_ollama_num_ctxNrR   ÚmodelrQ   úthe selected modelz±Ollama runtime context too small for Hermes tool use: model=%s provider=%s base_url=%s runtime_context=%d minimum_context=%d estimated_request_tokens=%d tool_count=%d session=%srÖ   ÚunknownÚbase_urlzunknown base URLÚ
session_idÚnonezOllama loaded `z` with only Ú,z6 tokens of runtime context, but Hermes needs at least a–   tokens for reliable tool use.

Increase the Ollama context for this model and restart/reload the model before trying again. A known-good starting point is 65,536 tokens. In Hermes config, set `model.ollama_num_ctx: 65536` (and `model.context_length: 65536` if you also override the displayed model context). If you manage the model through an Ollama Modelfile, set `PARAMETER num_ctx 65536` there instead.)rW   rX   rH   r   r[   Úwarningrª   )rB   rõ   Úruntime_ctxrù   s   &&  rL   Ú_ollama_context_limit_errorr  ¦  sû   € ä˜%Ð!2°DÓ9€Kä�E˜7 D×)Ò)Ü˜+¤s×+Ò+Ø�;Ö7Ô!7Õ7áð 8áä�E˜7 BÓ'×?Ð?Ð+?€EÜ
‡N�Nð	eàŒw�u˜j¨"Ó-×:Ð:°Ü��z 2Ó&×<Ð<Ð*<¸kÔKaØœœG E¨7°DÓ9×?Ð?¸RÓ@Ü��| TÓ*×4Ð4¨fôð ˜%˜ ¨[¸¨Oð <Ü0°Ð3ð 43ð	3ðrN   c               ó(   € V ^8„  d   QhRRRRRRRR/# )rA   rB   r   rí   rõ   rH   rI   rÞ   rJ   )rK   s   "rL   rM   rM   Ä  s*   € ÷ ñ  Cð °Sð Ø-0ðØ5BñrN   c                óÖ  € \        V RR4      ;'       g    RP                  4       P                  4       p\        V RR4      ;'       g    RpVR9  g   RV9   g
   RV9   g   R#  ^ RIHp \        \        VR^ 4      ;'       g    ^ 4      pV^ 8:  d   R# T! \        V R	R4      ;'       g    RV\        V4      VR
7      #   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)z~Grow a managed local model's context window before compressing; returns the new
window when the ladder granted one, else None.rÖ   rQ   rü   z	127.0.0.1Ú	localhostN)Úmaybe_grow_windowÚcontext_lengthrù   )rü   Úsession_tokensÚcurrent_windowz$local window growth check failed: %s)Úllamacppz	llama.cppz	llama-cppÚcustom)	rW   r†   rÛ   Úhermes_cli.local_runtime.growthr  rH   rZ   r[   r\   )rB   rí   rõ   rÖ   rü   r  r	  r˜   s   &&&     rL   Ú_maybe_grow_local_windowr  Ä  sÝ   € ô ˜˜z¨2Ó.×4Ð4°"×;Ñ;Ó=×CÑCÓE€HÜ�u˜j¨"Ó-×3Ð3°€HØÐGÔGØ�xÔ ;°(Ô#:áðÝEÜœW ZÐ1AÀ1ÓE×JÐJÈÓKˆØ˜QÔÙÙ Ü�E˜7 BÓ'×-Ð-¨2¸Ü˜~Ó.¸~ô
ð 	
øô ô Ü�‰Ð;¸SÔAÝûðús*   Á#B< ÂB< ÂB< Â(B< Â<C(ÃC#Ã#C(c                 ó   € ^ RI p V # )zPLazy ``run_agent`` reference so patches on ``run_agent.*`` reach this code path.N©Ú	run_agentr  s    rL   Ú_rar  Ü  s   € ãØÐrN   ÚbillingFc               ó$   € V ^8„  d   QhRRRRRR/# )rA   Ú
capabilityrF   r  rY   rI   rJ   )rK   s   "rL   rM   rM   â  s!   € ÷ ñ ¨#ð ¸4ð ÈCñ rN   c               óª   €  ^ RI HpHpHp V! RR7      pV'       d   V! V4      ;p'       d   V# V! WPRR7      ;'       g    R#   \         d     R# i ; i)z·``billing``: the request hit a billing wall. A usage-window account then gets its own next
step (top-up link); its plan is still live, so the entitlement copy alone would say nothing.)Ú&format_nous_portal_entitlement_messageÚ"format_usage_window_block_guidanceÚget_nous_portal_account_infoT)Úforce_fresh)r  Úin_chatrQ   )Úhermes_cli.nous_accountr  r  r  rZ   )r  r  r  r  r  Úaccount_infoÚwindow_guidances   &$     rL   Ú_nous_entitlement_messager  â  si   € ð÷	
ñ 	
ñ
 4ÀÔEˆßÑ+MÈlÓ+[Ð[˜Ö[Ø"Ð"Ù5Ø¸ô
÷ ð àð	øô ô Úðús&   ‚A �A ­A ¯A Á A ÁAÁAc               ó    € V ^8„  d   QhRRRR/# )rA   ÚmessagerF   rI   rY   rJ   )rK   s   "rL   rM   rM   õ  s   € ÷ ñ  Cð ¨Dñ rN   c                óŽ   € V'       g   R# VP                  4        F&  pV P                  V P                   RV 2RRR7       K(  	  R# )uT   Print each line of ``message`` as a ðŸ’¡ hint; False when there is nothing to print.Fu      ðŸ’¡ T)ÚforceÚ
diagnostic)Ú
splitlinesÚ_vprintÚ
log_prefix)rB   r   Úlines   && rL   Ú_print_guidancer(  õ  sC   € çÙØ×"Ñ"Ö$ˆØ�‰˜×)Ñ)Ð*¨(°4°&Ð9ÀÐRVˆÖWñ %árN   c               ó    € V ^8„  d   QhRRRR/# )rA   r  rF   rI   rY   rJ   )rK   s   "rL   rM   rM   þ  s   € ÷ Iñ I¸ð IÀñ IrN   c                ó,   € \        V \        V4      4      # râ   )r(  r  )rB   r  s   &&rL   Ú _print_nous_entitlement_guidancer+  þ  s   € Ü˜5Ô";¸JÓ"GÓHÐHrN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   Ú
api_kwargsr   Úrequest_messagesrI   rJ   )rK   s   "rL   rM   rM     s!   € ÷ 
ñ 
¨ð 
Àð 
Èñ 
rN   c                ó"  € V P                  R4      pVf   V P                  R4      pVfe   \        V\        4      '       dO   V'       dG   V^ ,          p\        V\        4      '       d(   VP                  R4      R8X  d   VP                  R4      pV# )z”System prompt as sent to the provider (``system`` / ``instructions`` / ``messages[0]``)
for observability hooks; None when the request carries none.ÚsystemÚinstructionsrn   rp   )ry   rX   r‡   rx   )r-  r.  rS   Úfirsts   &&  rL   Ú_system_prompt_for_hooksr3    sw   € ð —N‘N 8Ó,€MØÒØ"Ÿ™ ~Ó6ˆØÒ¤Ð,<¼d×!CÒ!C×HXØ  Õ#ˆÜ�eœT×"Ò" u§y¡y°Ó'8¸HÔ'DØ!ŸI™I iÓ0ˆMØÐrN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rÖ   rF   rü   rI   rY   rJ   )rK   s   "rL   rM   rM     s!   € ÷ ñ  sð °cð ¸dñ rN   c                ó¦   € T ;'       g    R P                  4       P                  4       R8H  ;'       g     \        \        T;'       g    R 4      R4      # )rQ   Únouszinference-api.nousresearch.com)r†   rÛ   r?   rF   )rÖ   rü   s   &&rL   Ú_is_nous_inference_router7    sJ   € Ø�NˆN˜×!Ñ!Ó#×)Ñ)Ó+¨vÑ5÷ ð Ô9NÜˆH�NˆN˜ÓÐ=ó:ð rN   Ú
unverifiedc               ó0   € V ^8„  d   QhRRRRRRRRRRRR/# ©	rA   r  rF   rÖ   rü   rù   r8  rY   rI   rJ   )rK   s   "rL   rM   rM     s<   € ÷ 5ñ 5Øð5Ø"%ð5Ø14ð5Ø=@ð5ØNRð5àñ5rN   c                óŽ  € \        W4      '       d   \        V R R7      # T;'       g    RP                  4       ;'       g    RpT;'       g    RP                  4       ;'       g    RpT;'       g    RP                  4       P                  4       R8X  dA   RpV'       d   RP	                  V RV R	2R
RVR.4      # RP	                  V RV R2RV.4      #  ^ RIHp V! WVR7      p	V	P                  ;'       g    TpV	P                  p
RP	                  V RV R2R.V
'       d	   V RV
 2.M. ORN4      #   \         d    Rp
 L<i ; i)T)r  rQ   zthe selected providerrú   Ú	anthropiczjYou can also switch to an Anthropic API key or another provider with /model <model> --provider <provider>.r¸   zC reported that your Claude subscription usage may be exhausted for uf    (included quota + extra-usage credits) â€” but this specific error is not proof of a billing problem.u  If https://claude.ai/settings/usage still shows quota remaining, this is probably NOT a billing problem: on a Claude subscription (OAuth) token Anthropic returns this same message when its content filter rejects part of the request â€” typically a phrase in the system prompt.zyIf usage really is exhausted: wait for the billing cycle to reset, or add extra usage at https://claude.ai/settings/usagez¡Retry with a fresh credential state: `hermes auth reset anthropic`. Until that cooldown clears, this error can be replayed from cache without contacting the API.z? reported that your Claude subscription usage is exhausted for z( (included quota + extra-usage credits).zdOptions: wait for the billing cycle to reset, or add extra usage at https://claude.ai/settings/usage©Úbuild_billing_block)rÖ   rü   rù   NzI reported that billing, credits, or account entitlement is exhausted for Ú.z=Add credits or update billing with that provider, then retry.z
 billing: zOYou can switch providers temporarily with /model <model> --provider <provider>.)
r7  r  r†   rÛ   rÍ   Úagent.billing_linksr>  Úprovider_labelÚbilling_urlrZ   )r  rÖ   rü   rù   r8  rA  Úmodel_labelÚswitchr>  Ú_linkrB  s   $$$$$      rL   Ú_billing_or_entitlement_messagerF    sŸ  € ô   ×3Ò3Ü(¨¸TÔBÐBà—n�n "×+Ñ+Ó-×HÐHÐ1H€NØ—;�;˜B×%Ñ%Ó'×?Ð?Ð+?€Kð
 	�ˆ�B×ÑÓ×%Ñ%Ó'¨;Ô6ð4ð 	÷ Ø—9‘9Ø!Ð"Ð"eØ�-ð  2ð2ð%ð6àðeðó ð ð �y‰yØÐÐ]ØˆmÐCðEàrØð	
ó ð 	ðÝ;Ù#¨XÐPUÔVˆØ×-Ñ-×?Ð?°ˆØ×'Ñ'ˆð �9‰9ØÐ
ÐcÐdoÐcpÐpqÐrØGð÷ ;FˆnÐ˜Z¨ }Ð5Ñ
6È2ðð 	Zð	ó ð øô ô ØŠðús   Ã"D4 Ã8D4 Ä4EÅEc               ó    € V ^8„  d   QhRRRR/# )rA   r8  rY   rI   zOptional[dict]rJ   )rK   s   "rL   rM   rM   M  s   € ÷ ñ Èdð Ð_mñ rN   c               óž   €  ^ RI Hp V! V \        V4      W#R7      P                  4       pTe   T'       d   RTR&   T#   \         d     R# i ; i)zQBest-effort structured billing descriptor (None if billing_links is unavailable).r=  )rÖ   rü   rù   r   NTr8  )r@  r>  rF   Úto_dictrZ   )rÖ   rü   rù   r   r8  r>  Úblocks   &&&&$  rL   Ú_billing_block_dictrK  M  sV   € ðÝ;Ù#Ø¬¨H«¸Uô
ç
‰'‹)ð 	ð
 ÒŸZØ"ˆˆlÑØ€Løô	 ô Úðús   ‚(= ½AÁAc               ó$   € V ^8„  d   QhRRRRRR/# )rA   ÚsummaryrF   r8  rY   rI   rJ   )rK   s   "rL   rM   rM   [  s!   € ÷ 6ñ 6 Sð 6°dð 6¸sñ 6rN   c                ó&   € V'       d   RV  2# RV  2# )zsTerminal-failure prefix for a billing-classified error; ``unverified`` (#82154) must
not assert exhaustion as fact.uz   Provider reported usage/credit exhaustion (unverified â€” the same error can be a content-filter rejection, not billing): zBilling or credits exhausted: rJ   )rM  r8  s   &&rL   Ú_billing_terminal_labelrO  [  s,   € ÷ ðFØFMÀYðPð	
ð ,¨G¨9Ð5Ð5rN   c               ó   € V ^8„  d   QhRR/# )rA   rI   ú+tuple[str, Optional[float], Optional[dict]]rJ   )rK   s   "rL   rM   rM   f  s   € ÷ .ñ .ÐCnñ .rN   c                óà  € \        VRR4      ;'       g    / pVP                  R4      '       g   R#  ^ RIHpHp ^ RIHp \        V RR4      pV! V 4      pVe   V! VRVR	7      MRp	VP                  R
4      p
\        \        VRR4      ;'       g    R4      P                  4       p\        V
\        4      '       d(   V
P                  4       '       d   V
P                  4       pM5V	'       d!   V	P                  R4      P                  4       pMV'       d   TpMR# Ve
   V! WxR7      MRpRp ^ RIHp ^ RIHp T! YV'       d   T! T;'       g    . 4      MRR7      pVe   VP                  4       MRpT\        V\$        4      '       d   V^ 8”  d   VR,          V3# RV3#   \         d    \         P#                  RRR7       Rp LSi ; i  \         d    \         P#                  RRR7       Ru # i ; i)u'  A usage-window 402 in the words of the credits limit line ("You've hit your daily limit Â· resets
15:56 Â· /topup to add credits") plus when that allowance frees up (epoch
seconds), so the chat and the error card say exactly what the notice says and the card can offer
a retry at the reset. The third item is the structured limit (:class:`agent.plan_limits.LimitHit`
payload: what ran out, the recommended models that still work, the credits option) every surface
renders as buttons or a sentence. ``("", None, None)`` for every other billing failure.Úerror_contextNÚusage_windowrQ   )Ú_window_hard_stopÚwindow_stop_resets_at_ms)Úcurrent_model_is_top_tierÚ_credits_stateF)Úmodel_is_freeÚmodel_is_top_tierÚdisplay_messager   u   âœ• )rZ  )Úestimate_messages_tokens_rough)Ú	limit_hit)r   Úneeded_tokensz&Usage-window limit payload unavailableTrT   iè  z!Usage-window refusal parse failed©rQ   NN)rW   ry   Úagent.credits_trackerrU  rV  Úagent.plan_limitsrW  rF   r†   rX   ÚremoveprefixÚagent.model_metadatar\  r]  Ú
to_payloadrZ   r[   r\   rH   )rB   Ú
classifiedrC   ÚcontextrU  rV  rW  ÚstateÚtop_tierÚstopÚdisplayÚserver_messager   Ú	resets_msÚlimitr\  r]  Úhits   &&&               rL   Ú_usage_window_refusalro  f  sÈ  € ô �j /°4Ó8×>Ð>¸B€GØ�;‰;�~×&Ò&ØÐð$ßUÝ?Ü˜Ð/°Ó6ˆÙ,¨UÓ3ˆØ\aÒ\mÑ  °eÈxÕXÐswˆð —+‘+Ð/Ó0ˆÜœW Z°¸BÓ?×EÐEÀ2ÓF×LÑLÓNˆÜ�gœs×#Ò#¨¯©¯ªØ—m‘m“o‰GßØ×'Ñ'¨Ó/×5Ñ5Ó7‰Gßð
 %‰Gà!Ð!ØSXÒSdÑ,¨UÕOÐjnˆ	Øˆð	ÝKÝ3Ù˜Eß`lÑ*HÈ×I[ÐI[ÐY[Ô*\ÐrvôxˆCà(+ª�C—N‘NÔ$¸TˆEð ¬Z¸	Ä3×-GÒ-GÈIÐXYÌM˜ TÕ)ÐejÐkÐkÐ_cÐejÐkÐkøô ô 	Ü�L‰LÐAÈDˆLÔQØŠEð	ûô ô Ü�‰Ð8À4ˆÔHØÒðúsa   ²AG ÂA G ÃG Ã*'G ÄG ÄG Ä)!F Å$F Å/(G ÆG Æ$GÇ G ÇGÇG Ç$G-Ç,G-ÚguidancerT  c               ó4   € V ^8„  d   QhRRRRRRRRRRR	R
RR/# )rA   rM  rF   Úapi_call_countrH   rÖ   rù   rp  rö   rT  rQ  rI   rx   rJ   )rK   s   "rL   rM   rM   —  sH   € ÷ #ñ #Øð#Ø;>ð#ØJMð#Ø`cð#àð#ð >ð#ð 
ñ	#rN   c        	        ó  € \        \        V RR4      4      p	Vf9   \        V4      R,           ^ ,          '       g   \        RV\	        V4      VV	R7      p\        V4      R,           R,          w  r«pT
;'       g     \        W4      V'       d   RV 2MR,           p/ pV
'       d   W®R&   Ve   W¾R	&   V'       d   WÎR
&   / VCRVRVRVRRRRRVRV P                  P                  R\        V P                  4      RV	R\        WEWgV	R7      /
C# )u  Structured terminal result for a billing-classified failure â€” the single construction
point for the non-retryable abort and max-retries paths (#82154). A usage-window refusal
reads as its one stop-line sentence instead of the generic "billing exhausted" text.Úbilling_unverifiedFrQ   zmodel access©r  rÖ   rü   rù   r8  ºNé   Nrq   Úusage_window_messageÚfailure_resets_atÚusage_limitÚfinal_responserh   Ú	api_callsÚ	completedÚfailedTÚerrorÚfailure_reasonÚfailure_retryableÚbilling_block)r8  ©rQ   )NNN)
rY   rW   ÚtuplerF  rF   rO  ÚreasonÚvalueÚ	retryablerK  )re  rM  rh   rr  rÖ   rü   rù   rp  rT  r8  rx  Úusage_window_resets_atrz  ÚfinalÚextras   $$$$$$$$$      rL   Ú_billing_failure_resultr‹  —  s.  € ô ”g˜jÐ*>ÀÓFÓG€JØÒ¤ |Ó!4°uÕ!<¸a× @Ô @Ü2Ø%°Ä3ÀxÃ=ÐX]Ø!ô
ˆô BGÀ|ÓATÐWiÕAiÐkmÕ@nÑ=Ð°+Ø ÷ `ð `Ü Ó4ÏX¸$¸x¸jÑ8IÐ[]Õ^ð 
à€EßØ(<Ð$Ñ%Ø!Ò-Ø)?Ð%Ñ&ßð $/�-Ñ ð	Ø
ð	à˜% ¨X°{ÀNØ�U˜H d¨G°WØ˜*×+Ñ+×1Ñ1àœT *×"6Ñ"6Ó7Ø˜jØÔ,¨XÀÐ]gÔhñ	ð 	rN   c               ó0   € V ^8„  d   QhRRRRRRRRRRRR/# r:  rJ   )rK   s   "rL   rM   rM   ½  s<   € ÷ ñ ØðØ),ðØ8;ðØDGðØUYðà	ñrN   c               ó2   € \        V \        WW4VR 7      4      # )ru  )r(  rF  )rB   r  rÖ   rü   rù   r8  s   &$$$$$rL   Ú&_print_billing_or_entitlement_guidancerŽ  ½  s#   € ô ˜5Ô"AØ¸8Øô#ó ð rN   c               ó    € V ^8„  d   QhRRRR/# )rA   Ústored_promptú
str | NonerI   rY   rJ   )rK   s   "rL   rM   rM   Æ  s   € ÷ $ñ $°ð $Àñ $rN   c                ó€  € V'       g   R#  ^ RI HpHpHp Rp ^ RIHp V! V 4      pV! W4      '       d   R# \        V RR4      '       g   R# \        \        V RR4      ;'       g    R4      P                  4       pV'       gl   V P                  '       dZ   V P                  '       dH    \        V P                  P                  V P                  4      ;'       g    R4      P                  4       pWr8H  ;'       d    \        V! W4      4      #   \         d     Lði ; i  \         d    Rp L=i ; i  \         d     R# i ; i)	aò  Bot Chat capability epoch check for a stored prompt.

The stored prompt embeds a capability fingerprint; a mismatch is a deliberate
once-per-change rebuild. Unstamped prompts never match; probe failures fail closed
to "reuse" so the cache is kept. Legacy upgrade: a Bot Chat prompt predating the
epoch mechanism gets ONE title-gated migration rebuild; the stamped result cannot
re-fire. A NULL or empty stored prompt already rebuilds every turn, so this probe
is not a gate there and must not run.
F)ÚBOT_CHAT_TITLEÚ$stored_bot_chat_prompt_needs_upgradeÚstored_prompt_capability_staleN)Ú_agent_homeTÚ_bot_mode_protocolÚ_session_title_hintrQ   )Útools.bot_mode_prober“  r”  r•  Úagent.system_promptr–  rZ   rW   rF   r†   Ú_session_dbrý   Úget_session_titlerY   )rB   r�  r“  r”  r•  Úhomer–  Útitles   &&      rL   Ú_bot_chat_prompt_stalerŸ  Æ  s&  € ÷ Ùð÷	
ñ 	
ð
 ˆð	Ý7Ù˜uÓ%ˆDñ *¨-×>Ò>ÙÜ�uÐ2°D×9Ò9ÙÜ”G˜EÐ#8¸"Ó=×CÐCÀÓD×JÑJÓLˆß˜×*×*Ð*¨u×/?×/?Ð/?ðÜ˜E×-Ñ-×?Ñ?À×@PÑ@PÓQ×WÐWÐUWÓX×^Ñ^Ó`�ð Ñ&×jÐj¬4Ñ0TÐUbÓ0iÓ+jÐjøô ô 	Ùð	ûô ô Ø’ðûô ô Úðús€   ŒD. ™D
 §D. ·D. ÁD. Á%D. ÂD. ÂD. Â'0D ÃD Ã-
D. Ã8D. Ä
DÄD. ÄDÄD. ÄD+Ä(D. Ä*D+Ä+D. Ä.D=Ä<D=Úpersist_toolsc               ó$   € V ^8„  d   QhRRRRRR/# )rA   Úfailure_messagerF   r   rY   rI   rÅ   rJ   )rK   s   "rL   rM   rM   í  s"   € ÷ ?ñ ?°3ð ?È$ð ?Ð[_ñ ?rN   c               ó2  € V P                   '       g   R#  V P                   P                  V P                  V P                  4       V'       d   ^ RIHp V! V 4       R# R#   \         d,   p\        P                  YP                  T4        Rp?R# Rp?ii ; i)zêPersist ``agent._cached_system_prompt`` to the session row; failures log at WARNING
(with ``failure_message``) because the gateway path (fresh AIAgent per turn) reads
this row every turn, so a silent failure breaks prefix-cache reuse.N)Úpersist_agent_tool_names)	r›  Úupdate_system_promptrý   Ú_cached_system_promptÚtools.mcp_tool_agentr¤  rZ   r[   r   )rB   r¢  r   r¤  r˜   s   &&$  rL   Ú_persist_system_promptr¨  í  sv   € ð ××ÐÙð?Ø×Ñ×.Ñ.¨u×/?Ñ/?À×A\ÑA\Ô]ßÝEÙ$ UÖ+ñ øô ô ?Ü�‰�×(8Ñ(8¸#×>Ò>ûð?ús   –7A  ÁA  Á BÁ+ BÂBc               ó   € V ^8„  d   QhRR/# )rA   rI   r‡   rJ   )rK   s   "rL   rM   rM   ü  s   € ÷ "ñ "°ñ "rN   c                ó~  € ^ RI HpHpHp V! V 4      pV'       d   VP	                  R4      MRp V'       d   \
        P                  ! V4      MRp V'       d   V! W4       V# Ve   \        V RR4      '       g	   V! V 4       V#   \         d    Rp LCi ; i  \         d    \        P                  RRR7        T# i ; i)	z£Pin ``agent.tools`` to the session's persisted array (tools freeze); returns the names
this surface built BEFORE the pin merged a previous surface's tools back in.)Úagent_tool_namesr¤  Úrestore_agent_tool_prefixÚ
tool_namesNÚ_persist_disabledFztool prefix restore skippedTrT   )r§  r«  r¤  r¬  ry   ÚjsonÚloadsÚ
ValueErrorrW   rZ   r[   r\   )rB   Úsession_rowr«  r¤  r¬  Úbuilt_for_this_surfaceÚsaved_toolsÚpins   &&      rL   Ú_restore_pinned_toolsr¶  ü  sÁ   € ÷ kÑjÙ-¨eÓ4Ðß3>�+—/‘/ ,Ô/ÀD€Kðß)4Œd�jŠj˜Ô%¸$ˆðCßÙ% eÔ1ð "Ð!ð Ò$¬W°UÐ<OÐQV×-WÒ-Wñ % UÔ+ð "Ð!øô ô ØŠðûô ô CÜ�‰Ð2¸TˆÕBØ!Ð!ðCús4   ¯B ·B ÁB ÁB Á"B ÂBÂBÂ"B<Â;B<c               ó   € V ^8„  d   QhRR/# ©rA   rI   rÅ   rJ   )rK   s   "rL   rM   rM     s   € ÷ .ñ . dñ .rN   c                ó^  € ^ RI Hp V! 4       p\        V RR4      pVf
   VR
9  d   R#  ^ RIHp Ve"   V! V \        VP                  4      RRR7       R# ^ RIHpH	p V! W! V4      V! 4       RRR7       R#   \         d-   p\        P                  R	T P                  T4        Rp?R# Rp?ii ; i)a•  Rebuild ``agent.tools`` for a Bot Chat capability refresh through the builder that
created the session, so the refreshed set is what a fresh desktop/TUI session gets
(#124211). A canonical Bot Chat never forks, so its tools[] is otherwise a fossil of
session creation: ``hermes tools enable/disable`` writes ``platform_toolsets`` and the
automatic between-turns refresh reuses the build-time selection. Only the desktop/TUI
gateway keeps agents alive across turns; every other surface builds a fresh agent whose
tools[] already reflects config. No prefix preservation: a disabled toolset must drop,
and the prompt rebuild this rides on already breaks the cache.)Úactive_policyÚplatformN)Úrefresh_agent_mcp_toolsT)Úenabled_overrideÚ
quiet_modeÚcontent_aware)Ú_load_disabled_toolsetsÚ_load_enabled_toolsets)r½  Údisabled_overrider¾  r¿  zFBot Chat capability refresh kept the previous tools for session %s: %s)ÚdesktopÚtui)Úgateway.session_policyrº  rW   r§  r¼  r‡   ÚtoolsetsÚtui_gateway.serverrÀ  rÁ  rZ   r[   r   rý   )rB   rº  Úpolicyr»  r¼  rÀ  rÁ  r˜   s   &       rL   Ú_refresh_bot_chat_toolsrÉ    s­   € õ 5Ù‹_€FÜ�u˜j¨$Ó/€HØ‚~˜(Ð*<Ô<Ùð.Ý@ØÒñ $ E¼DÀÇÁÓ<QØ/3À4õIáßVÙØÐ$:¸8Ó$DÙ5Ó7ÀDÐX\÷	^øô ô .Ü�‰Ð_Ø×'Ñ'¨÷	.ò 	.ûð.ús   ©)A5 ÁA5 Á5B,Â !B'Â'B,c           
     óÜ  € RpRpRpV'       dk   V P                   '       dY    V P                   P                  V P                  4      pVe/   VP                  R4      pVf   RM
VR8X  d   RMRpT;'       g    RpV'       dø   \        W4      '       dç   \        W4      '       d‹   \
        P                  R	V P                  4       R
V n
         ^ RIHp V! RR7       \        V 4       V P                  V4      V n        \!        V R4       \#        W P                  V4       \%        V RRR7       R# W0n        \#        WV4      p	\'        W4      p
V	'       d   \)        W
4       ^ RIHpHp V! W4       V! WR7       R# V'       dO   Rp\
        P                  RV P                  \1        V RR4      ;'       g    R\1        V RR4      ;'       g    R4       V'       d)   VR#9   d"   \
        P                  RV P                  V4       \'        W4      p
V P                  V4      V n        V'       d   \3        WW@P                  4       \#        W P                  V4       \)        W
4       \1        V RR4      '       g=    ^ RIHp T! RV P                  V P8                  \1        V RR4      ;'       g    RR7        ^ RIHp V! V 4       \%        V R"RR7       R#   \         d-   p\
        P                  RT P                  T4        Rp?EL…Rp?ii ; i  \         d     EL:i ; i  \         d!   p\
        P                  RT4        Rp?L‘Rp?ii ; i  \         d    \
        P?                  R RR!7        L®i ; i)$a9  Restore the cached system prompt from the session DB or build it fresh.

Mutates ``agent._cached_system_prompt`` and persists a freshly-built prompt on first
build. Row states ``missing``/``null``/``empty``/``present`` are logged and DB
failures log at WARNING so silent prefix-cache misses show in ``agent.log``.NÚmissingrS   ÚnullrQ   ÚemptyÚpresentu�   Session DB get_session failed for system-prompt restore (session=%s): %s. Falling back to fresh build â€” prefix cache will miss for this turn.z�Bot Chat capability epoch changed for session %s; rebuilding system prompt to adopt the new capability surface (one-time prefix-cache break).zBot Chat)Ú clear_skills_system_prompt_cacheT)Úclear_snapshotÚtoolset_changez~Session DB update_system_prompt failed after Bot Chat capability refresh (session=%s): %s. The refresh will re-fire next turn.)r   )Úreconstruct_static_prefixÚrestore_plugin_prompt_sections©Úsystem_messageÚstale_runtimezdStored system prompt for session %s has stale runtime identity; rebuilding for model=%s provider=%s.rù   rÖ   zÁStored system prompt for session %s is %s; rebuilding from scratch this turn. Prefix cache will miss until the rebuild persists. Investigate the previous turn's update_system_prompt write path.r®  F)Úinvoke_hookÚon_session_startr»  )rý   rù   r»  z on_session_start hook failed: %s)Úseed_credits_at_session_startz*cold-start credits seed failed (fail-open)rT   z…Session DB update_system_prompt failed for session %s: %s. Subsequent turns will rebuild the system prompt and miss the prefix cache.)rÌ  rÍ  ) r›  Úget_sessionrý   ry   rZ   r[   r   Ú_stored_prompt_matches_runtimerŸ  r{   r˜  Úagent.prompt_builderrÏ  rÉ  Ú_build_system_promptr¦  r#   r    r¨  r¶  r   rš  rÒ  rÓ  rW   r$   Úhermes_cli.lifecycler×  rù   r`  rÙ  r\   )rB   rÕ  Úconversation_historyr�  Ústored_stater²  Ú
raw_promptr˜   rÏ  Úannounced_switchr³  rÒ  rÓ  Ú_invoke_hookrÙ  s   &&&            rL   Ú_restore_or_build_system_prompträ  1  s,  € ð €MØ€LØ€Kß × 1× 1Ð 1ð	Ø×+Ñ+×7Ñ7¸×8HÑ8HÓIˆKØÒ&Ø(Ÿ_™_¨_Ó=�
Ø)3Ò);™vÈZÐ[]ÔM]Á'Ðcl�Ø *× 2Ð 2¨d�÷ Ô7¸×MÒMä! %×7Ò7Ü�K‰KðRà× Ñ ôð
 )3ˆEÔ%ðÝQÙ0ÀÕEô $ EÔ*Ø*/×*DÑ*DÀ^Ó*TˆEÔ'Ü˜uÐ&6Ô7Ü% e×-HÑ-HÐJ^Ô_ô
 #ØðHà"õ	ñ ð '4Ô#ô 5°UÐK_Ó`Ðô "7°uÓ!JÐßÜ# EÔB÷ 	bÙ& uÔ<Ù! %ÕGÙßØ&ˆÜ�‰ð3à×Ñœg e¨W°bÓ9×?Ð?¸RÄÈÐPZÐ\^ÓA_×AeÐAeÐceô	
÷  Ð0AÔ Aô 	�‰ð/ð ×Ñ˜lô		
ô 3°5ÓFÐØ"'×"<Ñ"<¸^Ó"L€EÔßÜ˜e°L×B]ÑB]Ô^ô ˜e×%@Ñ%@ÐBVÔWÜ˜EÔ:ô �5Ð-¨u×5Ò5ð	DÝHÙØ"¨u×/?Ñ/?ÀuÇ{Á{Ü  ¨
°DÓ9×?Ð?¸RõðRÝGÙ% eÔ,ô Øð	?à÷	øôm ô 	Ü�N‰NðXà× Ñ  #÷ò ûð	ûô* ô Úðûôl ô 	DÜ�N‰NÐ=¸s×CÑCûð	Dûô ô RÜ�‰ÐAÈDˆÖQðRús`   ¢AK Á6K ÃL É22L Ê%L Ê.M ËLË!K>Ë>LÌLÌLÌMÌ#L>Ì>MÍ"M+Í*M+c               ó    € V ^8„  d   QhRRRR/# )rA   ÚpromptrF   rI   rY   rJ   )rK   s   "rL   rM   rM   ¿  s   € ÷ ñ °#ð ¸$ñ rN   c                ó€  € R FP  w  r#\        W4      p\        \        WR4      ;'       g    R4      P                  4       pV'       g   KG  WE8w  g   KO   R# 	  \        VR4      pV'       d&   \        V RR4      '       d   W`P                  8w  d   R# \        VR4      pV'       d   V\        \        4       4      8w  d   R# R# )zAReturn False when the persisted runtime-identity lines are stale.rQ   Fz
Session IDÚpass_session_idzCurrent working directoryT))ÚModelrù   )ÚProviderrÖ   )r   rF   rW   r†   rý   r   r   )rB   ræ  ÚlabelÚattrÚstoredÚcurrentÚ
stored_sidÚ
stored_cwds   &&      rL   rÛ  rÛ  ¿  s£   € ó F‰ˆÜ$ VÓ3ˆÜ”g˜e¨2Ó.×4Ð4°"Ó5×;Ñ;Ó=ˆß‰6�fÖ'Úñ	 Fô % V¨\Ó:€Jß”g˜eÐ%6¸×>Ò>À:×QaÑQaÔCaÙô $ FÐ,GÓH€Jß�j¤CÔ(9Ó(;Ó$<Ô<Ùñ rN   uL  [System: The previous response was cut off by a network error mid-stream â€” a transport interruption, NOT a change in your capabilities. Your tools are still fully available; call them as normal and ignore any earlier claim that you lack tool access. Continue the task from where you left off. Do not restart or repeat prior text.]z°[System: Your previous response was truncated by the output length limit. Continue exactly where you left off. Do not restart or repeat prior text. Finish the answer directly.]z°[System: The previous response was cut off by a network error mid-stream. Continue exactly where you left off. Do not restart or repeat prior text. Finish the answer directly.]z![System: Your previous tool call c               ó$   € V ^8„  d   QhRRRRRR/# )rA   r½   rY   Údropped_toolszOptional[list[str]]rI   rF   rJ   )rK   s   "rL   rM   rM   ò  s(   € ÷ gñ g¨dð gÐCVð gÐbeñ grN   c                ó’   € V '       d-   V'       d%   R P                  VR,          4      p\         RV R2# V '       d   \        # \        # )ú, rv  Ú(u«  ) was too large and the stream timed out before it could be delivered. Do NOT retry the same tool call with the same large content. Instead, break the content into multiple smaller tool calls (e.g. use multiple patch calls or write smaller files). Each tool call's arguments must be under ~8K tokens to avoid stream timeouts. The cut was a transport interruption, not a capability change â€” your tools remain fully available.])rÍ   Ú)_LENGTH_CONTINUATION_DROPPED_TOOLS_PREFIXÚ!_LENGTH_CONTINUATION_NETWORK_STUBÚ!_LENGTH_CONTINUATION_OUTPUT_LIMIT)r½   rò  Ú	tool_lists   && rL   Ú_get_continuation_promptrú  ò  sJ   € ßŸ=Ø—I‘I˜m¨BÕ/Ó0ˆ	ä8Ð9¸¸9¸+ð F\ð \ð	
÷ 1@Ô,ÐfÔEfÐfrN   zá[System: Your previous response contained only internal reasoning and never produced a visible answer or tool call. Do not keep thinking. Produce your final answer as plain text now (or make the tool call you were planning).]zr[System: Continue now. Execute the required tool calls and only send your final answer after completing the task.]zñ[System: Your previous message ended the turn with a fragment that is not a usable answer. If the task is unfinished, continue it and then give the complete answer. If that fragment WAS your complete answer, send it again exactly as before.]u    Your previous turn indicated a tool call but none was included. Do not narrate a plan or restate intent â€” issue the actual tool call now to continue the task.z~You just executed tool calls but returned an empty response. Please process the tool results above and continue with the task.zdict[str, str]Ú_CANON_ARGS_CACHEi   c               ó    € V ^8„  d   QhRRRR/# )rA   Úarg_strrF   rI   rJ   )rK   s   "rL   rM   rM   1  s   € ÷ ñ ¨sð °sñ rN   c                óL  € \         P                  V 4      pVe   V# \        P                  ! \        P                  ! V 4      RRR7      pV\         V &   \
        \        V 4      \        V4      ,           ,          s\        \         4      \        8”  g$   \
        \        8”  di   \        \         4      ^8”  dU    \        \        \         4      4      p\
        \        V4      \        \         P                  V4      4      ,           ,          sK�  V#   \        \        \        3 d     T# i ; i)z�Canonical wire form of a tool-call arguments JSON string; raises on malformed input
(the caller falls back to ``_repair_tool_call_arguments``).T)Ú
separatorsÚ	sort_keys)rÿ   Ú:)rû  ry   r¯  Údumpsr°  Ú_canon_args_cache_bytesrª   Ú_CANON_ARGS_CACHE_MAXÚ_CANON_ARGS_CACHE_MAX_BYTESÚnextÚiterÚpopÚStopIterationÚKeyErrorr›   )rý  ÚcachedÚ	canonicalÚevicted_keys   &   rL   Ú!_canonicalize_tool_call_argumentsr  1  sé   € ô ×"Ñ" 7Ó+€FØÒØˆÜ—
’
œ4Ÿ:š: gÓ.¸:ÐQUÔV€IØ!*Ô�gÑÜœs 7›|¬c°)«nÕ<Õ<ÐÜ
ÔÓ
 Ô#8Ô
8ÜÔ"=Ô=Ä#ÔFWÓBXÐ[\ÔB\ð	ÜœtÔ$5Ó6Ó7ˆKÜ#¤s¨;Ó'7¼#Ô>O×>SÑ>SÐT_Ó>`Ó:aÕ'aÕaÒ#ð Ðøô œx¬Ð6ô 	ØØÐð	ús   Â4AD	 Ä	D#Ä"D#c           
     ó~  € \        V \        4      '       dM   V P                  4        UUu/ uF/  w  rT\        V\        \        34      '       d   \	        V4      MTbK1  	  upp# \        V \        4      '       d:   V  Uu. uF,  p\        V\        \        34      '       d   \	        V4      MTNK.  	  up# V # u uppi u upi )zõStructural clone (dicts/lists recursively, immutable leaves shared) of a history
message for the per-call API copy, so send-path rewrites never reach the persisted
transcript (#80498). Cheaper than deepcopy: messages are JSON-shaped and acyclic.)rX   rx   Úitemsr‡   Ú_clone_message_for_send)r}   ÚkÚvs   &  rL   r  r  F  s¡   € ô �#”t×ÒØ`c×`iÑ`iÔ`kÔlÑ`kÑX\ÐXY�´¸AÄÄd¸|×1LÒ1LÔ*¨1Ô-ÐRSÒSÑ`kÒlÐlÜ�#”t×ÒÙZ]Ó^ÑZ]ÐUV¬j¸¼TÄ4¸L×.IÒ.IÔ'¨Ô*ÈqÒPÑZ]Ñ^Ð^Ø€Jùó mùâ^s   ª5B4Á=2B:c               ó   € V ^8„  d   QhRR/# r¸  rJ   )rK   s   "rL   rM   rM   Q  s   € ÷ #ñ #°$ñ #rN   c           
     ó„  € V  F…  pVP                  R4      pV'       g   K  . pV F[  p\        V\        4      '       d2   RV9   d+   VR,          p \        VR,          4      p/ VCR/ VCRV/C/CpVP                  V4       K]  	  W1R&   K‡  	  R#   \         d'    \        TR,          TP                  RR4      4      p L]i ; i)z�Canonicalize tool-call argument JSON on the send-path copy (copy-on-write for the
dicts it touches; persisted history untouched).Ú
tool_callsÚfunctionÚ	argumentsÚnameÚ?N)ry   rX   rx   r  rZ   r   rÌ   )rC   ÚamÚtcsÚnew_tcsÚtcÚfnÚargss   &      rL   Ú_canonicalize_api_tool_callsr!  Q  sÈ   € ó ˆØ�f‰f�\Ó"ˆßÙØˆÛˆBÜ˜"œd×#Ò#¨
°bÔ(8Ø˜
•^�ð]Ü<¸RÀ½_ÓM�Dð C˜ÐB˜JÐ(A¨2Ð(A¨{¸DÑ(AÑB�Ø�N‰N˜2Öñ ð #ˆ<Óó# øô !ô ]Ü6°r¸+µÈÏÉÈvÐWZÓH[Ó\’Dð]ús   ÁBÂ.B?Â>B?c               ó    € V ^8„  d   QhRRRR/# )rA   r  rF   rI   rJ   )rK   s   "rL   rM   rM   h  s   € ÷ Iñ I¨3ð IÀSñ IrN   c                óŒ   € T ;'       g    RP                  4       '       g    R# RP                  \        V4      4      pRV  RV 2# )uï   Error content for an unknown tool name. A blank name is a model echoing tool-call
syntax seen in data (#47967) â€” dumping the catalog feeds that loop, so it gets a terse
error; a nonempty wrong name still gets the catalog to self-correct.rQ   u÷   Tool call rejected: the tool name was empty. If tool-call XML or JSON appeared in file contents or tool output, that is data â€” do not re-emit it as a tool call. To call a tool, use a valid name from your tool list; otherwise reply in plain text.rô  zTool 'z#' does not exist. Available tools: )r†   rÍ   Úsorted)r  Úvalid_tool_namesÚ	availables   && rL   Ú _invalid_tool_name_error_contentr'  h  sN   € ð �JˆJ�B×Ñ×ÒðYñ	
ð
 —	‘	œ&Ð!1Ó2Ó3€IØ�D�6Ð<¸Y¸KÐHÐHrN   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
rA   rh   ú
list[dict]rr  rH   r{  rF   Úerror_detailrI   údict[str, Any]rJ   )rK   s   "rL   rM   rM   v  s4   € ÷ 	ñ 	Øð	Ø*-ð	ØBEð	ØUXð	àñ	rN   c               ó,   € RVRV RVRRRRRR	V 2R
RRR/# )z’Terminal turn result for a content-policy block (deterministic for the unchanged
prompt, so no retry); shared by the HTTP-200 and exception paths.r{  rh   r|  r}  Fr~  Tr  zcontent_policy_blocked: r€  Úcontent_policy_blockedr�  rJ   )rh   rr  r{  r*  s   &&$$rL   Ú_content_policy_blocked_resultr.  v  s<   € ð 	˜.¨*°hÀÈ^Ø�U˜H d¨GÐ7OÐP\È~Ð5^ØÐ2Ð4GÈðð rN   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )rA   r{  rF   rh   r)  rr  rH   Úflagsr   rI   r+  rJ   )rK   s   "rL   rM   rM   ‚  s4   € ÷ ñ ØðØ#-ðØ?BðØMPðàñrN   c                ó"   € RV RVRRRVRV RR/VC# )	z˜Incomplete-turn result whose ``error`` mirrors ``final_response``; ``flags`` add the
recovery-contract keys (``failed``, ``compression_deferred``, ...).r{  rh   r}  Fr|  r  ÚpartialTrJ   )r{  rh   rr  r0  s   &&&,rL   Ú_partial_turn_resultr3  ‚  s0   € ð 	˜.¨*°hÀÈUØ�^ W¨n¸iÈðàQVðð rN   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	rA   rh   r)  rr  rH   r…  rF   rI   r+  rJ   )rK   s   "rL   rM   rM   �  s*   € ÷  ñ  °*ð  Ècð  Ð[^ð  Ðlzñ  rN   c           	     ó®  € V P                   ;'       g    RpVR8X  d@   \        V RR4      p\        P                  R\	        V\
        4      '       d   TMRV4       RpM>\        V RR4      p\        P                  R	T\	        V\
        4      '       d   TMR
4       Rp V P                  4        \        WaVRRV P                   R7      #   \         d     L'i ; i)uö   Soft turn result for a transiently-deferred compression. Both reasons must end as
``compression_deferred``, never ``compression_exhausted`` â€” the gateway wipes the
session on exhaustion (#9893/#35809). ``failed`` stays False; the turn persists.rþ   Útransient_blockÚ_compression_blocked_transientNuk   turn deferred: compression transiently blocked (%s) (session=%s) â€” not counting as compression exhaustionzunknown guardu´   Context compression is temporarily paused after a recent failed attempt. Please retry in a moment â€” compression will resume automatically (or run /compress to force a retry now).Ú _compression_skipped_due_to_lockuv   turn deferred: compression lock held by another path (session=%s holder=%s) â€” not counting as compression exhaustionÚunconfirmedu£   Context compression is already running for this session. Please retry in a moment â€” your next message will be processed once the concurrent compression finishes.FT)r~  Úcompression_deferredrý   )	rý   rW   r[   r{   rX   rF   Ú_flush_status_bufferrZ   r3  )rB   rh   rr  r…  ÚsessionrJ  Ú_finalÚholders   &&&&    rL   Ú_compression_deferred_resultr?  �  sè   € ð ×Ñ×(Ð( &€GØÐ"Ô"Ü˜Ð?ÀÓFˆÜ�‰ð%Ü/9¸%Ä×/EÒ/E¡eÈ?Ð\cô	
ð
mñ 	ô
 ˜Ð BÀDÓIˆÜ�‰ð1Ø29ÄZÐPVÔX[×E\ÒE\¹6Ðboô	
ð
\ð 	ðØ×"Ñ"Ô$ô  Ø˜.Ø¨4¸E×<LÑ<Lôð øô ô Ùðús   ÂC ÃCÃCc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	rA   rh   r)  rr  rH   Úrequest_pressure_tokensÚmax_compression_attemptsrI   r+  rJ   )rK   s   "rL   rM   rM   °  s6   € ÷ ñ ØðØGJðà ðà<?ðð ñrN   c                óØ   € V P                  4        \        P                  RV P                  WTR 4       V P	                  W4       \        \        RV P                  R7      WRRRRRR7      # )	zEFail closed when a rebuilt request is still too large after recovery.ze%sContext compression failed after %d attempts; rebuilt request remains over threshold at ~%s tokens.rÿ   Úcontext_overflow)rù   TÚcontext_compression_exhaustedF©r~  Úcompression_exhaustedÚturn_exit_reasonr€  r�  )r;  r[   r  r&  Ú_persist_sessionr3  r0   rù   )rB   rh   rß  rr  rA  rB  s   &&&&&&rL   Ú#_provider_overflow_exhausted_resultrJ  °  sm   € ð
 
×ÑÔ Ü
‡L�Lð	0à×ÑÐ2ÈqÐ6Qôð 
×Ñ˜8Ô:ÜÜÐ$¨E¯K©KÔ8Ø¨ÀTØ8Ø)¸Uô	ð rN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rÕ  rx   Ú	effectiverF   rI   rY   rJ   )rK   s   "rL   rM   rM   Ì  s!   € ÷ ñ °4ð ÀCð ÈDñ rN   c                ó  € V P                  R4      p\        V\        4      '       dC   V'       d;   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       g   R# \	        V4      ^8X  d   W^ ,          R&   R# \	        V4      ^8X  dp   V^ ,          P                  R4      ;'       g    RpV'       dF   VP                  V4      '       d/   V\	        V4      R '       d   V\	        V4      R V^,          R&   R# R# )zèRewrite a cache-decorated system message in place, keeping its blocks (a bare string
over the ``[static prefix, volatile tail]`` list would drop both cache_control
breakpoints). Returns False when the shape cannot be safely patched.rp   c              3  óz   "  € T F1  p\        V\        4      ;'       d    VP                  R 4      R8H  x € K3  	  R# 5i)rr   rs   N)rX   rx   ry   )rã   r¼   s   & rL   ræ   Ú1_rewrite_system_content_blocks.<locals>.<genexpr>Ñ  s3   é € ð ?ÙJQÀ$Œ
�4œÓ×=Ð= 4§8¡8¨FÓ#3°vÑ#=Ô=Ë'ùs   ‚;ž;FTrs   rQ   N)ry   rX   r‡   Úallrª   Ú
startswith)rÕ  rL  rp   Úheads   &&  rL   Ú_rewrite_system_content_blocksrS  Ì  sÖ   € ð × Ñ  Ó+€GÜ�gœt×$Ò$¯G¿3»3ñ ?ÙJQó?¿3¿3º3ñ ?ÙJQó?÷ <ò <ñ Ü
ˆ7ƒ|�qÔØ&��
�6ÑÙÜ
ˆ7ƒ|�qÔØ�q�z�~‰~˜fÓ%×+Ð+¨ˆß�I×(Ñ(¨×.Ò.°9¼SÀ»Y¸Z×3HØ!*¬3¨t«9¨:Ð!6ˆG�A�J�vÑÙÙrN   c                ój  € \        V RR4      p\        V\        4      '       d	   V'       g   V# V'       d~   V^ ,          P                  R4      R8X  da   V P                  '       d)   VR,           V P                  ,           P                  4       MTp\        V^ ,          V4      '       g   WA^ ,          R&   V# )z­Refresh the in-flight system message after a provider failover: ``api_messages`` were
built pre-failover and are reused each retry. Returns the new ``active_system_prompt``.r¦  Nrn   r0  rq   rp   )rW   rX   rF   ry   Úephemeral_system_promptr†   rS  )rB   rC   Úactive_system_promptÚsprL  s   &&&  rL   Ú_sync_failover_system_messagerX  à  sŽ   € ô 
�Ð/°Ó	6€BÜ�bœ#×Ò§bØ#Ð#ß˜ Q�×+Ñ+¨FÓ3°xÔ?ØMR×Mj×MjÐMj�R˜&•[ 5×#@Ñ#@Õ@×GÑGÔIÐprˆ	Ü-¨l¸1­o¸y×IÒIØ)2˜�O˜IÑ&Ø€IrN   c                ó:   € \        WV4      pRVn        RVn        V# )zÅAfter a successful fallback activation: sync the system message and arm
``restart_with_rebuilt_messages``. Callers also zero ``retry_count`` /
``compression_attempts`` and ``break`` the retry loop.FT)rX  Úprimary_recovery_attemptedÚrestart_with_rebuilt_messages)rB   rC   rV  Ú_retrys   &&&&rL   Ú_arm_fallback_restartr]  í  s+   € ô 9ØÐ1ó3Ðà(-€FÔ%Ø+/€FÔ(ØÐrN   c               ó   € V ^8„  d   QhRR/# r¸  rJ   )rK   s   "rL   rM   rM   ø  s   € ÷ gñ gÀtñ grN   c                ó&   € ^ RI Hp V! WRR7       R# )zÐRebuild ``_cached_system_prompt_static`` when caching becomes active (#72626): sessions
restored under a cache-off primary would otherwise fall back to the legacy layout after
failover to a cache-on provider.)rÒ  zfailover redecoration)rÕ  Ú	log_labelN)rš  rÒ  )rB   rÕ  rÒ  s   && rL   Ú#_ensure_cached_system_prompt_staticra  ø  s   € õ >Ù˜eÐNe×frN   c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rh   rD   rp  r   rI   rJ   )rK   s   "rL   rM   rM      s#   € ÷ 7ñ 7Ð!5ð 7Àð 7ÐI]ñ 7rN   c                ó   € ^ RI Hp V! W4      # )zIRemove MoA reference guidance attached by ``_attach_reference_guidance``.)Úpeel_reference_guidance)Úagent.moa_looprd  )rh   rp  rd  s   && rL   Ú_peel_moa_guidancerf     s   € å6Ù" 8Ó6Ð6rN   rÕ  Úmoa_preparedÚtools_for_apic               ó(   € V ^8„  d   QhRRRRRRRR/# )	rA   rC   rD   rg  úOptional[dict[str, Any]]rh  zOptional[list[dict[str, Any]]]rI   zKtuple[list[dict[str, Any]], Optional[dict[str, Any]], list[dict[str, Any]]]rJ   )rK   s   "rL   rM   rM     s/   € ÷ 1-ñ 1-Ø-ð1-à*ð1-àB`ð1-ð Qñ1-rN   c               óÎ  € T;'       g    .  Uu. uF&  p\        V\        4      '       d   \        V4      MTNK(  	  ppTp\        V\        4      '       d   VP                  R4      MRpV'       d   \        Wh4      p\	        V4       \        Ve   TM\        V R. 4      4      p	Vee   \        V RR4      R8X  dS   \        \        V P                  RR4      RR4      p
\        V
RR4      p\        V4      '       d   V! Wv4      pVR	,          pMÔV P                  '       dÃ   \        WR
7       \        V RR4      p^ RIHp \        TT	\        V P                  V P                   V P"                  R7      V P$                  \        V\&        4      '       d   TMR\        V RR 4      ! 4       V! \        V RR4      \        V RR4      4      R7      pVP(                  VP*                  r–WgV	3# u upi )u§   Strip and re-apply cache_control for the *current* provider policy â€” failover
``continue`` paths reuse ``api_messages`` (#72626). MoA guidance is peeled and rebased.rp  NrR   rÖ   Úmoar¡   r¢   Úrebase_prepared_requestrh   rÔ  Ú_cached_system_prompt_static)Ú*envelope_tool_part_cache_markers_supported©rÖ   rù   Ú._direct_native_anthropic_tool_cache_capabilityc                 ó   € R # )FrJ   rJ   rN   rL   Ú<lambda>Ú7_redecorate_prompt_cache_for_provider.<locals>.<lambda>-  s   € ÑQVrN   rQ   rü   )Ú	cache_ttlÚnative_anthropicÚstatic_system_prefixÚdirect_native_tool_cacheÚtool_part_markers)rX   rx   ry   rf  r   r   rW   rŸ   r¤   Ú_use_prompt_cachingra  Úagent.prompt_cachingro  r   r   Ú
_cache_ttlrÖ   rù   Ú_use_native_cache_layoutrF   rh   rR   )rB   rC   rÕ  rg  rh  Úmrh   Úpreparedrp  Úplanned_toolsr¢   ÚrebaseÚstaticro  Úplans   &&$$$          rL   Ú%_redecorate_prompt_cache_for_providerr„    sÂ  € ð Wc×VhÐVhÐfhÐVhÓ%jÑVhÐPQ´¸A¼t×1DÒ1D¤d¨1¤gÈ!Ò&KÑVh€HÐ%jØ€HÜ+5°hÄ×+EÒ+Eˆx�|‰|˜JÔ'È4€HßÜ% hÓ9ˆä! (Ô+Ü6Ø&Ò2‰¼ÀÀwÐPRÓ8Só€Mð Ò¤¨¨z¸4Ó @ÀEÔ Iô œg e§l¡l°F¸DÓAÀ=ÐRVÓWˆÜ˜Ð&?ÀÓFˆÜ�F×ÒÙ˜hÓ1ˆHØ 
Õ+ˆHøð 
×	"×	"Ð	"Ü+¨EÕQÜ˜Ð >ÀÓEˆÝSÜ&ØØô *¨%×*:Ñ*:ÀUÇ^Á^Ð[`×[fÑ[fÔgØ"×;Ñ;Ü+5°f¼c×+BÒ+B¡ÈÜ%,ØÐGÉô&ó &ñ
 IÜ˜˜z¨2Ó.´¸¸zÈ2Ó0Nóô
ˆð" #'§-¡-°·±�-à˜}Ð,Ð,ùòW &ks   �,G"c               ó$   € V ^8„  d   QhRRRRRR/# )rA   Úenginer   r  rF   rI   rY   rJ   )rK   s   "rL   rM   rM   :  s!   € ÷ ñ  3ð ¨cð °dñ rN   c                óª   € \        WR4      pV e   \        V4      '       g   R#  ^ RIHp \        VRR4      \        W14      J#   \         d     R# i ; i)zñTrue when ``engine`` implements ContextEngine hook ``name`` itself.

Non-implementing engines must pay nothing per turn; ``hasattr`` is not enough because
the ABC defines a no-op default. Lazy import avoids a cycle with agent.context_engine.NF)ÚContextEngineÚ__func__T)rW   r¤   Úagent.context_enginerˆ  rZ   )r†  r  ÚhookÚ_CEs   &&  rL   Ú_engine_overrides_hookr�  :  sS   € ô
 �6 Ó&€DØ‚~œX dŸ^š^ÙðÝ=Ü�t˜Z¨Ó.´g¸cÓ6HÐHÐHøÜô Úðús   ¥A ÁAÁAc               ó0   € V ^8„  d   QhRRRRRRRRRRR	R/# )
rA   rB   r   rC   rD   Úconversation_messagesÚincoming_messagerj  r[   rI   rJ   )rK   s   "rL   rM   rM   I  s>   € ÷ /ñ /Øð/Ø2ð/ØK_ð/à.ð/à;>ð/ð ñ/rN   c          
     ób  € \        V RR4      p\        VR4      '       g   V# \        V RR4      ;'       g    Rp TP                  TVe   V Uu. uF  p\        V4      NK  	  upMR\	        V\
        4      '       d   \        V4      MT\        VR^ 4      ;'       g    ^ R7      pTf   T# \	        T\        4      '       d­   T'       d¥   \        ;QJ d    R T 4       F  '       d   K   RM	  R	M! R T 4       4      '       dk   T Uu. uF  p\        T4      NK  	  p	p\        ;QJ d%    R \        Y˜4       4       F  '       d   K   RM	  R	M! R \        Y˜4       4       4      '       d   T# T	# TP                  RT4       T# u upi   \         d    TP                  RTR	R
7       Tu # i ; iu upi )zªRun the optional per-turn ``ContextEngine.select_context()`` hook, fail-open: any
exception or invalid return yields ``api_messages`` unchanged; history is never mutated.Úcontext_compressorNÚselect_contextrý   Ú-r  )r�  r�  Úbudget_tokenszYContext engine select_context hook failed; using unmodified request messages (session=%s)TrT   c              3  óB   "  € T F  p\        V\        4      x € K  	  R # 5irâ   )rX   rx   )rã   r~  s   & rL   ræ   Ú2_apply_context_engine_selection.<locals>.<genexpr>n  s   é € Ð6]ÑT\Èq´zÀ!ÄT×7JÐ7JÓT\ùs   ‚Fc              3  ó,   "  € T F
  w  rWJ x € K  	  R # 5irâ   rJ   )rã   ÚaÚbs   &  rL   ræ   r—  s  s   é € ÐJÑ2I©$¨!˜q�vÓ2Iùs   ‚znContext engine select_context returned an invalid value (not a non-empty list of dicts); ignoring (session=%s))rW   r�  r“  r  rX   rx   rZ   r   r‡   rP  r   Úzip)
rB   rC   r�  r�  r[   r†  Úsession_labelr~  ÚselectedÚstrippeds
   &&&&$     rL   Ú_apply_context_engine_selectionrŸ  I  s£  € ô �UÐ0°$Ó7€FÜ! &Ð*:×;Ò;ØÐä˜E <°Ó6×=Ð=¸#€MðØ×(Ñ(Øð )Ò4ñ 6KÓKÑ5J°Ô(¨Ö+Ñ5JÒKØ:>ô Ð.´×5Ò5ô (Ð(8Ô9Ø;Kä! &Ð*:¸AÓ>×CÐCÀ!ð )ó 
ˆð& ÒØÐô �(œD×!Ò!§h·3³3Ñ6]ÑT\Ó6]·3·3²3Ñ6]ÑT\Ó6]×3]Ò3]ñ <DÓD¹8°aÔ.¨qÖ1¹8ˆÐDß›3ÑJ´#°hÔ2IÓJŸ3Ÿ3š3ÑJ´#°hÔ2IÓJ×JÒJˆxÐXÐPXÐXØ
‡N�Nð	AØBOôð Ðùò= Løô ô Ø�‰ØgØ Dð 	ô 	
ð Òðüò Es/   ºF ÁF 
Á"9F ÂF ÄF,Æ F Æ!F)Æ(F)Úusagec               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )rA   rB   r   rh   rD   r   rj  r[   ÚmetarI   rÅ   rJ   )rK   s   "rL   rM   rM   {  s<   € ÷ 
ñ 
Øð
Ø.ð
Ø:Rð
Øcfð
Øpsð
à	ñ
rN   c          	     ó&  € \        V RR4      p\        VR4      '       g   R#  VP                  ! V Uu. uF  p\        V4      NK  	  up3RV/VB  R# u upi   \         d.    TP                  R\        T RR4      ;'       g    RRR	7        R# i ; i)
z�Notify the active context engine that a user turn has finished (fail-open; the engine
gets a copy so it cannot mutate the persisted transcript).r’  NÚon_turn_completer   z8Context engine on_turn_complete hook failed (session=%s)rý   r”  TrT   )rW   r�  r¤  r  rZ   r   )rB   rh   r   r[   r¢  r†  r~  s   &&$$,  rL   Ú$_notify_context_engine_turn_completer¥  {  s–   € ô
 �UÐ0°$Ó7€FÜ! &Ð*<×=Ò=Ùð
ð 	×ÒÁXÓ NÁXÀÔ!8¸Ö!;ÁXÑ NÑdÐV[ÐdÐ_cÔdùÒ NøÜô 
Ø�‰ØFÜ�E˜<¨Ó.×5Ð5°#Àð 	÷ 	
ð
ús(   £A ³AÁ
A ÁA Á*BÂ	BÂBc                ón   €  ^ RI Hp V! V 4      w  r4Ve   Vf   TpW4V3#  V RV3#   \         d     Li ; i)zžDecode a MoA preset encoded into ``user_message``; returns ``(user_message,
moa_config, persist_user_message)``, unchanged with ``moa_config=None`` otherwise.)Údecode_moa_turnN)Úhermes_cli.moa_configr§  rZ   )r‚   Úpersist_user_messager§  Ú_decoded_messageÚ_decoded_moa_configs   &&   rL   Ú_decode_inline_moa_turnr¬  Ž  s_   € ðÝ9Ù0?ÀÓ0MÑ-ÐØÒ*Ø#Ò+Ø'7Ð$Ø#Ð:NÐNÐNð +ð ˜Ð3Ð3Ð3øô ô Ùðús   ‚& ¦4³4c               ó   € V ^8„  d   QhRR/# )rA   rI   r+  rJ   )rK   s   "rL   rM   rM   �  s   € ÷ ñ À>ñ rN   c                ó¨   € \         P                  RV4       ^ RIHp V! V 4       \	        \        V4      \        T;'       g    . 4      ^ RRRRRR7      # )z¥Typed recovery result when turn-start preflight compression timed out (#98424): no
provider call was sent, and surfaces would otherwise hide the actionable guidance.uY   Turn-start preflight compression timed out â€” ending turn with typed recovery result: %s)Únote_turn_persistedTÚcontext_compression_timeoutrD  FrF  )r[   r   Úagent.agent_runtime_helpersr¯  r3  rF   r‡   )rB   r˜   rß  r¯  s   &&& rL   Ú_preflight_timeout_resultr²  �  sY   € ô ‡N�NØcÐehôõ
 @Ù˜Ôô  ÜˆC‹”$Ð+×1Ð1¨rÓ2°AØ¨4ÐB_Ø)¸Uôð rN   c                  óÔ  € ] tR tRt$ RtR]R&   R]R&   R]R&   R]R&   R]R&   R]R	&   R]R
&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   ^ tR]R&   RtR]R&   RtR]R&   Rt	R]R&   ^ t
R]R&   ^ tR]R&   ^ tR]R&   ^ tR]R&   ^ tR]R&   ]! ]R 7      tR!]R"&   ^ tR]R#&   RtR$]R%&   RtR]R&&   RtR]R'&   R(tR)]R*&   RtR]R+&   RtR]R,&   RtR]R-&   RtR]R.&   RtR]R/&   RtR]R0&   RtR]R1&   RtR]R2&   RtR]R3&   Rt R]R4&   Rt!R]R5&   Rt"R]R6&   ^ t#R]R7&   Rt$R]R8&   Rt%R]R9&   R:t&R)]R;&   Rt'R]R<&   Rt(R]R=&   Rt)R]R>&   Rt*R]R?&   Rt+R]R@&   Rt,R]RA&   Rt-R]RB&   RCt.R# )DÚ
_LoopStatei°  aï  Every local the turn loop threads through the phase helpers in ``agent/turn_*.py``.

Helpers take the loop locals they need as keyword arguments named like these fields and
return a verdict whose non-``action``/``result`` fields carry the same names;
:func:`_run_phase` passes and copies them back by name, so a new helper input/output
needs a field here and nothing else. Per-iteration slots are rebound by the phases
before any later phase reads them, exactly as the former inline locals were.r   r‚   rÕ  Ú
moa_configÚoriginal_user_messagerß  Úeffective_task_idÚturn_idÚ_should_review_memoryÚ_plugin_user_contextÚ_ext_prefetch_cacherh   rV  Úcurrent_turn_user_idxÚ_preflight_compression_blockedrB  rH   rr  Nr{  FrY   Úinterruptedr~  Úcodex_ack_continuationsÚlength_continue_retriesÚrestart_countÚ_outer_error_countÚtruncated_tool_call_retries)Údefault_factoryr¶   Útruncated_response_partsr�   rÞ   Ú_last_preflight_pressureÚ#_provider_overflow_recovery_pendingÚ_compression_timeout_exhaustedrû   rF   Ú_turn_exit_reasonÚ_pending_verification_responseÚ(_pending_verification_response_previewedÚpending_moa_prepared_requestÚrequest_loggerrC   rh  Ú_moa_prepared_requestrG   rA  Útotal_charsÚthinking_spinnerÚapi_start_timeÚretry_countÚmax_retriesr\  ri  Úfinish_reasonÚresponser-  Úapi_request_idÚ_original_api_kwargsÚ_llm_middleware_traceÚapi_durationÚassistant_messagerJ   )/Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__rr  r{  r¾  r~  r¿  rÀ  rÁ  rÂ  rÃ  r   r‡   rÅ  r�   rÆ  rÇ  rÈ  rÉ  rÊ  rË  rÌ  rÍ  rC   rh  rÎ  rG   rA  rÏ  rÐ  rÑ  rÒ  rÓ  r\  rÔ  rÕ  r-  rÖ  r×  rØ  rÙ  rÚ  Ú__static_attributes__rJ   rN   rL   r´  r´  °  s   ‡ ñTð ÓØÓØƒOØÓØÓØÓØƒLØÓØÓØÓàƒMØÓØÓØ$'Ó'ð "Ó!Ø€N�CÓØ€N�CÓØ€K�ÓØ€FˆDÓØ#$Ð˜SÓ$Ø#$Ð˜SÓ$ð
 €M�3ÓØÐ˜ÓØ'(Ð Ó(Ù7<ÈTÔ7RÐÐ4ÓRØ !Ð˜#Ó!Ø.2Ð˜mÓ2ð 16Ð'¨Ó5ð ,1Ð" DÓ0Ø&Ð�sÓ&ð +/Ð" CÓ.Ø5:Ð,¨dÓ:à(,Ð  #Ó,à€N�CÓØ€L�#ÓØ€M�3ÓØ!%Ð˜3Ó%Ø€M�3ÓØ#'Ð˜SÓ'Ø€K�ÓØ Ð�cÓ Ø€N�CÓØ€K�ÓØ€K�ÓØ€FˆCÓØ€M�3ÓØ€HˆcÓØ€J�ÓØ€N�CÓØ $Ð˜#Ó$Ø!%Ð˜3Ó%Ø€L�#ÓØ!Ð�s×!rN   r´  zdict[Any, tuple]Ú_PHASE_PARAMSr+   rÇ  c               ó   € V ^8„  d   QhRR/# )rA   rg  r´  rJ   )rK   s   "rL   rM   rM     s   € ÷ ñ  ñ rN   c                óÌ  € \         P                  V 4      pVfr   \        ;QJ d2    . R \        P                  ! V 4      P
                   4       F  NK  	  5M+! R \        P                  ! V 4      P
                   4       4      ;p\         V &   T ! V3/ V Uu/ uF  qUWS9   d	   W5,          M
\        W%4      bK  	  upB p\        P                  \        V RR4      R4      p\        V4       Ft  pVP                  R9   d   K  \        WhP                  4      p	VP                  V9  d   \        W(P                  V	4       KT  V	'       g   K^  \        W(P                  R4       Kv  	  V# u upi )zÝCall phase helper ``fn`` with the loop locals it names, copy its verdict fields back.

``extra`` supplies non-state arguments (the caught exception). Returns the verdict so
the caller can act on ``.action`` / ``.result``.c              3  ó6   "  € T F  qR 8w  g   K  Vx € K  	  R# 5i)rB   NrJ   )rã   Úps   & rL   ræ   Ú_run_phase.<locals>.<genexpr>  s   é € Ð*gÑ6V°Ð_fÑZf¯1ª1Ó6Vùs   ‚�
rÛ  rQ   TrJ   )ÚactionÚresult)râ  ry   r„  ÚinspectÚ	signatureÚ
parametersrW   Ú_LATCHED_VERDICT_FIELDSr   r  Úsetattr)
r  rB   rg  rŠ  ÚparamsÚnÚverdictÚlatchedÚfr†  s
   &&&,      rL   Ú
_run_phaserô    s  € ô
 ×Ñ˜rÓ"€FØ‚~ß%*¤UÑ*g´g×6GÒ6GÈÓ6K×6VÒ6VÓ*g§U¡UÑ*g´g×6GÒ6GÈÓ6K×6VÒ6VÓ*gÓ%gÐgˆ”˜rÑ"Ù�Ñ]ÑU[Ó\ÑU[ÐPQ¨!¬*˜ežh¼'À%Ó:KÒKÑU[Ñ\Ñ]€GÜ%×)Ñ)¬'°"°jÀ"Ó*EÀrÓJ€GÜ�GŽ_ˆØ�6‰6Ð)Ô)ÙÜ˜§¡Ó(ˆØ�6‰6˜Ô Ü�EŸ6™6 5Ö)ß‰UÜ�EŸ6™6 4Ö(ñ ð €Nùò ]s   Â"E!c               ó    € V ^8„  d   QhRRRR/# )rA   Úsr´  rI   rj  rJ   )rK   s   "rL   rM   rM   %  s   € ÷ ñ  *ð Ð1Iñ rN   c                óÎ  € VP                   VP                  8  dµ   \        \        W4      pVP                  R8X  d   VP
                  # VP                  R8X  d   R#  \        \        W4       \        \        W4      P                  R8X  d   R# \        \        W4      pVP                  R8X  d   VP
                  # VP                  R8X  d   R# KÏ  R#   \         d(    \        \        Y4      P                  R8X  d    R#  EK  \         dX   p\        \        YTR7      pTP                  R8X  d   TP
                  u Rp?# TP                  R8X  d    Rp?R#  Rp?EK^  Rp?ii ; i)u  One API call with its retry/recovery loop (guard â†’ build â†’ call â†’ check, error handlers).

Returns a turn result dict when a phase ends the turn, else None once the loop is left
(success, a restart armed on ``s._retry``, interrupt, or retries exhausted).rI   ÚbreakN)Ú	api_error)rÒ  rÓ  rô  r)   rè  ré  r,   r*   r:   ÚInterruptedErrorr(   rZ   r+   )rB   rö  Ú_ngÚ_rcrù  Ú_aes   &&    rL   Ú_run_api_retry_looprþ  %  s  € ð
 �-‰-˜!Ÿ-™-Ô
'ÜÔ.°Ó9ˆØ�:‰:˜Ô!Ø—:‘:ÐØ�:‰:˜Ô Ùð	ÜÔ(¨%Ô3ÜÔ*¨EÓ5×<Ñ<ÀÔGÙÜÔ/°Ó:ˆCØ�z‰z˜XÔ%Ø—z‘zÐ!Ø�z‰z˜WÔ$Ùñ %ñ øô  ô 	ÜÔ.°Ó9×@Ñ@ÀGÔKÚó Läô 	ÜÔ-¨uÀ9ÔMˆCØ�z‰z˜XÔ%Ø—z‘zÕ!Ø�z‰z˜WÔ$Ýö %ûð		ús<   Á/C Â,C Â;C Ã*E$ÄE$ÄE$Ä.EÄ;E$ÅEÅE$c               ó$   € V ^8„  d   QhRRRRRR/# )rA   rB   r   rö  rI   rj  rJ   )rK   s   "rL   rM   rM   E  s"   € ÷ ñ  #ð ¨#ð Ð2Jñ rN   c                óL  € V P                  VP                  VP                  VP                  VP                  VP
                  R7      p^ RIHp V! W4      '       g   V# \        VP                  R4      ;'       g    ^ 4      Vn
        \        V RVP                  4      Vn        R# )z‹The codex app-server's result for this turn, or None when its failure activated a fallback and the
generic loop retries the same user turn.)r‚   r¶  rh   r·  Úshould_review_memory)Ú"activate_codex_app_server_fallbackr|  N)Ú_run_codex_app_server_turnr‚   r¶  rh   r·  r¹  Úagent.turn_recoveryr  rH   ry   rr  rX  rV  )rB   rö  Úcodex_resultr  s   &&  rL   Ú_codex_app_server_turnr  E  s“   € ð ×3Ñ3Ø—^‘^¸1×;RÑ;RØ—‘¨q×/BÑ/BØ×4Ñ4ð 4ó €Lõ
 GÙ-¨e×BÒBØÐô ˜<×+Ñ+¨KÓ8×=Ð=¸AÓ>€AÔÜ:¸5À$È×H^ÑH^Ó_€AÔÙrN   c               óT   € 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RRRRRRR/# )rA   r‚   r   rÕ  r‘  rß  úlist[dict[str, Any]] | NoneÚtask_idÚstream_callbackúOptional[callable]r©  úOptional[Any]Úpersist_user_timestampúOptional[float]Úpersist_user_display_kindrö   Úpersist_user_display_metadatarj  Úpersist_user_platform_idÚturn_authorrµ  Útitle_user_messageÚpreludeúOptional[Prelude]rI   r+  rJ   )rK   s   "rL   rM   rM   W  s±   € ÷ _ñ _àð_ð ð_ð 6ð	_ð
 ð_ð (ð_ð (ð_ð ,ð_ð  -ð_ð $<ð_ð ,ð_ð *ð_ð )ð_ð &ð_ð ð_ð  ñ!_rN   c                óŒ
  € Vf   \        W4      w  rpR;V n        V n        RV n        \	        W4        V P                  4         \        WW#VWVV3RVRV	RV
R	VR
\        R\        R\        R\        R\        R\        R\         R\#        V4      RV/ p^ RIHp T! YP,                  TP.                  4      Tn        \1        4       T n        RT n        RT n        RT n        RT n        / T n        RT n        \A        R!RTRTR\C        T R^4      /\E        \@        4       Uu/ uFJ  pTPF                  \H        9   g   K  TPF                  \C        TTPF                  PK                  R4      4      bKL  	  upB pT PL                  R8X  d   \O        T T4      ;pe   T# \Q        T TT4      w  ppTR8X  d   T# TR8w  Edy   TPR                  T PT                  8  d   T PV                  PX                  ^ 8”  g   T PZ                  '       Ed0   \]        \^        T T4      P`                  R8X  d   EM\]        \b        T T4       \]        \d        T T4       \]        \f        T T4      pTP`                  R8X  d   TPh                  # TP`                  R8X  d   EMªTP`                  R8X  d   Ké  \]        \j        T T4       \l        Pl                  ! 4       ^ T Pn                  uTn8        Tn9        Tn:        \w        4       RRR3w  Tn<        Tn=        Tn>        Tn?        TP€                   RTPR                   2;TnA        T nB        \‡        T T4      pTe   T# \]        \ˆ        T T4      pTP`                  R8X  d   MÐTP`                  R8X  d   EKÄ   \]        \Š        T T4      pTP`                  R8X  d   TPh                  # TP`                  R8X  d   EK  \]        TPŒ                  PŽ                  '       d   \�        M\’        T T4      pTP`                  R8X  d   TPh                  # TP`                  R8X  d   MTP`                  R8X  d   EK}  EK€  \—        T 3/ \˜        Pš                  ! \–        4      Pœ                   Uu/ uF  pTR8w  g   K  T\C        TT4      bK  	  upB pTPž                  '       d   TP¡                  \¢        RRR 7       T#   \         d    \        P                  RRR7        ELŒi ; i  \$         d   p\'        T TT4      u Rp?# Rp?ii ; iu upi   \         d6   p\]        \”        T TTR7      P`                  R8X  d    Rp?EK   Rp?EKŒ  Rp?ii ; iu upi )"aÆ  Run a complete conversation with tool calling until completion; returns the result dict.

``stream_callback``: per-text-delta callback (TTS). ``persist_user_message``: clean text to
store when ``user_message`` carries API-only synthetic prefixes; timestamp / platform id are
stored as metadata (platform id lets restart drain recovery dedup).
``title_user_message``: optional pre-injection text for titles only (None uses the
model-facing message; an empty string suppresses titling for this turn).
``persist_user_display_*``:
display-only event rendering; the model still receives the message unchanged.
``prelude``: scripted tool calls played before the first model call (``agent/turn_scripted_prelude.py``).NFz&per-turn env credential refresh failedTrT   r  r  r  r  Úrestore_or_build_system_promptÚinstall_safe_stdioÚsanitize_surrogatesÚsummarize_user_message_for_logr=   r>   ÚraÚ
moa_activer  )Úbegin_voice_turn_routerÕ  rµ  rB  Ú_Úcodex_app_serverrI   rø  Úcontinueri  z:api:)ÚerB   )r  r2  rG  rJ   )Rr¬  Ú_last_compaction_in_placeÚ"_last_compression_attempt_recordedÚ"_last_compression_attempt_in_placeÚbegin_fast_mode_turnÚ#_try_refresh_env_client_credentialsrZ   r[   r\   r"   rä  r   r   r   r=   r>   r  rY   r!   r²  Úagent.voice_turn_router  rh   rV  ÚsetÚ_delivered_interim_textsÚ_incremental_persistence_failedÚ_last_persistence_error_causeÚ_compression_adoption_failedÚ_ephemeral_reasoning_offÚ_auth_pool_refresh_countsÚ_last_turn_usager´  rW   r   r  Ú_CTX_FIELDSÚlstripÚapi_moder  r'   rr  Úmax_iterationsÚiteration_budgetÚ	remainingÚ_budget_grace_callrô  r5   rè  r6   r9   r8   ré  r3   rt   Ú_api_max_retriesrÑ  rÒ  rÓ  r%   r\  rÔ  rÕ  r-  r¸  rÖ  Ú_current_api_request_idrþ  r4   r;   rÚ  r  r<   r1   r7   r2   rê  rë  rì  rÈ  ÚupdateÚ#_COMPRESSION_TIMEOUT_FINAL_RESPONSE)rB   r‚   rÕ  rß  r	  r
  r©  r  r  r  r  r  rµ  r  r  Ú_ctxÚ_preflight_timeout_excr  ró  rö  r  Ú_prelude_actionÚ_prelude_resultÚ_pgÚearly_resultÚ_rsÚ_riÚ_vr!  r  ré  s   &&&&&&&&&&&&&&&                rL   Ú_run_conversation_turnrD  W  s-  € ð6 ÒÜ9PØó:
Ñ6ˆÐ"6ð RWÐV€EÔ# eÔ&NØ/3€EÔ,Ü˜Ô5ðNØ×1Ñ1Ô3ð
^Ü!Ø ÀwØÐ3Iñ
ð '@ð
ð +Hð	
ð
 &>ð
ð $ð
ô ,Kð
ô  3ð
ô !5ð
ô ,Kð
ô !4ð
ô &>ð
ô ð
ô  ˜JÓ'ð!
ð"  2ñ#
ˆõ. >Ù 6°u¿m¹mÈT×MfÑMfÓ g€DÔô &)£U€EÔ"Ø,1€EÔ)Ø*.€EÔ'Ø).€EÔ&Ø%*€EÔ"Ø&(€EÔ#Ø!€EÔäñ 	Ø%ð	Ø2<ð	ä!(¨Ð0JÈAÓ!Nð	ô ?EÄZÔ>PÓ
jÑ>P¸ÐTU×TZÑTZÔ^iÑTiÔ4ˆ1�6‰6”7˜4 §¡§¡¨sÓ!3Ó4Ò4Ñ>PÑ
jñ	€Að ‡~�~Ð+Ô+ÔAWÐX]Ð_`ÓAaÐ1a°Ò0nØÐä'3°E¸1¸gÓ'FÑ$€O�_Ø˜(Ô"ØÐØ
˜WÕ
$Ø	
×	Ñ	˜E×0Ñ0Ô	0°U×5KÑ5K×5UÑ5UÐXYÔ5YÐ^c×^v×^vÑ^vä”o u¨aÓ0×7Ñ7¸7ÔBÙÜÔ$ e¨QÔ/ÜÔ'¨°Ô2ÜÔ+¨U°AÓ6ˆØ�:‰:˜Ô!Ø—:‘:ÐØ�:‰:˜Ô ÙØ�:‰:˜Ô#ÙÜÔ$ e¨QÔ/ä9=¿º»ÀaÈ×I_ÑI_Ð6ˆÔ˜!œ-¨¬Ü>LÓ>NÐPVÐX\Ð^bÐ>bÑ;ˆŒ�!”/ 1¤:¨q¬|Ø>?¿i¹i¸[ÈÈa×N^ÑN^ÐM_Ð;`Ð`ˆÔ˜5Ô8ä*¨5°!Ó4ˆØÒ#ØÐäÔ-¨u°aÓ8ˆØ�:‰:˜Ô ØØ�:‰:˜Ô#Úð	ÜÔ5°u¸aÓ@ˆCØ�z‰z˜XÔ%Ø—z‘zÐ!Ø�z‰z˜ZÔ'ÚÜØ"#×"5Ñ"5×"@×"@Ð"@•ÔFZÐ\aÐcdóˆBð �y‰y˜HÔ$Ø—y‘yÐ Ø�y‰y˜GÔ#ØØ�y‰y˜JÔ&Úò 'ô ˜5ñ ä×%Ò%¤mÓ4×?Ò?ó%á?ˆDÀ4È7Á?ô 	ˆŒg�a˜ÓÒÙ?ñ%ñ €Fð 	×'×'Ð'ð 	�‰Ô?ÈÐeiˆÔjØ€Møôk ô NÜ�‰Ð=Èˆ×MðNûô0 (ô ^Ü(¨Ð0FÐH\Ó]Õ]ûð^üò2 køôn ô 	ÜÔ1°5¸!¸qÔA×HÑHÈGÔSÞö Tûð	üò
%sy   ´R+ ÁAS ÄS9Ä84S9Í2-S> Î S> Î4AS> ÐS> ÐS> Ñ	UÑ)UÒ+"SÓSÓS6ÓS1Ó+S6Ó1S6Ó>T>Ô	"T9Ô9T>c               óT   € 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RRRRRRR/# )rA   r‚   r   rÕ  r‘  rß  r  r	  r
  r  r©  r  r  r  r  rö   r  rj  r  rµ  r  r  r  r  rI   r+  rJ   )rK   s   "rL   rM   rM   ù  s    € ÷ 9ñ 9àð9ð ð9ð 6ð	9ð
 ð9ð (ð9ð (ð9ð ,ð9ð  -ð9ð $<ð9ð ,ð9ð )ð9ð *ð9ð &ð9ð ð9ð  ñ!9rN   c                ó|  € ^ RI Hp ^ RIHp ^ RIHp RV n        V! V4      ;_uu_ 4         \        V VVVVVVVVV	V
VVVVR7      pV! V 4        RRR4       V! V XV4      p\        V\        4      '       d   \        \        V RR4      4      VR&   \        V V4       V#   T! T 4       i ; i  + '       g   i     Ld; i)	u¡  Run one turn (see ``_run_conversation_turn``) and export the current-turn boundary.

Every envelope that leaves the loop â€” success, partial/error, interrupt, retry-exhausted,
tool-limit, preflight timeout, codex runtime â€” passes through here, so the
``{turn_id, current_turn_user_idx}`` pair is stamped beside the exact ``messages`` it
addresses, after every history rewrite including post-turn micro-compaction.
)Úexport_current_turn_boundary)Úend_voice_turn_route)Únative_turn_imagesF)rÕ  rß  r	  r
  r©  r  r  r  r  rµ  r  r  r  NÚ_turn_user_intervenedÚuser_intervened)Úagent.turn_contextrG  r'  rH  Ú!tools.vision_tools_history_budgetrI  rJ  rD  rX   rx   rY   rW   Ú_close_durable_failed_turn)rB   r‚   rÕ  rß  r	  r
  r©  r  r  r  r  rµ  r  r  r  rG  rH  rI  ré  s   &&&&&&&&&&&&&&&    rL   Úrun_conversationrO  ù  sÌ   € õ0 @Ý;ÝDð #(€EÔñ 
˜L×	)Õ	)ð	(Ü+ØØØ-Ø%9ØØ /Ø%9Ø'=Ø*CØ.KØ)AØ%Ø'Ø#5ØôˆFñ$ ! Õ'÷) 
*ñ* *¨%°¸ÓF€FÜ�&œ$×ÒÜ$(¬°Ð8OÐQVÓ)WÓ$XˆÐ Ñ!Ü˜u fÔ-Ø€Møñ ! Õ'ú÷) 
*×	)ús"   ªB+¬BÁB+Â
B(Â(B+Â+B;	iÐ  c               ó    € V ^8„  d   QhRRRR/# )rA   ré  rx   rI   rJ   )rK   s   "rL   rM   rM   8  s   € ÷ .ñ .°ð .¸$ñ .rN   c                ó¦  € ^ RI Hp  T! YP                  ;'       g    RV P                  ;'       g    RR7      p\        VP                  R4      ;'       g    R4      P                  4       R\         pRV3R	V33 UUu/ uF  w  rVV'       g   K  WVbK  	  ppp\        V4      #   \         d    \
        P                  RRR7       Rp L�i ; iu uppi )
aM  The error text and ``error_surface`` a client needs to redraw the failed turn's error
card from the transcript, after the live ``message.complete`` frame is gone. Every
string is redacted with ``force=True``: the error came from a provider/tool, so a
secret echoed in it must not reach the durable store (the redaction e2e boundary).)Úbuild_error_surface_from_resultrQ   rp  z%failed-turn error surface unavailableTrT   Nr  Úerror_surface)Úagent.error_surfacerR  rÖ   rù   rZ   r[   r\   rF   ry   r†   Ú_FAILED_TURN_ERROR_MAX_CHARSÚ_redact_display_metadata)rB   ré  rR  Úsurfacer  r  r  Úmetadatas   &&      rL   Ú_failed_turn_display_metadatarY  8  sÈ   € õ
 DðÙ1ØŸ^™^×1Ð1¨r¸¿¹×9JÐ9JÈô
ˆô �—
‘
˜7Ó#×)Ð) rÓ*×0Ñ0Ó2Ð3PÔ4PÐQ€EØ#*¨EÐ"2°_ÀgÐ4NÑ!OÔUÑ!O™˜ÔST”�’Ñ!O€HÑUÜ# HÓ-Ð-øô ô Ü�‰Ð<ÀtˆÔLØŠðüó Vs'   ˆB# �B# ²B# Á>CÂCÂ#$C
Ã	C
c               ó    € V ^8„  d   QhRRRR/# )rA   rX  rx   rI   rJ   )rK   s   "rL   rM   rM   K  s   € ÷ 8ñ 8 tð 8°ñ 8rN   c                ó‚   aa€ ^ RI Ho VV3R loV P                  4        UUu/ uF  w  rVS! V4      bK  	  upp# u uppi )aá  Force-redact every string in a display_metadata payload (dicts and lists included).

display_metadata is persisted via ``SessionDB.append_message`` and re-delivered to
clients, so it sits downstream of the turn's own content redaction: an error string
that escaped a provider or tool would otherwise reach the 'store' and 'export' sinks
verbatim. ``force=True`` keeps the boundary closed even when ``security.redact_secrets``
is off, matching the compressor's persistence boundary.)Úredact_sensitive_textc                ó<  <€ \        V \        4      '       d   S! V R R7      # \        V \        4      '       d,   V P                  4        UUu/ uF  w  rVS! V4      bK  	  upp# \        V \        4      '       d   V  Uu. uF  pS! V4      NK  	  up# V # u uppi u upi )T)r"  )rX   rF   rx   r  r‡   )r†  r  r  Ú_redactr\  s   &  €€rL   r^  Ú)_redact_display_metadata.<locals>._redactU  s‚   ø€ Ü�eœS×!Ò!Ù(¨°dÔ;Ð;Ü�eœT×"Ò"Ø.3¯k©k¬mÔ<©m¡d a�A‘w˜q“z’M©mÒ<Ð<Ü�eœT×"Ò"Ù(-Ó.© 1‘G˜A–J©Ñ.Ð.Øˆùó =ùâ.s   ÁBÁ=B)Úagent.redactr\  r  )rX  r  r  r^  r\  s   &  @@rL   rV  rV  K  s:   ù€ õ 3öð '/§n¡nÔ&6Ô7Ñ&6™d˜aˆA‰w�q‹zŠMÑ&6Ò7Ð7ùÓ7s   £;c               ó    € V ^8„  d   QhRRRR/# )rA   ré  r   rI   rÅ   rJ   )rK   s   "rL   rM   rM   a  s   € ÷ ,Hñ ,H¨cð ,H°dñ ,HrN   c                ój  €  \        V\        4      '       d   VP                  R4      RJ d   R# VP                  R4      '       g.   VP                  R4      '       g   VP                  R4      R8X  d   R# VP                  R4      p\        V R	R4      \        V R
R4      rC\        V\        4      '       d   V'       d   Ve	   V'       g   R# \        V RR4      '       g   VP                  V4      \        9  d   R# VP                  R4      p\        V\        4      '       d    ^ Tu;8:  d   \        V4      8  d   M MW%R MTpRRR\        V4      R\        /p\        W4      ;p'       d   W‡R&   \        W'4       V P                  V4       R#   \         d    \        P!                  RRR7        R# i ; i)uª  Append a Hermes-authored assistant boundary when a failed turn left its durable tail open
(``OPEN_TURN_TAIL_ROLES``: the accepted ``user`` row, or a ``tool`` row when a call ran before
the failure), in place on ``result["messages"]`` and in SessionDB.

The terminal-failure paths (content-policy refusal, ``_Trunc.end_turn``, retry exhaustion,
interrupt before any assistant text) persist the accepted user row and return without
reaching ``finalize_turn``; the next prompt then appends a second user row and
``repair_message_sequence`` merges the failed request into the new one. The gateway
compensates with ``_hmwa_close_failed_turn``; CLI, TUI/Desktop and ACP hosts hand
``result["messages"]`` straight back as history, so the seam is here.

Excluded: the context-pressure classes (``compression_exhausted``, ``compression_deferred``,
``failure_reason == "context_overflow"``) â€” appending to an already-oversized session is the
#1630 growth loop; their repair is rotation or a retry. Idempotence is keyed on the DURABLE
tail (``SessionDB.latest_conversation_role``), so a redelivery or a tail already closed by
another writer is a no-op, and the gateway's own closer then no-ops in turn.
r}  TNrG  r:  r€  rD  rh   r›  rý   r®  Fr¼  rn   rÈ   rp   Údisplay_kindÚdisplay_metadataz failed-turn boundary not writtenrT   )rX   rx   ry   rW   r‡   Úlatest_conversation_roler.   rH   rª   r/   r-   rY  r   Ú_flush_messages_to_session_dbrZ   r[   r\   )	rB   ré  rh   Údbrý   ÚstartÚturn_messagesÚboundaryÚfailures	   &&       rL   rN  rN  a  so  € ð$HÜ˜&¤$×'Ò'¨6¯:©:°kÓ+BÀdÓ+JÙà�J‰JÐ.×/Ò/°6·:±:Ð>T×3UÒ3UØ�z‰zÐ*Ó+Ð/AÔAáØ—:‘:˜jÓ)ˆÜ  ¨°tÓ<¼gÀeÈ\Ð[_Ó>`ˆJÜ˜(¤D×)Ò)·¸RºZÏzÙÜ�5Ð-¨u×5Ò5¸×9TÑ9TÐU_Ó9`Ôh|Ô9|Ùð —
‘
Ð2Ó3ˆÜ,6°u¼c×,BÒ,BÀqÈEÖGaÔTWÐX`ÓTa×Ga˜ Ñ(Ðgoˆà�K Ô,>¸}Ó,MÈ~Ô_wð
ˆô 4°EÓBÐBˆ7ÖBØ+2Ð'Ñ(Ü�xÔ*Ø×+Ñ+¨HÖ5øÜô HÜ�‰Ð7À$ˆ×GðHús<   ‚+F ¯F ÁF ÁF Á5AF Â=F Ã-F Ã:BF Æ"F2Æ1F2rO  >   Úmessage_contentÚmessage_sanitizationÚagent_runtime_helpersr–   rƒ  râ   r_  i   )Úlock>   r¸  rh   r‚   r·  r»  rº  rV  rß  r¹  r¼  r¶  r½  )NNNNNNNNNNNNN)ËÚ__conditional_annotations__rß  Ú
__future__r   rê  r¯  ÚloggingÚrert   Údataclassesr   r   r   Útypingr   r   r   r	   Ú(agent.agent_runtime_helpers_placeholdersr
   rV   r   Úagent.fast_moder   r%  Úagent.message_metadatar   r   Úagent.message_sanitizationr   r   rc  r   r   Úagent.process_bootstrapr   rÜ  r   r   r{  r   r   r   r   Úagent.repetition_guardr   r   Úagent.runtime_cwdr   Úagent.surface_switchr   r   r   r    rL  r!   r"   Ú2hermes_cli.observability.shared_metrics_efficiencyr#   r$   Úagent.turn_retry_stater%   Úagent.turn_scripted_preluder&   r'   Úagent.turn_api_callr(   r)   r*   Úagent.turn_api_errorr+   Úagent.turn_api_requestr,   Úagent.turn_failure_copyr-   r.   r/   r0   Úagent.turn_final_responser1   Úagent.turn_finalizerr2   Úagent.turn_iteration_prepr3   r4   r5   r6   Úagent.turn_loop_errorsr7   Úagent.turn_preflight_gater8   Úagent.turn_request_assemblyr9   Úagent.turn_response_checkr:   Úagent.turn_response_intaker;   Úagent.turn_tool_roundr<   Úhermes_loggingr=   Útools.skill_provenancer>   Úutilsr?   Ú	getLoggerrÛ  r[   ÚcompileÚ_STALE_MARKER_RErË   rz   r^   rf   r   rŠ   rŽ   Ú_HANDOFF_SKIP_FINAL_RESPONSEr:  Ú"INTERRUPT_WAITING_FOR_MODEL_PREFIXr•   Ú	frozensetÚ_LOCAL_PROCESSING_MODULESÚ_API_CALL_MODULESÚ_MAX_OUTER_LOOP_ERRORSr�   r¥   r«   r³   r¾   rÃ   rÓ   rÚ   rë   ró   r  r  r  r  r(  r+  r3  r7  rF  rK  rO  ro  r‹  rŽ  rŸ  r¨  r¶  rÉ  rä  rÛ  r÷  rø  Ú(_LEGACY_LENGTH_CONTINUATION_NETWORK_STUBrö  rú  Ú_CODEX_INCOMPLETE_NUDGEÚ_CODEX_ACK_CONTINUATION_NUDGEÚ_DEGENERATE_FINAL_NUDGEÚ_DROPPED_TOOLCALL_NUDGE_CONTENTÚ_EMPTY_TOOL_RESPONSE_NUDGErû  rà  r  r  r  r  r  r!  r'  r.  r3  r?  rJ  rS  rX  r]  ra  rf  r„  r�  rŸ  r¥  r¬  r²  r´  r0  râ  rí  rô  rþ  r  rD  rO  rU  rY  rV  rN  Ú__all__)rp  s   @rL   Ú<module>r¡     sÍ  øðô*õ #ã Û Û Û 	Û ß 0Ñ 0ß ,Ó ,å UÝ IÝ >ß Mß Xß UÝ 7ß U÷ó ÷ VÝ /÷ó ÷ Pß hÝ 1ß =÷ ^Ñ ]Ý 1Ý 4ß qÓ qÝ :Ý .÷ó õ ;Ý 8Ý <Ý 8Ý ?Ý 0Ý .Ý ;Ý 'à	×	Ò	˜8Ó	$€ð —:’:Ð?Ó@Ð ð UÐ ð
_ð õ]õ:	Sõ õFõ$	ð& _ð ðjð $ð &[Ð "õñ &ò 'ó Ð ñ Ð8Ð9Ó:Ð ð Ð õõ;ð Ð õBõ8õ
õ'%õT

õõõ<õ<ò0ðÀ%÷ õ&õIõ
õð5ØUZ÷5ñpÐUZ÷ ð õ6÷.ðb#à"ð#ð AQ÷#ðLØ\a÷õ$ðN?ÐQV÷ ?õ"õ,.ò>Kõ\ðBEð "ð\ð "ð\ð )ð
 -PÐ )÷gð"6ð ð"ð ðBð ðNð  ð0ð ð %'Ð �>Ó &ØÐ Ø.Ð ØÐ õò*õ#õ.Iõ	õ÷ õFõ8ò(
ò ÷gõ7ð1-ØAEð1-à-1ð1-àcg÷1-õhõ/ðd
ØUY÷
ò&4õð& ÷O"ð O"ó ðO"ñf ò ó €ð #%€ÐÓ $ð .©yÐ:_Ð9`Ó/aÐbÐ õõ*õ@÷$_÷D9ðx  $Ð õ.õ&8õ,,Hð^ Ð
‚rN   