+
    iHàjÉ   ã                  óº  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHt ^ RIHt ^ RIHt ^ RI H!t! ]PD                  ! R4      t#0 REmt$]PJ                  ! R]PL                  4      t']! R4      t(](t)Rt*RR/R R llt+RFt,R R lt-]-! RRR4      t.]-! RRR4      t/Rt0Rt1Rt2R  R! lt3R" R# lt4RGR$R%R&R%/R' R( lllt5] ! R) R*4      4       t6]! R+R,7       ! R- R.]64      4       t7R/ R0 lt8R1 R2 lt9R3 R4 lt:R5 R6 lt;RGR7 R8 llt<R9 R: lt=R; R< lt>RHt?R=t@R>R/R? R@ lltA] ! RA RB4      4       tBRC RD ltCR# )Ia  Truncation recovery (``finish_reason == "length"``) for the conversation turn loop.

Handles thinking-budget exhaustion, repetition-dominated truncation, content-filter stream
stalls escalated to the fallback chain, text continuation nudges (up to 4, with the ceiling
exit that drops the fragment trail), truncated tool-call retries with max_tokens boosts, and
the final roll-back. Nothing here imports ``agent.conversation_loop`` at module level
(cycle); loop-internal helpers are imported lazily so tests patching them keep working.
)ÚannotationsN)Ú	dataclass)ÚAnyÚDictÚListÚOptionalÚTuple)ÚFailoverReason)Úappend_message)Úclose_interrupted_tool_sequence)Úis_repetition_dominated)Ústop_thinking_spinner)Úcontent_policy_copyÚprovider_label_forÚ	site_copyÚstamp_failure)ÚTurnRetryState)Únormalize_usage)ÚPARTIAL_STREAM_STUB_IDzagent.conversation_loopz8<(?:think|thinking|reasoning|REASONING_SCRATCHPAD)[^>]*>Ú	truncatedz¬The request no longer fits the model's context window, so the partial response was not continued. Continue in a fresh session (/new; gateway chats are reset automatically).Úpartsc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )é   Úagentr   Úmessagesúlist[dict[str, Any]]Úcurrent_turn_user_idxÚfinish_reasonÚstrr   zOptional[list[str]]Úreturn© )Úformats   "Ú:/home/ubuntu/.hermes/hermes-agent/agent/turn_truncation.pyÚ__annotate__r#   -   s>   € ÷ /ñ /Øð/Ø.ð/ØGJð/àð/à2ð/ð 	ñ/ó    c          	     ó  € Tp\        V\        4      ;'       d    V^ 8¬  pVf   V'       d   V\        V4      8  g   R# V'       d
   V^,           M^ p. p. p	Rp
WR  F³  p\        V\        4      '       dŠ   VP	                  R4      '       g   VP	                  R4      '       d\   Rp
VP	                  R4      pVP	                  R4      '       d0   \        V\
        4      '       d   V'       d   VP                  V4       K¢  V	P                  V4       Kµ  	  Vf   V
'       g   R# Y‘VR% ^ RIHp Vf   TMTp. pV FŽ  p\        V\        4      '       dA   \        V4      ^8X  d1   \        V^ ,          \
        4      '       d   VP                  V4       KY  \        V\
        4      '       g   Kq  V'       g   K{  VP                  VR34       K�  	  V P                  V! V4      4      P                  4       pV'       d   \        VR	R
RVRV/4       Wn        V# )u   Drop this turn's ``_length_continuation_fragment``/``_nudge`` rows and append one
assistant row holding the joined, think-stripped partial; returns that text ("" none).

``parts=None`` (retry exhaustion, #119001): the text comes from the fragment rows and
nothing happens without a valid turn index or a trail â€” an unanswered synthetic nudge
must never be persisted, and an earlier turn's rows must never be read. Explicit
``parts`` (the continuation ceiling) always appends, scanning from 0 without an index.
NÚ FÚ_length_continuation_fragmentÚ_length_continuation_nudgeTÚcontent)Ú_join_truncated_partsÚroleÚ	assistantr   )Ú
isinstanceÚintÚlenÚdictÚgetr   ÚappendÚagent.conversation_loopr*   ÚtupleÚ_strip_think_blocksÚstripr
   Ú_session_messages)r   r   r   r   r   ÚidxÚ	valid_idxÚ
turn_startÚfragment_partsÚretainedÚfound_trailÚmessager)   r*   ÚrawÚ
join_partsÚitemÚpartials   &&&$$             r"   Úcollapse_continuation_trailrC   -   s´  € ð  €CÜ˜3¤Ó$×1Ð1¨°©€IØ‚}Ÿi¨C´#°h³-Ô,?Ùß%��q–¨1€JØ "€NØ€HØ€KØ˜KÓ(ˆÜ�gœt×$Ò$Ø�K‰KÐ7×8Ò8¸G¿K¹KÐHd×<eÒ<eàˆKØ—k‘k )Ó,ˆGØ�{‰{Ð:×;Ò;Ä
È7ÔTW×@XÒ@X×]dØ×%Ñ% gÔ.ÙØ�‰˜Ö ñ )ð ‚}Ÿ[ÙØ$ˆZˆ[ÐÝ=Ø!šM‰.¨u€CØ€JÛˆÜ�dœE×"Ò"¤s¨4£y°A¤~¼*ÀTÈ!ÅWÌc×:RÒ:RØ×Ñ˜dÖ#Ü˜œc×"Ô"§t¡tØ×Ñ˜t U˜mÖ,ñ	 ð
 ×'Ñ'Ù˜jÓ)óç�eƒgð ÷ Ü�x &¨+°yÀ'È?Ð\iÐ!jÔkØ&ÔØ€Nr$   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ústoppingr   ÚoutcomeÚrefusalr   ztuple[str, str, str]r    )r!   s   "r"   r#   r#   i   s)   € ÷ 	ñ 	˜cð 	¨Cð 	¸#ð 	ÐBVñ 	r$   c                ó$   € RV  R2RV R2RV R23# )zŸ(log line, user copy, error) for a repetition-dominated abort; only the clauses naming
where the turn stopped differ between the length path and the stop path.u6   ðŸ”� Response dominated by repeated text â€” stopping Ú.ux   âš ï¸� **Response Stopped â€” Repetition Detected**

The model fell into a repetition loop while writing this response, us   

â†’ Switch to a different model with `/model`
â†’ Or resend your message (your conversation history is preserved)z&Model output entered a repetition loopz degenerate response.r    )rE   rF   rG   s   &&&r"   Úrepetition_copyrJ   i   s@   € ð AÀÀ
È!ÐLð	"Ø") ð +Nð	Nð 1°°	Ð9NÐOðð r$   z+instead of continuing a degenerate responsezXso continuing would only produce more repeated text. The partial response was discarded.z3 and was truncated mid-loop; refusing to continue azthe stream mid-loopzTso the stream was stopped instead of running on. The partial response was discarded.z0 and the stream was cut mid-loop; discarding theu  âš ï¸� **No visible answer was produced.** The model hit its output-token limit on every continuation attempt â€” its reasoning consumed the entire budget each time.

To fix this:
â†’ Lower reasoning effort: `/reasoning low` or `/reasoning none`
â†’ Or raise max_tokens for this modeli   uV  âš ï¸� **Context window full.** The prompt used {prompt:,} of this model's {ctx:,}-token context window, leaving no room to answer in. This is a context-window limit, not an output-length limit.

To fix this:
â†’ Compress the conversation with `/compress` or start a new session
â†’ Or raise the model's context window (e.g. Ollama `num_ctx`)c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Úresponser   úOptional[tuple[int, int]]r    )r!   s   "r"   r#   r#   �   s'   € ÷ 	[ñ 	[ ð 	[°ð 	[Ð8Qñ 	[r$   c           	     ó(  € \        \        \        V RR4      R^ 4      ;'       g    ^ 4      p\        VRR4      pV'       d	   V'       g   R# \        W0P                  V P                  R7      P
                  pV'       d   W$,
          \        8  d   WB3# R# )zé``(prompt_tokens, context_length)`` when this response's usage shows the prompt left
less than ``_MIN_CONTINUATION_HEADROOM`` in the window compression resolves for the
model; ``None`` (keep continuing) when either number is unknown.Úcontext_compressorNÚcontext_lengthÚusage)ÚproviderÚapi_mode)r.   Úgetattrr   rR   rS   Úprompt_tokensÚ_MIN_CONTINUATION_HEADROOM)r   rL   ÚctxrQ   Úprompts   &&   r"   Ú_prompt_filled_windowrY   �   sv   € ô Œg”g˜eÐ%9¸4Ó@ÐBRÐTUÓV×[Ð[ÐZ[Ó
\€CÜ�H˜g tÓ,€Eß—EÙÜ˜U¯^©^ÀeÇnÁnÔU×cÑc€Fß" s¥|Ô6PÔ'PˆFˆ=ÐZÐVZÐZr$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   rL   r   r    )r!   s   "r"   r#   r#   ›   s!   € ÷ ?ñ ?¨ð ?°sð ?¸sñ ?r$   c                ó¶   € V P                   R8X  d+   V P                  4       P                  WP                  R7      # V P                  4       P                  V4      # )zTOne OpenAI-style message from any transport; Anthropic strips the OAuth tool prefix.Úanthropic_messages)Ústrip_tool_prefix)rS   Ú_get_transportÚnormalize_responseÚ_is_anthropic_oauth)r   rL   s   &&r"   Únormalize_response_for_agentra   ›   sU   € à‡~�~Ð-Ô-Ø×#Ñ#Ó%×8Ñ8Ø×(AÑ(Að 9ó 
ð 	
ð ×ÑÓ!×4Ñ4°XÓ>Ð>r$   ÚfailedFÚcompression_exhaustedc               ó4   € V ^8„  d   QhRRRRRRRRR	R
RR
RR/# )r   r   r   Úapi_call_countr.   Úfinal_responser   ÚerrorúOptional[str]rb   Úboolrc   r   zdict[str, Any]r    )r!   s   "r"   r#   r#   ¤   sF   € ÷ ñ Ø"ðØ47ðØILðàðà,0ðàQUðð ñr$   c               ó\   € RTRT RTRRV'       d   RMRRR	Vf   TMT/pV'       d   RVR
&   V# )zôTyped incomplete-turn result (``partial`` unless ``failed``); ``error`` defaults to
``final_response``. ``compression_exhausted`` carries the #98722 typed bit the gateway
consumes to reset/move future input to a clean session (see run_turn.py).rf   r   Ú	api_callsÚ	completedFrb   rB   Trg   rc   r    )r   re   rf   rg   rb   rc   Úresults   &&&&$$ r"   Úpartial_resultrn   ¤   sH   € ð 	˜.Ø�HØ�^Ø�Uß‰ ¨TØ 5¢=‘°eð€F÷ Ø*.ˆÐ&Ñ'Ø€Mr$   c                  ól   € ] tR t^¸t$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   R]R&   R]R&   R]R&   RtR# )ÚTruncationVerdictu…  Outcome of ``recover_from_truncation``.

``action``: ``"return"`` (end the turn with ``result``), ``"break"`` (a
``_retry.restart_with_*`` flag is set â€” restart the API call), ``"continue"``
(re-issue the same call immediately) or ``"fallthrough"`` (unreachable in practice:
every path exits, kept for the contract). The remaining fields are the loop locals
the handler may have rebound.r   ÚactionúOptional[dict[str, Any]]rm   r   r   r.   Úlength_continue_retriesúlist[tuple[str, bool]]Útruncated_response_partsÚtruncated_tool_call_retriesÚretry_countÚcompression_attemptsr    N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r    r$   r"   rp   rp   ¸   s8   ‡ ñ%ð ƒKØ$Ó$Ø"Ó"Ø Ó Ø4Ó4Ø!$Ó$ØÓØ×r$   rp   T)Úkw_onlyc                  óÚ   € ] tR t^Ìt$ Rt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!R R llt	R!RRRRRRRRRR"/R R lllt
]R R l4       tR tR# )#Ú_Truncu¦   Working state for the truncation phases â€” the verdict itself, plus the read-only
call context; phases mutate the loop-local fields and ``done()`` stamps the action.r   r   rL   r   r   Úconversation_historyr.   re   Úeffective_task_idr   Úfallthroughrq   Nrr   rm   rM   Úwindow_filledc               ó$   € V ^8„  d   QhRRRRRR/# )r   rq   r   rm   rr   r   rp   r    )r!   s   "r"   r#   Ú_Trunc.__annotate__Ü   s#   € ÷ ñ ˜3ð Ð(@ð ÐL]ñ r$   c                	ó"   € WuV n         V n        V # ©N©rq   rm   )Úselfrq   rm   s   &&&r"   ÚdoneÚ_Trunc.doneÜ   s   € Ø#)Ð ˆŒ�T”[Øˆr$   Úresult_messagesÚcleanupTrb   Frc   Úfailurec               ó8   € V ^8„  d   QhRRRRRRRRR	RR
RRRRR/# )r   rf   r   rg   rh   r�   zOptional[list[dict[str, Any]]]r‘   ri   rb   rc   r’   ztuple[str, bool]r   rp   r    )r!   s   "r"   r#   r‰   à   sT   € ÷ ñ Ø!ðØ*7ðà7ðàIMðð ðð 6:ðð "ð	ð
 
ñr$   c               ó4  € V P                   pV'       d   VP                  V P                  4       VP                  V P                  V P
                  4       T P                  R\        \        Vf   V P                  MTV P                  WWVR7      .VO5!  4      # )a  Persist and end the turn as partial (or ``failed``).

``compression_exhausted`` forwards the #98722 typed bit so the gateway can
move future input off a bloated session (run_turn.py consumes it). ``failure`` is
the ``(failure_reason, retryable)`` verdict for the UI descriptor.
r   )rb   rc   )
r   Ú_cleanup_task_resourcesr…   Ú_persist_sessionr   r„   rŽ   r   rn   re   )	r�   rf   rg   r�   r‘   rb   rc   r’   r   s	   &&&$$$$$ r"   Úend_turnÚ_Trunc.end_turnà   s„   € ð —
‘
ˆßØ×)Ñ)¨$×*@Ñ*@ÔAØ×Ñ˜tŸ}™}¨d×.GÑ.GÔHØ�y‰y˜¤=´Ø,Ò4ˆD�MŠM¸/È4×K^ÑK^Ø¨&ô2
ð $ð ó$ó ð 	r$   c               ó   € V ^8„  d   QhRR/# )r   r   ri   r    )r!   s   "r"   r#   r‰   ö   s   € ÷ Jñ J˜ñ Jr$   c                	ó>   € \        V P                  R R4      \        8H  # )Úidr&   )rT   rL   r   )r�   s   &r"   Úis_stubÚ_Trunc.is_stubõ   s   € ä�t—}‘} d¨BÓ/Ô3IÑIÐIr$   rŒ   r‹   )r   T)rz   r{   r|   r}   r~   r   rq   rm   r‡   rŽ   r—   Úpropertyrœ   r€   r    r$   r"   rƒ   rƒ   Ì   s¦   ‡ ñ[ð ƒJØƒMØÓØÓØÓØÓØÓØ€FˆCÓØ'+€FÐ$Ó+Ø/3€MÐ,Ó3÷ñà:>ðàPTðð ðð =Bðð %8÷	ð ð* ôJó ôJr$   rƒ   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r   r)   Úhas_tool_callsri   r   zOptional[tuple]r    )r!   s   "r"   r#   r#   ú   s(   € ÷ ñ ˜ð  sð ¸Dð À_ñ r$   c                ó*  € V'       d   R# V'       d9   \         P                  V4      '       d   V P                  V4      '       g   \        # \	        V\
        4      '       d   V P                  V4      MTpV'       d   \        V4      '       d   \        # R# )u2  ``(vprint, user response, error)`` when continuation must NOT be attempted:
thinking exhausted the budget (reasoning blocks with no visible text after them â€”
``content=None`` from non-<think> models is normal truncation), or a repetition loop
burned the budget on one fragment (reasoning stripped first).N)	Ú_THINK_TAG_REÚsearchÚ_has_content_after_think_blockÚ_THINKING_EXHAUSTEDr-   r   r5   r   Ú_REPETITION_DOMINATED)r   r)   r    Úvisibles   &&& r"   Ú_abort_reasonr¨   ú   sj   € ÷
 Ùß”=×'Ñ'¨×0Ò0¸×9]Ñ9]Ð^e×9fÒ9fÜ"Ð"Ü4>¸wÌ×4LÒ4Lˆe×'Ñ'¨Ô0ÐRY€GßÔ*¨7×3Ò3Ü$Ð$Ùr$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ústrƒ   Ú_retryr   r   zOptional[TruncationVerdict]r    )r!   s   "r"   r#   r#   	  s"   € ÷ %ñ % ð %°ð %ÐD_ñ %r$   c                ó  € V P                   p\        V P                  RR4      '       d%   VP                  \	        VP
                  4      8  g   R# VP                  VP                   R2RRR7       VP                  R4       VP                  4       '       dÎ   V P                  '       d!   VP                  V P                  4      V n        V P                   F?  p\        V\        4      '       g   K  VP                  RR4       VP                  R	R4       KA  	  V P                  Vn        ^ V n        . V n
        ^ V n        ^ V n        RVn        RVn        V P-                  R
4      # VP                  VP                   R2RRR7       R# )uÛ   Content-filter stream stall â†’ fallback. ``_content_filter_terminated`` is
content-deterministic, so escalate before retrying the primary; without a fallback
fall through to normal continuation (best-effort, may loop).Ú_content_filter_terminatedFNuM   ðŸ›¡ï¸�  Content filter terminated stream â€” activating fallback provider...T©ÚforceÚ
diagnosticz:Content filter terminated stream; switching to fallback...r'   r(   Úbreaku^   âš ï¸�  No fallback provider configured â€” retrying with same provider (may re-hit filter)...)r   rT   rL   Ú_fallback_indexr/   Ú_fallback_chainÚ_vprintÚ
log_prefixÚ_emit_diagnostic_statusÚ_try_activate_fallbackru   Ú"_get_messages_up_to_last_assistantr   r-   r0   Úpopr7   rs   rw   rx   Úprimary_recovery_attemptedÚrestart_with_rebuilt_messagesrŽ   )rª   r«   r   Ú_frags   &&  r"   Ú_content_filter_fallbackr½   	  s_  € ð �H‰H€Eä�—‘Ð9¸5×AÒAØ×!Ñ!¤C¨×(=Ñ(=Ó$>Ô>áØ	‡M�MØ×ÑÐ
ÐiÐjØ˜tð ô ð 
×!Ñ!Ð"^Ô_Ø×#Ñ#×%Ò%ð ×&×&Ð&Ø×BÑBÀ2Ç;Á;ÓOˆBŒKØ—[”[ˆEÜ˜%¤×&Ô&Ø—	‘	Ð9¸4Ô@Ø—	‘	Ð6¸Ö=ñ !ð #%§+¡+ˆÔØ%&ˆÔ"Ø&(ˆÔ#ØˆŒØ"#ˆÔØ,1ˆÔ)Ø/3ˆÔ,Ø�w‰w�wÓÐØ	‡M�MØ×ÑÐ
ð !ð 	"à˜tð ô ñ
 r$   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   rª   rƒ   r«   r   Úassistant_messager   r   rp   r    )r!   s   "r"   r#   r#   1  s/   € ÷ Añ A�vð A ~ð AÈ#ð AÐRcñ Ar$   c           
     ó¾  € ^ RI HpHp V P                  pV P                  pV ;P
                  ^,          un        V P
                  p\        VRR4      pV'       g   V P                  '       g   RVn        V'       dR   VP                  W P                  4      p	RV	R&   \        Wi4       V P                  P                  W€P                  34       V P                  p
V^8  Ed   V
Ef	   \        V P                  RR4      pV P                  '       dF   V'       d>   VP!                  VP"                   RRP%                  VR	,          4       R
V R2RR7       MYV P                  '       d%   VP!                  VP"                   RV R2RR7       M#VP!                  VP"                   RV R2RR7       \        VRRRV! V P                  V4      RR/4       Wen        RVn        V P+                  R4      # \-        WVV P.                  RV P                  R7      pRVn        TP!                  V
e   VP"                   R2M"VP"                   RV R2V'       d   RMR,           RRR7       V
e\   \0        P3                  V
^ ,          V
^,          R7      pT P5                  V'       d   V RV 2MTRV
^ ,           RV
^,           R 24      # T P5                  T;'       g    \6        R!4      # )"u%  Text truncation (no tool calls): append the fragment + a continuation nudge (up to
4), then the ceiling exit that drops the fragment trail and keeps the stitched partial.
Never appends an interim assistant row with NO visible content â€” strict providers
reject it with 400 â€” only the nudge.)Ú_get_continuation_promptr*   r)   NTr'   Ú_dropped_tool_namesu&   â†» Stream interrupted mid tool-call (z, :Né   Nu    ) â€” requesting chunked retry (ú/4)...©r°   u4   â†» Stream interrupted â€” requesting continuation (u   â†» Requesting continuation (r+   Úuserr(   r±   Úlength)r   r   FuC   âš ï¸�  Not continuing â€” each attempt would only grow the prompt.u'   âš ï¸�  Response still truncated after u    continuation attempts â€” z-keeping the partial response received so far.zno visible text was produced.r®   )rX   rW   z

zPrompt used z of z" context tokens; no room to answerz9Response remained truncated after 4 continuation attempts)r3   rÁ   r*   r   r   rs   rT   rœ   Ú_ephemeral_reasoning_offÚ_build_assistant_messager   r
   ru   r2   r‡   rL   r´   rµ   Újoinr7   Ú restart_with_length_continuationrŽ   rC   r   Ú_WINDOW_FILLEDr!   r—   Ú_CEILING_NO_TEXT)rª   r«   r¿   rÁ   r*   r   r   ÚnÚ_interim_contentÚinterim_msgÚfilledÚ_dropped_toolsÚpartial_responseÚnotices   &&&           r"   Ú_continue_textrÕ   1  sÐ  € ÷
 Xà�H‰H€EØ�{‰{€HØ×Ò !Õ#ÕØ
×"Ñ"€AÜÐ0°)¸TÓBÐß B§J§J Jà)-ˆÔ&ßØ×4Ñ4Ð5F×HXÑHXÓYˆØ7;ˆÐ3Ñ4Ü�xÔ-Ø
×#Ñ#×*Ñ*Ð,<¿j¹jÐ+IÔJà×Ñ€FØˆ1…u�“Ü  §¡Ð.CÀTÓJˆØ�:�:ˆ:Ÿ.Ø�M‰MØ×#Ñ#Ð$ð %Ø"Ÿi™i¨°rÕ(:Ó;Ð<Ð<\Ð]^Ð\_Ð_eðgØswð õ ð �Z�ZˆZØ�M‰M˜U×-Ñ-Ð.Ð.bÐcdÐbeÐekÐlÐy}ˆMÕ~à�M‰M˜U×-Ñ-Ð.Ð.KÈAÈ3ÈfÐUÐbfˆMÔgÜ�xØ�F˜IÑ'?ÀÇ
Á
ÈNÓ'[Ø(¨$ð"
ô 	ð #+ÔØ26ˆÔ/Ø�w‰w�wÓÐô 3Ø˜×1Ñ1ÀØ×)Ñ)ôÐð
 &+€EÔ"Ø	‡M�MàÒð ×ÑÐ
Ð_Ñ`à×ÑÐ
ÐCÀAÀ3ÐFaÐbß>NÑ:Ø/õ	1ð ˜tð ô ð ÒÜ×&Ñ&¨f°Q­i¸VÀA½YÐ&ÓGˆØ�{‰{ß1AÐÐ   V HÑ-ÀvØ˜6 !�9˜+ T¨&°­)¨Ð4VÐWó
ð 	
ð �;‰;Ø×,Ð,Ô,ØCóð r$   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   úOptional[int]r    )r!   s   "r"   r#   r#   u  s   € ÷ Jñ J˜sð J }ñ Jr$   c                óp   € \        V RR4      R8w  d   R# ^ RIHp T! \        V RR4      ;'       g    R4      # )zCThe model's real max output tokens when Hermes knows it, else None.rS   Nr\   )Ú_get_anthropic_max_outputÚmodelr&   )rT   Úagent.anthropic_adapterrÙ   )r   rÙ   s   & r"   Ú_model_output_limitrÜ   u  s6   € äˆu�j $Ó'Ð+?Ô?ÙåAÙ$¤W¨U°G¸TÓ%B×%HÐ%HÀbÓIÐIr$   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   r   r   Úrequested_capr×   rÎ   r.   Úbaser   r    )r!   s   "r"   r#   r#   ~  s0   € ÷ 1ñ 1˜cð 1°-ð 1ÀCð 1È}ð 1Ðhkñ 1r$   c                ó@  € Vf!   V P                   ;'       g    T;'       g    RpT;'       g    Tp\        V 4      pV'       d	   WE8¼  d   V# \        \        V^V,          ,          T;'       g    ^ 4      \        RV^,          4      4      pV'       d   \        We4      # T# )u‡  Output budget for truncation retry ``n`` (1-based): ``baseÂ·2â�¿``, never below the
failed request's cap, at most ``max(32768, 2Ã—cap)``, and never above the model's
known output limit. ``base`` defaults to max_tokens, else the cap actually sent.

A ceiling equal to the requested cap would re-send the same budget (#72770); a
ceiling past the model limit only buys a provider 400 (#79715).
é   i €  )Ú
max_tokensrÜ   ÚminÚmax)r   rÞ   rÎ   rß   ÚanchorÚlimitÚboosts   &&&&   r"   Úboosted_output_caprè   ~  s‡   € ð ‚|Ø×Ñ×8Ð8 =×8Ð8°DˆØ×"Ð"˜d€FÜ Ó&€Eß�”ØˆÜ”�D˜A �F•O ]×%7Ð%7°aÓ8¼#¸eÀVÈaÅZÓ:PÓQ€Eß %Œ3ˆuÓÐ0¨5Ð0r$   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rª   rƒ   Ú
api_kwargsr   r   rp   r    )r!   s   "r"   r#   r#   �  s"   € ÷ -ñ - 6ð -°sð -Ð?Pñ -r$   c                óH  € V P                   pV P                  ^8  d”   V ;P                  ^,          un        V P                  pV P                  '       d   VP                  RV R24       MVP                  RV R24       \	        W"P                  V4      V4      Vn        V P                  R4      # VP                  4        V P                  '       d   \        P                  P                  MRpV P                  '       db   \        V P                  RR4      '       dE   VP                  VP                   R2R	R	R
7       \!        R\#        VP$                  4      R7      pRpM{V P                  '       dC   VP                  VP                   R2R	R	R
7       \!        R\#        VP$                  4      R7      pM'VP                  VP                   R2R	R	R
7       \&        pVP)                  V P*                  4       \-        V P.                  V4       V P1                  VRVR	3R7      # )uÈ   Truncated tool call: re-run the same call (up to 4Ã—) with a boosted max_tokens â€”
a real output-cap truncation needs it, harmless for a network stall â€” else refuse to
execute incomplete arguments.u7   âš ï¸�  Stream interrupted mid tool-call â€” retrying (rÄ   u<   âš ï¸�  Truncated tool call detected â€” retrying API call (Úcontinuer   Ú
_clean_eofFue   âš ï¸�  Server kept closing the stream mid tool-call after 4 retries â€” the action was not executed.Tr®   Ústream_closed_tool_call)Úlabelu[   âš ï¸�  Stream kept dropping mid tool-call after 4 retries â€” the action was not executed.Ústream_dropped_tool_calluf   âš ï¸�  Truncated tool call response detected again â€” refusing to execute incomplete tool arguments.)r‘   r’   )r   rv   rœ   Ú_buffer_vprintrè   Ú%_requested_output_cap_from_api_kwargsÚ_ephemeral_max_output_tokensrŽ   Ú_flush_status_bufferr	   ÚtimeoutÚvaluerT   rL   r´   rµ   r   r   rR   Ú_TRUNCATED_FINALr•   r…   r   r   r—   )rª   rê   r   rÎ   Ú_failureÚ_final_responses   &&    r"   Ú_retry_truncated_tool_callrú   �  sþ  € ð �H‰H€EØ	×%Ñ%¨Ô)Ø
×&Ò&¨!Õ+Õ&Ø×*Ñ*ˆØ�:�:ˆ:Ø× Ñ Ð#ZÐ[\ÐZ]Ð]cÐ!dÕeà× Ñ Ð#_Ð`aÐ_bÐbhÐ!iÔjÜ-?Ø×>Ñ>¸zÓJÈAó.
ˆÔ*ð �w‰w�zÓ"Ð"Ø	×ÑÔ Ø/1¯z¯z¨zŒ~×%Ñ%×+Ò+¸{€HØ	‡z‡z€z”g˜bŸk™k¨<¸×?Ò?ð 	�‰Ø×ÑÐ ð  !Fð  GØ 4ð 	ô 	
ô $Ð$=ÔEWÐX]×XfÑXfÓEgÔhˆØ‰Ø	��ˆØ�‰Ø×ÑÐ Ð {Ð|Ø 4ð 	ô 	
ô $Ð$>ÔFXÐY^×YgÑYgÓFhÔi‰à�‰Ø×ÑÐ ð  !Gð  HØ 4ð 	ô 	
ô +ˆØ	×!Ñ! "×"6Ñ"6Ô7ä# B§K¡K°ÔAØ�;‰;Ø Ø˜4Ð ð ó ð r$   c                óX   € 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RR/# )r   r   r   rL   r   r   r«   r   r   r   r„   rê   re   r.   r…   r   rs   ru   rt   rv   rw   rx   r   rp   r    )r!   s   "r"   r#   r#   À  sÆ   € ÷ ^Kñ ^KØð^KØð^KØ.1ð^KØ;Ið^Kà"ð^Kà:=ð^KàKNð^Kà`cð^Kð ð^Kð 47ð^Kð RUð^Kð 5ð	^Kð TWð	^Kð fið	^Kð
 ð^Kð ñ^Kr$   c               ó$  € \        WVWWW‰WJVWÍVR7      p\        VRR4      '       d?   \        w  pppV P                  V P                   V 2RRR7       VP                  VV4      # \        W4      Vn        VP                  '       d   \        VRR4      '       d   RpMWVP                  '       d   RpMBVP                  '       d/   R	VP                  ^ ,          R
 RVP                  ^,          R
 R2pMRpV P                  V P                   RV 2RRR7       \        VP                  RR4      '       dj   V P                  4        V P                  V P                   R2RRR7       \        VP                  \        4       VP                  \        \        RRRR7      # \        W4      pV'       d   \        VRR4      MRpV'       d   \        \        VRR4      4      MRp\!        V VV4      pVe;   Vw  pppV P                  V P                   V 2RRR7       VP                  VV4      # V P"                  \$        9   d5   \'        Wó4      pVe   V# Ve    V'       g   \)        WóV4      # \+        Wö4      # \-        V4      ^8”  dG   V P                  V P                   R2RR7       VP                  \.        V P1                  V4      R7      # V P                  4        V P                  V P                   R2RRR7       VP                  \2        RRR7      # )aJ  Recover from a truncated response. Order is load-bearing: thinking exhaustion and
repetition abort BEFORE any continuation; a content-filter stall escalates to the
fallback chain BEFORE the primary is retried; text continuation (no tool calls) then
truncated tool-call retry; finally roll back to the last complete assistant turn.)r   rL   r   r„   re   r…   r   r   rs   ru   rv   rw   rx   Ú_runaway_repetitionFTr®   rí   uš   Response truncated â€” server ended the stream without ever sending finish_reason (no transport error â€” the server or a proxy closed the stream cleanly)u5   Response truncated â€” stream ended before completionzTResponse truncated (finish_reason='length') - the prompt filled the context window (Ú,Ú/z tokens)zIResponse truncated (finish_reason='length') - model hit max output tokensu   âš ï¸�  Ú_overflow_terminalu’   âš ï¸� Stream ended on a context-overflow error after partial delivery â€” not continuing (the request no longer fits the model's context window).)rg   rb   rc   r’   r)   NÚ
tool_callsu3      â�ª Rolling back to last complete assistant turnrÅ   )r�   u-   â�Œ First response truncated - cannot recover)r‘   rb   )Úcontext_overflowF)rƒ   rT   Ú_REPETITION_STREAM_CUTr´   rµ   r—   rY   r‡   rœ   rL   rô   r   r   Ú_CONTEXT_OVERFLOW_PARTIAL_FINALra   ri   r¨   rS   Ú_CONTINUABLE_MODESr½   rÕ   rú   r/   r÷   r¸   Ú_FIRST_TRUNCATED_FINAL)r   rL   r   r«   r   r„   rê   re   r…   r   rs   ru   rv   rw   rx   rª   ÚlineÚuser_responserg   Ú_bannerÚ
_trunc_msgÚ_trunc_contentÚ_trunc_has_tool_callsÚabortÚcfs   &&&&$$$$$$$$$$$          r"   Úrecover_from_truncationr  À  s  € ô 
Ø°mØ1Ø+ØØ!9Ø$?Ø1ô
€Bô ˆxÐ.°×6Ò6ô &<Ñ"ˆˆm˜UØ�‰˜×)Ñ)Ð*¨4¨&Ð1¸È$ˆÔOØ�{‰{˜=¨%Ó0Ð0Ü,¨UÓ=€BÔØ	‡z‡z€z”g˜h¨°e×<Ò<ð^‰à	��ˆØI‰Ø	×	×	Ð	ðØ×'Ñ'¨Õ*¨1Ð-¨Q¨r×/?Ñ/?ÀÕ/BÀ1Ð.EÀXðO‰ð ^ˆØ	‡M�M�U×%Ñ%Ð& h¨w¨iÐ8ÀÐQU€MÔVô ˆr�{‰{Ð0°%×8Ò8Ø×"Ñ"Ô$Ø�‰Ø×ÑÐ ð !ð ð  4ð	 	ô 	
ô 	(¨¯©Ô5TÔUð �{‰{Ü+Ü1ØØ"&Ø/ð ó 
ð 	
ô .¨eÓ>€Jß=G”W˜Z¨°DÔ9ÈT€NßMWœD¤¨°\À4Ó!HÔIÐ]bÐä˜% Ð1FÓG€EØÒØ%*Ñ"ˆˆm˜UØ�‰˜×)Ñ)Ð*¨4¨&Ð1¸È$ˆÔOØ�{‰{˜=¨%Ó0Ð0à‡~�~Ô+Ô+Ü% bÓ1ˆØŠ>ØˆIØÒ!ß(Ü% b°*Ó=Ð=Ü-¨bÓ=Ð=ä
ˆ8ƒ}�qÔØ�‰˜×)Ñ)Ð*Ð*]Ð^ÐkoˆÔpØ�{‰{Ü¨e×.VÑ.VÐW_Ó.`ð ó 
ð 	
ð 
×ÑÔ Ø	‡M�M�U×%Ñ%Ð&Ð&SÐTÐ\`Ðmq€MÔrØ�;‰;Ô-°uÀTˆ;ÓJÐJr$   Úcodex_fallback_activatedrL   c               ó8   € 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„   re   r.   rL   r   zOptional[Any]r    )r!   s   "r"   r#   r#   +  sX   € ÷ Lñ LØðLØ#&ðLØ7:ðLØI]ðLàðLà/2ðLà>AðLð ñLr$   c          
     óR  € ^ RI Hp ^ RIHp V ;P                  ^,          un        V P                  p	V P                  W4      p
\        V
P                  R4      ;'       g    RP                  4       4      pV
P                  R4      p\        V\        4      ;'       d    \        VP                  4       4      p\        V
P                  R4      4      p\        V
P                  R4      4      pV'       * ;'       d    \        VRR	4      '       * pV'       d   V P                  ^,           M^ V n        V P                  pV'       g   V'       g   V'       g
   V'       Ed’   V'       d
   VR ,          MR	p\        V\        4      pV'       d   V P                  V4      MRpV P                  V
4      pV'       g	   V'       d   VV8H  pM€T;'       dw    VP                  R4      ;'       g    RV
P                  R4      ;'       g    R8H  ;'       d8    VP                  R4      ;'       g    RV
P                  R4      ;'       g    R8H  pV'       d‰   VP                  R
4      R8X  ds   VP                  R4      R8X  d]   V'       dU   \         FI  pVV
9  d   K  VR8X  d+   ^ RIHp V! VP                  V4      V
V,          4      VV&   K=  V
V,          VV&   KK  	  M\%        W:4       V P'                  V
4       V'       dÜ   V^8¼  dÕ   V P)                  \*        P,                  R7      '       d­   WPP.                  8¼  g   V P0                  P2                  ^ 8:  d   RV n        ^ V n        ^ V n        V P6                  '       g>   V P9                  V P:                   RV RV P<                   RV P>                   R2RR7       V PA                  R4       W0n!        \D        # EM¯V	^8  g
   V'       Ed    T;'       g    T;'       g    TpV'       d   V	^8¼  dˆ   V'       d
   VR ,          MR	p\        V\        4      '       d_   VP                  R
4      R8H  ;'       d    VP                  R4      V8H  pV'       g'   VP                  R
4      R8X  d   \%        VR
RRV/4       V'       gš   V! V4      R8X  d�   RV n#        \        VRR	4      p\        V\        4      '       g   \        VRR	4      MVP                  R4      p\I        T R	Y�PJ                  ;'       g     \M        T;'       g    ^ 4      ;'       g    RR7      V n'        V P6                  '       g$   V P9                  V P:                   RV	 R2RR7       V PA                  RV	 R24       W0n!        R	# ^ V n        ^ V n        V PQ                  W44       \S        W5R4      # )!u—  Codex Responses ``status=incomplete`` continuation (max 3 per turn).

Appends the interim assistant message (deduped on visible content only â€” opaque
provider state drifts per continuation; ``codex_reasoning_items`` are merged, not
overwritten, because the earlier response holds the only native-compaction
checkpoint) and, when a bare retry would be byte-identical, a user-role nudge â€” only
after an assistant row, to preserve role alternation. Returns ``None`` to continue
the turn loop, ``CODEX_FALLBACK_ACTIVATED`` when a reasoning-only stall was handed to
the next fallback provider, or the terminal ``partial`` result once retries are exhausted.

Reasoning-only stall ladder (#67321): a response with neither visible text nor a tool
call advances ``_codex_reasoning_only_streak`` (a visible partial resets it; the aggregate
``_codex_incomplete_retries`` stays the cap for partials). Encrypted reasoning replays
byte-for-byte, so after replay (1) and nudge (2) the third consecutive reasoning-only
response goes to the configured fallback with the semantic ``incomplete_response`` reason
instead of ending on the sentinel; when that response consumed the last iteration the
fallback gets exactly one grace call (``_budget_grace_call`` is consumed by the next
iteration, and the streak restarts from 0, so a second grace call is unreachable).

When ``response`` hit ``max_output_tokens`` with no visible text (reasoning ate the
whole budget), the next attempt goes out with reasoning off and a doubled output
cap â€” the same one-shot overrides the chat-completions length path uses â€” because
re-sending the identical budget and effort re-burns the budget identically (#90393).)Ú_CODEX_INCOMPLETE_NUDGE)Ú_codex_finish_reasonr)   r&   Ú	reasoningÚcodex_reasoning_itemsÚcodex_message_itemsr  Nr+   r,   r   Ú
incomplete)Úmerge_interim_reasoning_items)ÚreasonTu%   â†» Codex reasoning-only stall after u$    attempts â€” switching to fallback z (Ú)rÅ   uH   â†» model stuck on internal reasoning â€” switching to fallback providerrÆ   rQ   Úoutput_tokensrá   )rß   u0   â†» Codex response incomplete; continuing turn (z/3)uM   â†» model returned reasoning with no final answer â€” asking it to continue (z@Codex response remained incomplete after 3 continuation attemptséÿÿÿÿ)*r3   r  Úagent.turn_response_checkr  Ú_codex_incomplete_retriesrÉ   ri   r1   r6   r-   r   rT   Ú_codex_reasoning_only_streakr0   Ú_interim_assistant_visible_textÚ_CODEX_REPLAY_KEYSÚagent.native_compactionr  r
   Ú_emit_interim_assistant_messager·   r	   Úincomplete_responseÚmax_iterationsÚiteration_budgetÚ	remainingÚ_budget_grace_callÚ
quiet_moder´   rµ   rÚ   rR   Ú_emit_diagnostic_waitr7   ÚCODEX_FALLBACK_ACTIVATEDrÈ   rè   râ   r.   ró   r–   rn   )r   r¿   r   r   r„   re   rL   r  r  rÎ   rÐ   Úinterim_has_contentÚ
_reasoningÚinterim_has_reasoningÚinterim_has_codex_reasoningÚinterim_has_codex_message_itemsÚreasoning_onlyÚstreakÚlast_msgÚlast_is_dictÚlast_interim_visibleÚcurrent_interim_visibleÚsame_visible_outputÚ_keyr  Úinterim_replayableÚ	_last_msgÚ_already_nudgedrQ   Úobserveds   &&&$$$$                       r"   Úcontinue_codex_incompleter>  +  só  € õ6 @Ý>à	×#Ò# qÕ(Õ#Ø×'Ñ'€Aà×0Ñ0Ð1BÓR€KÜ §¡°	Ó :× @Ð @¸b×GÑGÓIÓJÐØ—‘ Ó-€JÜ& z´3Ó7×TÐT¼DÀ×AQÑAQÓASÓ<TÐÜ"& {§¡Ð7NÓ'OÓ"PÐÜ&*¨;¯?©?Ð;PÓ+QÓ&RÐ#Ø,Ô,×cÐc´WÐ=NÐP\Ð^bÓ5cÔ1c€NßSa¨×)KÑ)KÈaÖ)OÐgh€EÔ&Ø×/Ñ/€Fç×3×7R×VuÐVuß#+�8˜B–<°ˆÜ! (¬DÓ1ˆßR^˜u×DÑDÀXÔNÐdfÐØ"'×"GÑ"GÈÓ"TÐß×#:Ø"6Ð:QÑ"QÑð #/÷ #ð #Ø—‘˜iÓ(×.Ð.¨B°K·O±OÀIÓ4N×4TÐ4TÐRTÑU÷ ^ð ^Ø—\‘\ +Ó.×4Ð4°"¸+¿/¹/È+Ó:V×:\Ð:\ÐZ\Ñ]ð  ÷
 Ø—‘˜VÓ$¨Ô3Ø—‘˜_Ó-°Ô=ß#÷ +�Ø˜{Ô*ÙØÐ2Ô2ÝUÙ%BÀ8Ç<Á<ÐPTÓCUÐWbÐcgÕWhÓ%i�H˜T“Nà%0°Õ%6�H˜T“Nò +ô ˜8Ô1Ø×1Ñ1°+Ô>ç˜& Aœ+Ø×'Ñ'¬~×/QÑ/QÐ'×RÒRð ×!5Ñ!5Ô5¸×9OÑ9O×9YÑ9YÐ]^Ô9^Ø+/�Ô(Ø./ˆEÔ+Ø12ˆEÔ.Ø×#×#Ð#Ø—‘Ø×'Ñ'Ð(Ð(MÈfÈXð V-Ø-2¯[©[¨M¸¸E¿N¹NÐ;KÈ1ðNØZ^ð ô ð ×'Ñ'Ð(rÔsØ&.Ô#Ü+Ð+ñ Sð  
ˆQŒ—.�.ð 1×rÐrÐ4O×rÐrÐSrÐß! Q¨!¤Vß(0˜ ž°dˆIÜ˜)¤T×*Ò*à—M‘M &Ó)¨VÑ3×kÐk¸	¿¹ÀiÓ8PÐTkÑ8kð  ÷ '¨9¯=©=¸Ó+@ÀKÔ+OÜ" 8¨f°f¸iÐI`Ð-aÔbß"Ñ';¸HÓ'EÈÔ'UØ-1ˆEÔ*ô ˜H g¨tÓ4ˆEÜDNÈuÔVZ×D[ÒD[”w˜u o°tÔ<Ðaf×ajÑajÐkzÓa{ˆHÜ1CØ�t˜Q×%5Ñ%5×%SÐ%S¼¸X¿]¸]ÈÓ9K×%SÐ%SÈtô2ˆEÔ.ð ××ÐØ�M‰M˜U×-Ñ-Ð.Ð.^Ð_`Ð^aÐadÐeÐrvˆMÔwð 	×#Ñ#Ø[Ð\]Ð[^Ð^aÐbô	
ð #+ÔÙà&'€EÔ#Ø)*€EÔ&Ø	×Ñ˜8Ô:ÜØÐ"dóð r$   c                  ó:   € ] tR tRt$ RtR]R&   R]R&   R]R&   R	tR
# )ÚRefusalVerdictiº  u  Outcome of ``handle_content_policy_refusal``: ``"break"`` (fallback activated â€”
restart armed on ``_retry``; caller resets retry/compression counters) or
``"return"`` (the typed content-policy result in ``result``). ``active_system_prompt``
is the possibly re-synced system prompt.r   rq   rr   rm   r   Úactive_system_promptr    Nry   r    r$   r"   r@  r@  º  s   ‡ ñ0ð
 ƒKØ$Ó$Ø×r$   r@  c          "     ó\   € V ^8„  d   QhRRRRRRRRRRR	RR
RRRRRRRRRRRRRRRRRRRRR/# )r   r   r   rL   r«   r   Úthinking_spinnerr   r   Úapi_messagesrê   rA  r„   re   r.   r…   Úturn_idÚapi_request_idÚapi_start_timeÚfloatrw   Úmax_retriesr   r@  r    )r!   s   "r"   r#   r#   Æ  s­   € ÷ <ñ <Øð<Øð<Ø'5ð<ØLOð<à"ð<à25ð<àCFð<à^að<ð ð<ð 03ð<ð HKð<ð VYð<ð ð	<ð */ð	<ð >Að	<ð PSð	<ð
 ñ<r$   c               ó€  € ^ RI HpHp \        W4      p\	        VRR4      ;'       g    RP                  4       pV'       g*   V P                  V4      ;'       g    RP                  4       p\	        VRR4      ;'       g    / P                  R4      pV'       gv   \        V\        4      '       d`   \        VP                  R4      ;'       g    R4      P                  4       ;'       g&    VP                  R4      '       d   R	VR,           2MRpT P                  Y«TY�TR
T;'       g    RRWïR\        P                  P                  R7       \        W4       V P!                  4       '       d   V P#                  R4       V P%                  4       '       d   V! WWr4      p\'        RRV4      # V P)                  4        \+        V4      R8”  d   VR,          R,           MTp\,        P/                  RV P0                  V P2                  V P4                  \	        VRR4      ;'       g    RT;'       g    RT;'       g    R4       V P7                  R4       R\9        \;        V P4                  4      T;'       g    RR7      ,           pV P=                  V
4       V P?                  WH4       \'        RT! YITT;'       g    RR7      V4      # )uù   HTTP-200 refusal (``finish_reason`` ``content_filter`` / ``guardrail_intervened``).
Deterministic for the unchanged prompt â€” never retried: one configured-fallback try,
else surface the refusal (explanation may live only in the reasoning channel).)Ú_arm_fallback_restartÚ_content_policy_blocked_resultr)   Nr&   Úprovider_dataÚstop_detailsÚexplanationÚcategoryzprovider refusal category: ÚContentPolicyBlockedz*model declined to respond (content_filter)F)Útask_idrE  rF  re   rG  rê   Ú
error_typeÚerror_messageÚstatus_coderw   rI  Ú	retryabler  uH   âš ï¸� Model declined to respond (safety refusal) â€” trying fallback...r±   iô  :Niô  Nz...z�%sModel declined to respond (finish_reason=content_filter). model=%s provider=%s native_stop_reason=%s stop_details=%s refusal=%sÚstop_reasonzn/az	(no text)uF   âš ï¸� The model declined to respond to this request (safety refusal).u   âš ï¸� z!the model returned no explanation)rï   Úsummaryr   zmodel declined (content_filter))rf   Úerror_detail) r3   rK  rL  ra   rT   r6   Ú_extract_reasoningr1   r-   r0   r   Ú_invoke_api_request_error_hookr	   Úcontent_policy_blockedrö   r   Ú_has_pending_fallbackÚ_buffer_diagnostic_statusr·   r@  rô   r/   ÚloggerÚwarningrµ   rÚ   rR   r¶   r   r   r•   r–   )r   rL   r«   rC  r   rD  rê   rA  r„   re   r…   rE  rF  rG  rw   rI  rK  rL  Ú_refusal_resultÚ_refusal_textÚ_stop_detailsÚ_refusal_logÚ_refusal_responses   &&&$$$$$$$$$$$$$       r"   Úhandle_content_policy_refusalrf  Æ  s  € ÷ ^ä2°5ÓC€OÜ˜_¨i¸Ó>×DÐDÀ"×KÑKÓM€MßØ×1Ñ1°/ÓB×HÐHÀb×OÑOÓQˆô ˜_¨o¸tÓD×JÐJÈ×OÑOÐP^Ó_€MßœZ¨´t×<Ò<Ü˜M×-Ñ-¨mÓ<×BÐBÀÓC×IÑIÓK÷ 
ð 
ØIV×IZÑIZÐ[e×IfÒIfÐ)¨-¸
Õ*CÐ)DÑEÐlnð 	ð 
×(Ñ(Ø!À>Ø%ÐQ[Ø)Ø#×SÐSÐ'SØ kÐV[Ü×4Ñ4×:Ñ:ð )ô ô ˜%Ô2à×"Ñ"×$Ò$Ø×'Ñ'Ð(rÔsØ×#Ñ#×%Ò%Ù4°UÐJ^ÓgÐÜ˜g tÐ-AÓBÐBà	×ÑÔ Ü25°mÓ2DÀsÔ2J�= Õ&¨Ö.ÐP]€Lô ‡N�Nð	;à×Ñ˜%Ÿ+™+ u§~¡~Ü�˜-¨Ó.×7Ð7°%¸×9OÐ9OÈ%Ø×#Ð#˜ôð 
×!Ñ!Ð"jÔkØ!Ô$7Ü  §¡Ó0Ø×DÐDÐ!Dô%õ Ðð 
×!Ñ!Ð"3Ô4Ø	×Ñ˜8Ô:Ü˜(Ñ$BØÐ1BØ"×GÐGÐ&Gô%ð óð r$   >   Úcodex_responsesÚbedrock_converseÚchat_completionsr\   )uV   ðŸ’­ Reasoning exhausted the output token budget â€” no visible response was produced.u  âš ï¸� **Thinking Budget Exhausted**

The model used all its output tokens on reasoning and had none left for the actual response.

To fix this:
â†’ Lower reasoning effort: `/reasoning low` or `/reasoning minimal`
â†’ Or switch to a larger/non-reasoning model with `/model`z‚Model used all output tokens on reasoning with none left for the response. Try lowering reasoning effort or increasing max_tokens.r‹   )r)   r  Úreasoning_contentÚreasoning_detailsr  r  )Dr~   Ú
__future__r   ÚloggingÚreÚdataclassesr   Útypingr   r   r   r   r   Úagent.error_classifierr	   Úagent.message_metadatar
   Úagent.message_sanitizationr   Úagent.repetition_guardr   Úagent.turn_api_callr   Úagent.turn_failure_copyr   r   r   r   Úagent.turn_retry_stater   Úagent.usage_pricingr   Úhermes_constantsr   Ú	getLoggerr_  r  ÚcompileÚ
IGNORECASEr¢   r÷   r  r  rC   r¥   rJ   r¦   r  rÍ   rV   rÌ   rY   ra   rn   rp   rƒ   r¨   r½   rÕ   rÜ   rè   rú   r  r"  r,  r>  r@  rf  r    r$   r"   Ú<module>r}     sº  ðñõ #ã Û 	Ý !ß 3Õ 3å 1Ý 1Ý FÝ :Ý 5ß eÓ eÝ 1Ý /Ý 3à	×	Ò	Ð4Ó	5€ò
 gÐ Ø—
’
ÐVÐXZ×XeÑXeÓf€Ù˜[Ó)Ð Ø)Ð ð
&ð  ð/à59÷/ðdÐ õ	ñ (Ø1Ø^Ø9óÐ ñ
 )ØØZØ6óÐ ðpð ð !Ð ðUð õ	[õ?ñà38ðàX]÷ð ð( ÷ð ó ðñ& �4Ôô*JÐó *Jó ð*JõZõ%õPAõHJ÷1õ$-õ`^KðBÐ ð 6Ð ðLàDH÷Lð^ ÷ð ó ð÷<r$   