+
    iHàjOÈ  ã            	      óÀ  a€ 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHtHtHt ^ RIHtHt ^ RIHt ^ RIHt ]P,                  ! ]4      t]P2                  ! R4      t]! R	R
RR]04      tR R lt]P2                  ! R4      tR«R R lltR R lt R R lt!R R lt"R R lt#]	! ]"]R7      t$]	! ]#]RR7      t%]	! ]"] R7      t&]	! ]#] RR7      t']&t(R R lt)R  R! lt*R"t+R# R$ lt,R%R&R'R(/t-R) R* lt.R¬R+ R, llt/R­R- R. llt0R/R0R1R2R3R/t1R4 R5 lt2R6 R7 lt30 R®mt4R8 R9 lt5R¯t6R°t7R: R; lt8R< R= lt9R> R? lt:. R@NRANRBNRCNRDNRENRFNRGNRHNRINRJNRKNRLNRMNRNNRONRPNRQNRRNRSNRTNRUNRVNRWNRXNRYNRZNR[NR\NR]NR^Nt;R_ R` lt<Ra Rb lt=R±Rc Rd llt>Re Rf lt?Rg Rh lt@Ri Rj ltARk Rl ltBR³Rm Rn lltCR´tDRo Rp ltERq Rr ltFRs]! RtRu04      ]! 4       R²Rµ3Rv]! 4       ]! Rv04      R¶R·3Rw]! 4       ]! Rx04      R¸R¹3Ry]! 4       ]! 4       RºR²33tGRz]HR{&   ]G U u/ uF  q ^ ,          V bK  	  up tIR|R}R~utJtKtL]J]K]L3tM]! ]M4      tN]! ]J04      tO]! ]J]K04      tP]! 4       ]! 0 R»m4      R¼3]! ]J04      ]! R04      R½3]N]! 0 R¾m4      R¿3]! ]J]L04      ]! 0 RÀm4      RÁ3]P]! 0 RÂm4      RÃ33tQRz]HR€&    ! R� R‚]4      tRRƒ R„ ltSR… R† ltTR‡ Rˆ ltUR‰ RŠ ltVR‹ RŒ ltWR�RRŽR²/R� R� lltXR‘ R’ ltYR“ R” ltZR• R– lt[R— R˜ lt\R­R™ Rš llt]R› Rœ lt^R­R� Rž llt_RÄt`]J]P2                  ! RŸ4      ]L]P2                  ! R 4      ]K]P2                  ! R¡4      /taR¢ R£ ltbR¤ R¥ ltcR¦tdR§ R¨ lteR© Rª ltfR# u up i )Åa+  Message and tool-payload sanitization helpers (pure; documented in-place mutation).

Walk OpenAI-format message lists and structured payloads, repairing or stripping
characters that would crash ``json.dumps`` in the OpenAI SDK or be rejected upstream.
``run_agent`` re-exports them for old imports.
)ÚannotationsN)Úpartial)ÚAnyÚCallableÚIterableÚ
NamedTuple)Ú_INTERRUPTED_PLACEHOLDERÚ hidden_interrupt_placeholder_row)ÚDB_ROW_SNAPSHOT)Ú_provider_model_keyz[\ud800-\udfff]ÚcontentÚnameÚ
tool_callsÚrolec               ó    € V ^8„  d   QhRRRR/# ©é   ÚtextÚstrÚreturn© )Úformats   "Ú?/home/ubuntu/.hermes/hermes-agent/agent/message_sanitization.pyÚ__annotate__r       s   € ÷ -ñ -˜sð - sñ -ó    c                ó^   € V P                  4       '       d   V # \        P                  RV 4      # )zHReplace lone surrogate code points with U+FFFD; no-op when none present.u   ï¿½)ÚisasciiÚ_SURROGATE_REÚsub©r   s   &r   Ú_sanitize_surrogatesr        s'   € ð ‡|�|‡~‚~ØˆÜ×Ñ˜X tÓ,Ð,r   z[A-Za-z0-9_-]{1,64}c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Úfallbackr   r   r   )r   s   "r   r   r   /   s!   € ÷ 
$ñ 
$˜3ð 
$¨#ð 
$Èñ 
$r   c           
     ó(  € \        V \        4      '       g   V# \        P                  V 4      '       d   V # \        P
                  ! RR\        P
                  ! RRV P                  4       4      4      P                  R4      pVR,          ;'       g    T# )u�  Coerce a *replayed* tool/function name to ``^[A-Za-z0-9_-]{1,64}$``. Valid names are returned
as-is (identity â€” prompt-cache safe); invalid runs collapse to ``_`` and the result is cut at 64;
empty/all-invalid â†’ ``fallback``. Deterministic, so the same stored name always renders the same
bytes. Never apply to live tool definitions (schema names must match the dispatch registry).z_+Ú_z[^A-Za-z0-9_-]:Né@   N)Ú
isinstancer   Ú_VALID_TOOL_NAME_REÚ	fullmatchÚrer   Ústrip)r   r"   Úcoerceds   && r   Úcoerce_tool_namer,   /   sp   € ô
 �dœC× Ò ØˆÜ×$Ñ$ T×*Ò*ØˆÜ�fŠf�U˜C¤§¢Ð(9¸3ÀÇ
Á
ÃÓ!MÓN×TÑTÐUXÓY€GØ�3�<×#Ð#˜8Ð#r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r   s   "r   r   r   <   s   € ÷ Añ A˜3ð A 3ñ Ar   c                óv   € V P                  4       '       d   V # V P                  RRR7      P                  R4      # )uS   Drop non-ASCII characters â€” last resort for ASCII-only system encodings (LANG=C).ÚasciiÚignore©Úerrors)r   ÚencodeÚdecoder   s   &r   Ú_strip_non_asciir5   <   s0   € à‡|�|‡~‚~ØˆØ�;‰;�w xˆ;Ó0×7Ñ7¸Ó@Ð@r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Ú	containerr   ÚkeyÚfixúCallable[[str], str]r   Úboolr   )r   s   "r   r   r   C   s)   € ÷ ñ ˜cð ¨ð Ð2Fð È4ñ r   c                ó¼   € \        V \        4      '       d   V P                  V4      MW,          p\        V\        4      '       d	   V! V4      MTpWC8X  d   R# W@V&   R# )zGApply ``fix`` to ``container[key]`` if it is a str; True if it changed.FT)r&   ÚdictÚgetr   )r7   r8   r9   ÚvalueÚfixeds   &&&  r   Ú_fix_str_fieldrA   C   sI   € ä",¨Y¼×"=Ò"=ˆI�M‰M˜#ÔÀ9Å>€EÜ$ U¬C×0Ò0‰C�ŒJ°e€EØ„~ÙØˆc�NÙr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úpayloadr   r9   r:   r   r;   r   )r   s   "r   r   r   M   s"   € ÷ ñ  ð Ð+?ð ÀDñ r   c                ó²  € RpV .pV'       dÊ   VP                  4       p\        V\        4      '       d   VP                  4       M"\        V\        4      '       d   \        V4      MRp\	        V4       F_  w  rg\        V\        4      '       d   V\        WFV4      ,          pK0  \        V\        \        34      '       g   KN  VP                  V4       Ka  	  KÑ  V# )zHApply ``fix`` to every str inside nested dict/list ``payload`` in-place.Fr   )	Úpopr&   r=   ÚitemsÚlistÚ	enumerater   rA   Úappend)rC   r9   ÚfoundÚstackÚnoderF   r8   r?   s   &&      r   Ú_sanitize_structurerM   M   sœ   € à€EØˆI€Eß
Ø�y‰y‹{ˆÜ *¨4´× 6Ò 6�—
‘
”ÌzÐZ^Ô`d×OeÒOe¼IÀd¼OÐkmˆÜ˜už+‰JˆCÜ˜%¤×%Ò%Øœ¨°3Ó7Õ7’Ü˜E¤D¬$ <×0Ô0Ø—‘˜UÖ#ó	 &ð
 €Lr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   ÚmessagesrG   r9   r:   Údeepr;   r   r   )r   s   "r   r   r   \   s*   € ÷  ñ   ð  Ð,@ð  È4ð  ÐTXñ  r   c               ó˜  € ^ RI Hp RpV  EF0  p\        V\        4      '       g   K  RpVP	                  R4      p\        V\
        4      '       d-   V Uu. uF  p\        V\        4      '       g   K  VR3NK!  	  upMRp	V	e   T	MVR3.p
V
P                  VR34       VP	                  R4      p\        V\
        4      '       d   TMR F�  p\        V\        4      '       d   VP	                  R4      MRpY¢'       d   \        V\        4      '       d   VR	3.M. ,          p
T
\        V\        4      '       d   V'       d   VR3.M. VR
3.,           M. ,          p
K‘  	  V
 F  w  rïV\        WïV4      ,          pK  	  VP                  4        Uu. uF  pV^ ,          \        9  g   K  VNK  	  up Fl  w  pp\        V\        4      '       d   V\        W_V4      ,          pK1  V'       g   K;  \        V\        \
        34      '       g   KY  V\        VV4      ,          pKn  	  V'       g   EK  VP                  VR4       RpEK3  	  V# u upi u upi )a  Apply ``fix`` to the string fields of every message dict in-place (content / part text,
name, tool_call arguments, non-core top-level str fields). ``deep=True`` adds tool_call ids,
function names, and NESTED non-core fields (``reasoning_details`` from byte-level models).©Ú_DB_PERSISTED_MARKERFr   r   Nr   r   ÚfunctionÚidÚ	argumentsTr   )Úagent.context_compressorrS   r&   r=   r>   rG   rI   rA   rF   Ú_MESSAGE_CORE_KEYSr   rM   rE   )rO   r9   rP   rS   rJ   ÚmsgÚ	msg_foundr   ÚpÚpartsÚfieldsr   ÚtcÚfnr7   r8   Úkvr?   s   &&$               r   Ú_sanitize_messagesra   \   sð  € õ >à€EÜˆÜ˜#œt×$Ò$ÙØˆ	Ø—'‘'˜)Ó$ˆÜISÐT[Ô]a×IbÒIb¡gÓE¡g ´¸A¼t×1D”�!�V“¡gÒEÐhlˆØÒ+‘°3¸	Ð2BÐ1CˆØ�‰�s˜F�mÔ$Ø—W‘W˜\Ó*ˆ
Ü *¨:´t× <Ò <‘*À"ÒDˆBÜ'1°"´d×';Ò';�—‘˜
Ô#ÀˆBØ¦d¬z¸"¼d×/CÒ/C˜˜D�z‘lÈÕKˆFØÔPZÐ[]Ô_c×PdÒPd¯˜˜V˜‘~°2¸2¸{Ð:KÐ9LÖLÐjlÕlŠFñ Eó %‰NˆIØœ¨	¸Ó<Õ<ŠIñ %à(+¯	©	¬ÓW© "°r¸!µuÔDVÑ7VŸ2˜2©ÔW‰JˆC�Ü˜%¤×%Ò%Øœ^¨C°cÓ:Õ:’	ß‘œ* U¬T´4¨L×9Ô9ØÔ0°¸Ó<Õ<’	ñ	 X÷
 Š9ð �G‰GÐ(¨$Ô/Ø‹Eñ1 ð2 €Lùò) Fùò Xs   ÁIÁ1IÆ
IÆ#I)r9   T)r9   rP   Fc               ó$   € V ^8„  d   QhRRRRRR/# )r   Úagentr   Ú
api_kwargsr=   r   ÚNoner   )r   s   "r   r   r   ˆ   s!   € ÷ 2ñ 2 Cð 2°Tð 2¸dñ 2r   c                óà   € \        V4       V P                  '       dQ   VP                  R4      e1   VR,          \        V RR4      J d   ^ RIHp V! VR,          4      VR&   \        V4       R# R# )au  Outbound-request chokepoint for every built kwargs dict (main loop and iteration summary).

Tool descriptions, extra_body and kwargs strings can carry invalid code points that
providers reject with a non-retryable 400 (#50959); one in-place walk makes the whole
payload json.dumps()-safe. The ASCII strip is opt-in via the recovery flag set after an
ASCII-codec rejection.
ÚtoolsN)Ú_clone_message_for_send)Ú_sanitize_structure_surrogatesÚ_force_ascii_payloadr>   ÚgetattrÚagent.conversation_looprh   Ú_sanitize_structure_non_ascii)rc   rd   rh   s   && r   Úsanitize_outbound_kwargsrn   ˆ   se   € ô # :Ô.Ø×!×!Ð!ð
 �>‰>˜'Ó"Ò.°:¸gÕ3FÌ'ÐRWÐY`ÐbfÓJgÓ3gåGá"9¸*ÀWÕ:MÓ"NˆJ�wÑÜ% jÖ1ñ "r   c               ó    € V ^8„  d   QhRRRR/# )r   Úrawr   r   r   )r   s   "r   r   r   ž   s   € ÷ ñ ¨sð °sñ r   c                ó˜  € . pRp^ pV\        V 4      8  d¥   W,          pV'       dD   VR8X  d=   V^,           \        V 4      8  d&   VP                  WV^,            4       V^,          pKc  VR8X  d   V'       * pTP                  V'       d    \        V4      ^ 8  d   R\        V4      R 2MT4       V^,          pK´  RP                  V4      # )zœEscape literal control chars (0x00-0x1F) inside JSON string values as ``\uXXXX``
(for llama.cpp-style output mixing control chars with other malformations).FÚ\Ú"z\uÚ04xÚ )ÚlenrI   ÚordÚjoin)rp   ÚoutÚ	in_stringÚiÚchs   &    r   Ú%_escape_invalid_chars_in_json_stringsr}   ž   s©   € ð €CØ€IØ	€AØ
Œc�#‹hŒ,Ø�Vˆß˜˜tœ¨¨A­´°C³Ô(8Ø�J‰J�s˜Q �U�|Ô$Ø��FˆAÙØ�Œ9Ø%œˆIØ�
‰
¯)¼¸B»À$¼�Sœ˜R› ˜Ñ&ÈBÔOØ	ˆQ�ŠØ�7‰7�3‹<Ðr   i † c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   r;   r   )r   s   "r   r   r   ¶   s   € ÷ ñ �Cð ˜Dñ r   c                ól   €  \         P                  ! V 4       R #   \         P                   d     R# i ; i)TF)ÚjsonÚloadsÚJSONDecodeErrorr   s   &r   Ú	_loads_okrƒ   ¶   s.   € ðÜ�
Š
�4ÔÙøÜ×Ñô Úðús   ‚ š3²3Ú{Ú}Ú[Ú]c               ó    € V ^8„  d   QhRRRR/# )r   rp   r   r   ú
str | Noner   )r   s   "r   r   r   Á   s   € ÷ "Oñ "O ð "O¨ñ "Or   c                óš  € . p. pRp^ \        V 4      rTWE8  dô   W,          pV'       d7   VR8X  d&   VP                  WV^,            4       V^,          pKB  VR8X  d   RpM‘VR8X  d   RpM‡V\        9   d   VP                  V4       MjVR9   dd   VR V 4       9   dV   \        VR
,          ,          V8w  d-   VP                  \        VP                  4       ,          4       KE  VP                  4        VP                  V4       V^,          pKù  V'       d   R# RP	                  V4      RP	                  R	 \        V4       4       4      ,           # )u4  Close a JSON prefix's open braces/brackets in stack order, ignoring delimiters
inside string values (``{"code": "}"}`` keeps one open brace, not a balanced
document). A closer that does not match the stack top but does match a deeper opener
gets the missing inner closers inserted BEFORE it: ``{"a": [{"b": 1}}`` â†’ the model
dropped the ``]`` and let the neighbouring ``}`` close in its place, so the counts
balance and nothing can be appended. ``None`` when the text ends inside an
unterminated string â€” that content is unrecoverable and must not be guessed.
Frr   rs   Tz}]c              3  ó<   "  € T F  p\         V,          x € K  	  R # 5i©N©Ú_JSON_CLOSERS)Ú.0Úos   & r   Ú	<genexpr>Ú*_rebalance_json_closers.<locals>.<genexpr>Û   s   é € Ð"C¹U¸¤=°×#3Ò#3»Uùó   ‚Nru   c              3  ó<   "  € T F  p\         V,          x € K  	  R # 5irŒ   r�   )r�   r|   s   & r   r‘   r’   ã   s   é € Ð!N¹o¸¤-°×"3Ò"3»oùr“   éÿÿÿÿ)rv   rI   rŽ   rE   rx   Úreversed)rp   ry   rK   rz   r{   Únr|   s   &      r   Ú_rebalance_json_closersr˜   Á   s  € ð €CØ€EØ€IØŒc�#‹h€qØ
Œ%Ø�VˆßØ�TŒzØ—
‘
˜3  Q¥˜<Ô(Ø�Q•�ÙØ�SŒyØ!�	øØ�3ŒYØ‰IØ”=Ô Ø�L‰L˜ÕØ�4ŒZ˜BÑ"C¹UÓ"CÔCÜ  b¥	Õ*¨bÔ0Ø—
‘
œ=¨¯©«Õ5Ö6Ø�I‰IŒKØ�
‰
�2ŒØ	ˆQ�ŠßÙØ�7‰7�3‹<˜"Ÿ'™'Ñ!N¼hÀu¼oÓ!NÓNÕNÐNr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úraw_argsr   Ú	tool_namer   r   )r   s   "r   r   r   æ   s!   € ÷ 7ñ 7¨#ð 7¸#ð 7Èñ 7r   c                ó”  € \        V \        4      '       d   V P                  4       MRpV'       g   \        P	                  RV4       R# VR8X  d   \        P	                  RV4       R#  \
        P                  ! \
        P                  ! VRR7      RR7      pW28w  d   \        P	                  R	V4       V#   \
        P                  \        \        3 d     Mi ; i\        P                  ! R
RT4      p\        T4      ;'       g    Tp\        ^24       F“  p\        T4      '       gy   TP!                  R4      '       d&   TP#                  R4      TP#                  R4      8”  g?   TP!                  R4      '       d&   TP#                  R4      TP#                  R4      8”  g    M	TRR pK•  	  \        T4      '       d(   \        P	                  RYR,          TR,          4       T# \%        T4      pYd8w  d9   \        T4      '       d(   \        P	                  RYR,          TR,          4       T# \        P	                  RYR\&         4       R# )z±Repair malformed tool_call argument JSON (truncation, trailing commas, Python ``None``,
control chars); ``"{}"`` if unrepairable so the request succeeds. Repairs log at WARNING.ru   z*Sanitized empty tool_call arguments for %sz{}re   z0Sanitized Python-None tool_call arguments for %sF)Ústrict)Ú
separatorsz>Repaired unescaped control chars in tool_call arguments for %sz,\s*([}\]])z\1r…   r„   r‡   r†   Nu8   Repaired malformed tool_call arguments for %s: %s â†’ %s:NéP   NuA   Repaired control-char-laced tool_call arguments for %s: %s â†’ %suP   Unrepairable tool_call arguments for %s â€” replaced with empty object (was: %s)©Ú,Ú:r•   )r&   r   r*   ÚloggerÚwarningr€   Údumpsr�   r‚   Ú	TypeErrorÚ
ValueErrorr)   r   r˜   Úrangerƒ   ÚendswithÚcountr}   Ú_FULL_ARGS_LOG_BOUND)rš   r›   Úraw_strippedÚreserialisedr@   r$   Úescapeds   &&     r   Ú_repair_tool_call_argumentsr¯   æ   sÛ  € ô (2°(¼C×'@Ò'@�8—>‘>Ô#Àb€LçÜ�‰ÐCÀYÔOÙà�vÔÜ�‰ÐIÈ9ÔUÙðÜ—z’z¤$§*¢*¨\À%Ô"HÐU_Ô`ˆØÔ'Ü�N‰NÐ[Ð]fÔgØÐøÜ× Ñ ¤)¬ZÐ8ô Ùðúô �FŠF�> 5¨,Ó7€EÜ# EÓ*×3Ð3¨e€EÜ�2ŽYˆÜ�U×ÒØ�^‰^˜C× Ò  U§[¡[°Ó%5¸¿¹ÀCÓ8HÔ%HØ—‘˜s×#Ò#¨¯©°CÓ(8¸5¿;¹;ÀsÓ;KÔ(KáØ�c�r�
Šñ ô �×ÒÜ�‰ÐQÐS\ÐknÕ^oÐqvÐwzÕq{Ô|Øˆô 4°EÓ:€GØÔœI g×.Ò.Ü�‰ØOÐQZÐilÕ\mÐovÐwzÕo{ô	
ð ˆä
‡N�NØZØÐ 5Ô!5Ð6ôñ s   Á)AB5 Â5 CÃCc               ó$   € V ^8„  d   QhRRRRRR/# )r   rO   rG   Úfinal_responser   r   r;   r   )r   s   "r   r   r      s"   € ÷ ñ ¨dð ÀCð ÐSWñ r   c                óN  € V '       d
   V R
,          MRp\        V\        4      '       d   VP                  R4      R8w  d   R# \        V\        4      '       d   TMRp^ RIHp VP                  4       pV'       d   V\        8X  d   V! V \        4       4       R	# V! V RRRV/4       R	# )uY  Append a synthetic assistant turn when an interrupted tail is a tool result: a transcript
ending on a raw ``tool`` message makes the next user message land as ``tool â†’ user``, an
alternation violation strict providers (Gemini, Claude) answer by hallucinating a
continuation. Mutates in place; True if a closing turn was appended.

Only the placeholder closes silently: with no real text (or just the bare interrupt
placeholder) the row is hidden from the user â€” ``api_content`` carries the LLM-visible
text (substituted at API-build time by ``substitute_api_content``), ``content=""`` +
``display_kind="hidden"`` keep it out of rendered transcripts, matching the
``_INTERRUPTED_PLACEHOLDER`` shape in ``turn_api_call.py``. A caller-supplied banner
(truncation notices, partial-delivery text) stays visible: it is the turn's only
user-facing explanation.Nr   ÚtoolFru   )Úappend_messageÚ	assistantr   Tr•   )	r&   r=   r>   r   Úagent.message_metadatar´   r*   r   r	   )rO   r±   Úlastr   r´   Ústrippeds   &&    r   Úclose_interrupted_tool_sequencer¹      sˆ   € ÷ $ˆ8�BŽ<¨€DÜ�dœD×!Ò! T§X¡X¨fÓ%5¸Ô%?ÙÜ'¨¼×<Ò<‰>À"€DÝ5à�z‰z‹|€Hß�xÔ#;Ô;Ù�xÔ!AÓ!CÔDñ ñ 	�x &¨+°yÀ(Ð!KÔLÙr   Ú
max_tokensÚlengthÚendÚstopÚfunction_callc               ó    € V ^8„  d   QhRRRR/# )r   rp   r   r   r   )r   s   "r   r   r   H  s   € ÷ 
8ñ 
8 ð 
8¨ñ 
8r   c                óŒ   € \        V \        4      '       d	   V '       g   V # V P                  4       p\        P	                  W4      # )zõFold a wire ``finish_reason`` to the lowercase OpenAI contract value.

Non-string and empty values pass through unchanged (callers keep their
``or "stop"`` defaults and the Poolside int-reason path); contract values
are returned byte-identical.
)r&   r   ÚlowerÚ_FINISH_REASON_ALIASESr>   )rp   Úlowereds   & r   Únormalize_finish_reasonrÄ   H  s4   € ô �cœ3×Ò§sØˆ
Ø�i‰i‹k€GÜ!×%Ñ% gÓ7Ð7r   c               ó    € V ^8„  d   QhRRRR/# )r   rO   rG   r   Úintr   )r   s   "r   r   r   U  s   € ÷ 	2ñ 	2¨ð 	2°ñ 	2r   c           	     ó  € \        V \        4      '       d	   V '       g   ^ #  \        \        P                  ! V RR\
        R7      P                  R4      4      #   \        \        3 d    \        R T  4       4      u # i ; i)zâExact serialized byte size of ``messages`` (HTTP 413 is a BYTE-size error the token
estimator, pricing images flat, cannot score). Non-serializable values fall back to
``str()`` so a malformed message can never crash recovery.F)Úensure_asciirž   Údefaultúutf-8c              3  óJ   "  € T F  p\        \        V4      4      x € K  	  R # 5irŒ   )rv   r   )r�   Úms   & r   r‘   Ú,serialized_messages_bytes.<locals>.<genexpr>^  s   é € Ð1© 1”3”s˜1“v—;�;«ùs   ‚!#r    )
r&   rG   rv   r€   r¥   r   r3   r¦   r§   Úsum)rO   s   &r   Úserialized_messages_bytesrÏ   U  sg   € ô �h¤×%Ò%¯XÙð2Ü”4—:’:˜h°UÀzÔ[^Ô_×fÑfÐgnÓoÓpÐpøÜ”zÐ"ô 2ÜÑ1©Ó1Ó1Ò1ð2ús   ¢5A Á#A>Á=A>c               ó    € V ^8„  d   QhRRRR/# )r   rO   rG   r   r;   r   )r   s   "r   r   r   d  s   € ÷ !ñ !¨$ð !°4ñ !r   c                óÀ  € ^ RI Hp ^ RIHp Rp. p\	        V 4       EF$  w  rV\        V\        4      '       d   VP                  R4      MRp\        V\        4      '       g   KG  V Uu. uF7  p\        V\        4      '       d   VP                  R4      \        9   d   K5  VNK9  	  p	p\        V	4      \        V4      8  g   K¥  RpV	'       d   W–R&   VP                  VR4       MVVP                  R4      R	8X  g   VP                  R
4      '       d   RVR&   VP                  VR4       MVP                  V4       V! V4       EK'  	  \        V4       F  pW K  	  V# u upi )uí  Remove image content parts from all messages in-place (server rejected images).

``tool`` / ``tool_calls`` messages left empty get a placeholder, NOT deleted (deleting
orphans the paired ``tool_call_id`` â†’ HTTP 400); other now-empty messages are dropped.
Rewritten messages lose their ``api_content`` sidecar (it carries the removed images):
a caller rewriting a persisted row must not leave bytes that replay them next turn. The
current callers pass per-call clones, where this is a no-op.
rR   )Údrop_stale_api_contentFr   NÚtypeTr   r³   r   u:   [image content removed â€” server does not support images])rW   rS   Úagent.turn_contextrÒ   rH   r&   r=   r>   rG   Ú_IMAGE_PART_TYPESrv   rE   rI   r–   )
rO   rS   rÒ   rJ   Ú	to_deleter{   rY   r   r[   Ú	new_partss
   &         r   Ú_strip_images_from_messagesrØ   d  s  € õ >Ý9à€EØ€IÜ˜H×%‰ˆÜ(2°3¼×(=Ò(=�#—'‘'˜)Ô$À4ˆÜ˜'¤4×(Ò(ÙÙ 'Ól¡˜1´
¸1¼d×0CÒ0CÈÏÉÈfËÔYjÑHj—Q�Q¡ˆ	ÐlÜˆy‹>œC ›LÖ(ØˆEßØ!*�I‘à—‘Ð,¨dÕ3Ø—‘˜“ FÔ*¨c¯g©g°l×.CÒ.CØ!]��I‘Ø—‘Ð,¨dÕ3à× Ñ  Ô#Ù" 3×'ñ! &ô" �iÖ ˆØŠKñ !à€Lùò ms   Á'2EÂEc               ó$   € V ^8„  d   QhRRRRRR/# )r   rc   r   Úapi_messagesr   r;   r   )r   s   "r   r   r   ³  s&   € ÷ Xñ X¨Cð X¸sð XÀtñ Xr   c                ó€   € \        V 4      V P                  9  d   R# \        V\        4      ;'       d    \	        V4      # )aÞ  Send-path image strip for a model that rejected image content (see turn_recovery).

Runs on the per-call ``api_messages`` copy in Hermes's own message format, BEFORE the
provider-specific conversion: the part types this stripper knows are that format's, and a
converted payload (Bedrock Converse ``{"image": ...}`` blocks carry no ``type``) would slip
past it. History is never touched. Keyed on each rejecting (provider, model), so a model
that accepts images gets them again.
F)r   Ú_image_rejecting_modelsr&   rG   rØ   )rc   rÚ   s   &&r   Ú strip_images_for_rejecting_modelrÝ   ³  s5   € ô ˜5Ó!¨×)FÑ)FÔFÙÜ�l¤DÓ)×WÐWÔ.IÈ,Ó.WÐWr   c               ó    € V ^8„  d   QhRRRR/# ©r   Ú
error_bodyr   r   r;   r   )r   s   "r   r   r   Á  s   € ÷ Fñ F°Cð F¸Dñ Fr   c                óÎ   a€ \        T ;'       g    R4      P                  4       o\        ;QJ d#    V3R l\         4       F  '       g   K   R# 	  R# ! V3R l\         4       4      # )zMReturn True when a provider error says image/multimodal input is unsupported.ru   c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5irŒ   r   ©r�   ÚphraseÚbodys   & €r   r‘   Ú6_looks_like_image_content_rejection.<locals>.<genexpr>Ä  s   øé € ÐEÑ,D &˜Ž~Ó,Dùó   ƒTF)r   rÁ   ÚanyÚ_IMAGE_REJECTION_PHRASES©rà   rå   s   &@r   Ú#_looks_like_image_content_rejectionrë   Á  sI   ø€ äˆz×Ð˜RÓ ×&Ñ&Ó(€Dß‹3ÔEÕ,DÓE�3Œ3ÐEŠ3ÐEˆ3ÔEÕ,DÓEÓEÐEr   c               ó    € V ^8„  d   QhRRRR/# rß   r   )r   s   "r   r   r   Ç  s   € ÷ Dñ D°Cð D¸Dñ Dr   c                óÎ   a€ \        T ;'       g    R4      P                  4       o\        ;QJ d#    V3R l\         4       F  '       g   K   R# 	  R# ! V3R l\         4       4      # )zXReturn True when the rejection is about a bad image payload, not the model's capability.ru   c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5irŒ   r   rã   s   & €r   r‘   Ú6_looks_like_corrupt_image_rejection.<locals>.<genexpr>Ê  ó   øé € ÐCÑ,B &˜Ž~Ó,Bùrç   TF)r   rÁ   rè   Ú_IMAGE_CORRUPT_PHRASESrê   s   &@r   Ú#_looks_like_corrupt_image_rejectionrò   Ç  sI   ø€ äˆz×Ð˜RÓ ×&Ñ&Ó(€Dß‹3ÔCÕ,BÓC�3Œ3ÐCŠ3ÐCˆ3ÔCÕ,BÓCÓCÐCr   r   r}   r¯   Ú_sanitize_messages_non_asciiÚ_sanitize_messages_surrogatesrm   ri   r    Ú_sanitize_tools_non_asciirØ   r5   Úapply_reasoning_content_policyr¹   Úcoalesce_tool_call_idr,   Údeterministic_call_idÚmatches_reasoning_echo_familyÚneeds_reasoning_echoÚ normalize_provider_tool_call_idsÚreapply_reasoning_echoÚreasoning_echo_familyÚreasoning_replay_routeÚ record_reasoning_field_rejectionÚrejected_reasoning_carriersÚroute_reasoning_carriersrn   Ústale_thinking_reaches_wirerÝ   Útool_call_id_variantsÚtool_result_id_variantsÚuniquify_tool_call_idsc               ó$   € V ^8„  d   QhRRRRRR/# )r   r^   r   r8   r   r   r   )r   s   "r   r   r   ã  s&   € ÷ Kñ K�#ð K˜Cð K Cñ Kr   c                óh   € \        V \        4      '       d   V P                  V4      # \        WR4      # )zHRead ``key`` from a tool-call entry that may be a dict or an SDK object.N)r&   r=   r>   rk   )r^   r8   s   &&r   Ú	_tc_fieldr  ã  s(   € ä$ R¬×.Ò.ˆ2�6‰6�#‹;ÐJ´G¸BÀTÓ4JÐJr   c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   r^   r   r8   r   r?   r   re   r   )r   s   "r   r   r   è  s.   € ÷ Tñ T�ð T˜#ð T cð T¨dñ Tr   c                óp   € \        V \        4      '       d   V P                  W4       R # \        WV4       R # rŒ   )r&   r=   Ú__setitem__Úsetattr©r^   r8   r?   s   &&&r   Ú_tc_setr  è  s#   € Ü",¨R´×"6Ò"6€B‡N�N�3Ö¼GÀBÈUÖ<Sr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úfn_namer   rV   ÚindexrÆ   r   r   )r   s   "r   r   r   ÷  s.   € ÷ ]ñ ] 3ð ]°3ð ]¸sð ]È3ñ ]r   c                ó”   € V  RV RV 2pR\         P                  ! VP                  RRR7      4      P                  4       R,           2# )zWDeterministic call_id fallback when the API omits one (random ids would break caching).r¢   Úcall_rÊ   Úreplacer1   ºNé   N)ÚhashlibÚsha256r3   Ú	hexdigest)r  rV   r  Úseeds   &&& r   rø   rø   ÷  sK   € àˆY�a˜	�{ ! E 7Ð+€DØ”7—>’> $§+¡+¨g¸i +Ó"HÓI×SÑSÓUÐVYÕZÐ[Ð\Ð\r   c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluesztuple[Any, ...]r   úfrozenset[str]r   )r   s   "r   r   r   ý  s   € ÷ 	ñ 	 _ð 	¸ñ 	r   c                ó   € \        4       pV  Ft  p\        V\        4      '       d   VP                  4       MRpV'       g   K5  VP	                  V4       VP                  R R VP                  R4       4        4       4       Kv  	  \        V4      # )z´Every wire spelling of one tool-call identifier: Responses bridges may expose the pairing
id and response-item id separately or as ``call_id|response_item_id``; all alias ONE call.ru   c              3  ó8   "  € T F  q'       g   K  Vx € K  	  R # 5irŒ   r   )r�   r[   s   & r   r‘   Ú+_expand_tool_id_variants.<locals>.<genexpr>  s   é € ÐXÑ'R !ÓVWŸAšAÓ'Rùs   ‚	�
c              3  ó@   "  € T F  qP                  4       x € K  	  R # 5irŒ   )r*   )r�   Úparts   & r   r‘   r!    s   é € Ð'RÑAQ¸¯
©
¯¨ÓAQùs   ‚Ú|)Úsetr&   r   r*   ÚaddÚupdateÚsplitÚ	frozenset)r  Úvariantsrp   r?   s   &   r   Ú_expand_tool_id_variantsr+  ý  sm   € ô ›€HÛˆÜ)¨#¬s×3Ò3�—	‘	”¸ˆß‰5Ø�L‰L˜ÔØ�O‰OÑXÑ'RÀÇÁÈSÔAQÔ'RÓXÖXñ	 ô
 �XÓÐr   c               ó    € V ^8„  d   QhRRRR/# )r   r^   r   r   r  r   )r   s   "r   r   r   	  s   € ÷ lñ l˜cð l nñ lr   c                ó‚   a € \        \        ;QJ d    . V 3R lR 4       F  NK  	  54      # ! V 3R lR 4       4      4      # )z<Return all pairing-id variants carried by a tool-call entry.c              3  ó<   <"  € T F  p\        SV4      x € K  	  R # 5irŒ   )r  )r�   Úkr^   s   & €r   r‘   Ú(tool_call_id_variants.<locals>.<genexpr>  s   øé € Ð)jÑDi¸q¬)°B¸×*:Ð*:ÓDiùs   ƒ)Úcall_idrU   Úresponse_item_id)r+  Útuple)r^   s   fr   r  r  	  s/   ø€ ä#§E¤EÔ)jÑDiÓ)j§EÓkÐk EÔ)jÑDiÓ)jÓ$jÓkÐkr   c               ó    € V ^8„  d   QhRRRR/# )r   Útool_call_idr   r   r  r   )r   s   "r   r   r     s   € ÷ 5ñ 5¨#ð 5°.ñ 5r   c                ó   € \        V 34      # )z>Return all matching variants for a role=tool ``tool_call_id``.)r+  )r5  s   &r   r  r    s   € ä# \ OÓ4Ð4r   c               ó    € V ^8„  d   QhRRRR/# )r   r^   r   r   r   r   )r   s   "r   r   r     s   € ÷ ñ ˜cð  cñ r   c                ó
  € \        V R4      \        V R4      3 Ff  p\        V\        4      '       d   VP                  4       MRpV'       g   K5  VP	                  R^4      ^ ,          P                  4       ;'       g    Tu # 	  R# )zÛEffective call id of a tool_call entry (dict or object); ``""`` when none. Codex Responses
carry ``call_id`` (authoritative pairing key), Chat Completions ``id`` only, and bridge ids
may be ``call_id|response_item_id``.r1  rU   ru   r$  )r  r&   r   r*   r(  )r^   rp   r?   s   &  r   r÷   r÷     sk   € ô ˜"˜iÓ(¬)°B¸Ó*=Ó>ˆÜ)¨#¬s×3Ò3�—	‘	”¸ˆß‰5Ø—;‘;˜s AÓ& qÕ)×/Ñ/Ó1×:Ð:°UÒ:ñ ?ñ r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   rG   ÚtakenúIterable[str]r   r   )r   s   "r   r   r     s!   € ÷ *ñ * tð *°Mð *È4ñ *r   c                ó’  aa€ \        V4      oT ;'       g    .  EF  p\        VR4      ;'       g    \        VR4      ;'       g    Rp\        V\        4      '       d   VP	                  4       MRpVP                  R^4      ^ ,          oS'       g   Ky  SS9  d   SP                  S4       K“  \        VV3R l\        ^\        S4      ^,           4       4       4      pSP                  V4        \        VR4      p\        TR\        V\        4      '       d&   RV9   d   V RVP                  R^4      ^,           2MT4       \        VR4      '       d   \        VRV4       \        \        TR4      R4      ;'       g    R	p\        P                  R
SYF4       EK‚  	  V #   \         d    \        P                  RS4        EK«  i ; i)uØ  Ensure every tool call in one assistant turn has an id no other call in the session has.

Some providers reuse one id across a batch, and some name every call ``call_0`` turn after
turn; the pre-API sanitizer then keeps only the first call/result pair per id, strict
providers reject duplicates, and the desktop binds a tool card to the wrong call. ``taken``
is the ids already in this session's history: they are never rewritten (prompt cache), so
the incoming call is renamed instead. Collisions get a deterministic ``<id>_d<n>`` suffix
(never uuid4 â€” cache-prefix stability). Mutates entries (SDK models / SimpleNamespace /
dicts) in place. Blank ids are left for the deterministic fallback in
``build_assistant_message``.
r1  rU   ru   r$  c              3  óN   <"  € T F  pS R V 2S9  g   K  S R V 2x € K  	  R# 5i)Ú_dNr   )r�   r—   ÚcidÚseens   & €€r   r‘   Ú)uniquify_tool_call_ids.<locals>.<genexpr>7  s3   øé € ÐbÑ-D¨È3È%ÈrÐRSÐQTÈÐ]aÑHa”m˜˜˜R ˜s•mÓ-Dùs   ƒ%–%z,Could not uniquify duplicate tool call id %srT   r   Ú?ziModel reused tool call id %s; renamed the duplicate to %s (tool=%s) to keep call/result pairing lossless.)r%  r  r&   r   r*   r(  r&  Únextr¨   rv   r  Ú	Exceptionr£   r¤   )	r   r:  r^   rp   Únew_idÚoldÚ_fn_namer?  r@  s	   &&     @@r   r  r    sƒ  ù€ ô �E“
€DØ×Ð˜BÓˆä˜˜IÓ&×CÐC¬)°B¸Ó*=×CÐCÀˆÜ'¨¬S×1Ò1ˆc�i‰iŒk°rˆà�i‰i˜˜QÓ Õ"ˆßÙØ�dŒ?Ø�H‰H�SŒMÙäÕb¬U°1´c¸$³iÀ!µmÔ-DÓbÓbˆØ�‰�Ôð	ä˜B Ó%ˆCÜ�B˜ÄJÈsÔTW×DXÒDXÐ]`ÐdgÔ]g  ¨¨#¯)©)°C¸Ó*;¸AÕ*>Ð)?Ñ@ÐmsÔtÜ˜˜Y×'Ò'Ü˜˜I vÔ.ô œY r¨:Ó6¸Ó?×FÐFÀ3ˆÜ�‰ð Ø!$ f÷	
ñ3 ð: Ðøô ô 	Ü�N‰NÐIÈ3ÔOÛð	ús   Ã/A3F Æ !GÇGc               ó    € V ^8„  d   QhRRRR/# )r   r   rG   r   r   )r   s   "r   r   r   M  s   € ÷ ñ °ð ¸$ñ r   c           
     ó„  € \        T ;'       g    . 4      ^8  d   V # \        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       g   V # \        P                  R4       V  FÌ  pR
 FÃ  p\	        W4      p\        V\        4      '       g   K&  VP                  4       P                  R4      w  rEpVP                  4       pVP                  \        4      '       g   Ku  \        P                  ! VP                  RR4      4      P                  4       R,          p\        WR	V V V 24       KÅ  	  KÎ  	  V # )zãRewrite known provider ids when a parallel batch would be rejected on replay.

The digest is deterministic so persisted messages and prompt-cache prefixes remain
stable. Composite Responses ids retain their response-item half.
c              3  ó^   "  € T F#  p\        V4      P                  \        4      x € K%  	  R # 5irŒ   )r÷   Ú
startswithÚ_PROVIDER_TOOL_ID_PREFIXES)r�   r^   s   & r   r‘   Ú3normalize_provider_tool_call_ids.<locals>.<genexpr>W  s(   é € ÐeÑZdÐTVÔ$ RÓ(×3Ñ3Ô4N×OÐOÓZdùs   ‚+-FTzJNormalized provider-minted parallel tool-call ids for replay compatibilityr$  rÊ   Úsurrogatepassr  r  )rU   r1  )rv   Úallr£   r¤   r  r&   r   r*   Ú	partitionrK  rL  r  r  r3   r  Ú_set_provider_tool_id)r   r^   r8   r?   ÚprimaryÚsepÚitemÚdigests   &       r   rû   rû   M  s  € ô ˆ:×Ð˜Ó˜qÔ ØÐ÷ ‹3ÑeÑZdÓe�3�3Š3ÑeÑZdÓe×eÒeØÐÜ
‡N�NÐ_Ô`Ûˆó %ˆCÜ˜bÓ&ˆEÜ˜e¤S×)Ò)ÙØ!&§¡£×!8Ñ!8¸Ó!=ÑˆG˜$Ø—m‘m“oˆGØ×%Ñ%Ô&@×AÒAÙô —^’^ G§N¡N°7¸OÓ$LÓM×WÑWÓYÐZ]Õ^ˆFÜ! "¨U°6°(¸3¸%À¸vÐ+FÖGó %ñ ð Ðr   c               ó(   € V ^8„  d   QhRRRRRRRR/# r
  r   )r   s   "r   r   r   l  s(   € ÷  ñ  ˜cð  ¨ð  °Cð  ¸Dñ  r   c                óÔ   € \        \        \        V 4      VR 4      \        4      '       d2   \        \        V RR 4      \        4      '       d   W P
                  V&   R # \        WV4       R # )NÚprovider_data)r&   rk   rÓ   Úpropertyr=   rX  r  r  s   &&&r   rQ  rQ  l  sO   € ô ”'œ$˜r›( C¨Ó.´×9Ò9¼jÌÐQSÐUdÐfjÓIkÔmq×>rÒ>rØ %×Ñ˜Óä�˜Ör   Úkimizkimi-codingzkimi-coding-cnÚdeepseekÚmimoÚxiaomiÚ	missingnor3  Ú_REASONING_ECHO_RULESÚreasoning_contentÚ	reasoningÚreasoning_detailsÚ	fireworksÚ_REASONING_CARRIER_ROUTESc                  ó0   € ] tR tRt$ RtR]R&   R]R&   RtR# )	ÚReasoningReplayRoutei¤  a
  ``pad``: must-echo tier (missing reasoning_content -> " "). ``carriers``: the reasoning
keys an assistant wire copy carries; ``None`` outside chat_completions, where the native
adapters own reasoning replay (only the must-echo pad is applied, details are untouched).r;   Úpadúfrozenset | NoneÚcarriersr   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   r   r   rf  rf  ¤  s   ‡ ñað 
ƒIØ×r   rf  c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r   Úfamilyr   Úproviderr   ÚmodelÚbase_urlr   r;   r   )r   s   "r   r   r   ­  s1   € ÷ 
ñ 
¨#ð 
¸ð 
ÀSð 
ÐTWð 
Ð\`ñ 
r   c                óÈ  aa	a
€ ^ RI Ho	 \        V ,          w  rErgpT;'       g    RP                  4       o
W9   ;'       g¤    T;'       g    RP                  4       V9   ;'       g    \        ;QJ d    V
3R lV 4       F  '       g   K   RM	  RM! V
3R lV 4       4      ;'       g=    \        ;QJ d     VV	3R lV 4       F  '       g   K   R# 	  R# ! VV	3R lV 4       4      # )z¥True when (provider, model, base_url) matches one echo-back family (families can overlap;
membership is tested independently). Raises KeyError for an unknown family.©Úbase_url_host_matchesru   c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5irŒ   r   )r�   r   Úmodel_lowers   & €r   r‘   Ú0matches_reasoning_echo_family.<locals>.<genexpr>¶  s   øé € Ð8©Z c�kÖ!«Zùrç   TFc              3  ó6   <"  € T F  pS! SV4      x € K  	  R # 5irŒ   r   )r�   Úhostru  rx  s   & €€r   r‘   r{  ¶  s!   øé € Ð?xÑrwÐjnÑ@UÐV^Ð`d×@eÐ@eÓrwùó   ƒ)Úutilsrx  Ú_REASONING_ECHO_RULE_BY_FAMILYrÁ   rè   )rr  rs  rt  ru  r$   Úraw_providersÚlowered_providersÚ
model_subsÚhostsrx  rz  s   &&&f     @@r   rù   rù   ­  sÁ   ú€ õ ,ä=[Ð\bÕ=cÑ:€AÐ'°UØ—;�;˜B×%Ñ%Ó'€KàÑ!÷ 	yð 	y h§n n°"×%;Ñ%;Ó%=ÐARÑ%R÷ 	yð 	yß‹3Ô8©ZÓ8�3�3Š3Ô8©ZÓ8Ó8÷	yð 	yß<?»CÕ?xÑrwÓ?x¿C¼Cðâ<?ðà<?Õ?xÑrwÓ?xÓ<xðr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rs  r   rt  ru  r   r‰   r   )r   s   "r   r   r   º  s.   € ÷ lñ l Cð l°ð l¸sð lÀzñ lr   c                óR   a aa€ R \          4       p\        VVV 3R lV 4       R4      # )zŸ``"kimi"`` / ``"deepseek"`` / ``"mimo"`` (first match in table order) when the endpoint
enforces reasoning_content echo-back on tool-call turns, else ``None``.c              3  ó2   "  € T F  q^ ,          x € K  	  R# 5i)é    Nr   )r�   Úrules   & r   r‘   Ú(reasoning_echo_family.<locals>.<genexpr>½  s   é € Ð:Ñ$9˜D�Q—’Ó$9ùs   ‚c              3  óT   <"  € T F  p\        VSSS4      '       g   K  Vx € K  	  R # 5irŒ   )rù   )r�   Úfru  rt  rs  s   & €€€r   r‘   rŠ  ¾  s#   øé € Ðd™H�qÔ(EÀaÈÐSXÐZb×(c—’›Hùs   ƒ(ž
(N)r_  rC  )rs  rt  ru  Úfamiliess   fff r   rý   rý   º  s$   ú€ ñ ;Õ$9Ó:€HÜÖd™HÓdÐfjÓkÐkr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rs  r   rt  ru  r   r;   r   )r   s   "r   r   r   Á  s.   € ÷ Hñ H 3ð H¨sð H¸cð HÀdñ Hr   c                ó   € \        WV4      RJ# )zQTrue when the endpoint requires reasoning_content echo-back (the must-echo tier).N)rý   )rs  rt  ru  s   &&&r   rú   rú   Á  s   € ä  °(Ó;À4ÐGÐGr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rs  r   ru  r   r)  r   )r   s   "r   r   r   Æ  s!   € ÷ ñ  sð °cð ¸iñ r   c                ón  aaa€ ^ RI Ho T ;'       g    RP                  4       P                  4       o\	        VVV3R l\
         4       R4      pVf2   ^ RIHp S'       d   V! \        S4      4      '       d   \        M\        p\        V9  d(   V'       d    \        S4      '       d   V\        0,          pV# )zSReasoning carriers the chat-completions route reads (before any runtime rejection).rw  ru   c              3  óÄ   <"  € T FU  w  rpSV9   gE   \         ;QJ d     VV3R  lV 4       F  '       g   K   RM	  RM! VV3R  lV 4       4      '       g   KQ  Vx € KW  	  R# 5i)c              3  ó6   <"  € T F  pS! SV4      x € K  	  R # 5irŒ   r   )r�   Úhru  rx  s   & €€r   r‘   Ú5route_reasoning_carriers.<locals>.<genexpr>.<genexpr>Í  s   øé € Ð.aÑ[`ÐVWÑ/DÀXÈq×/QÐ/QÓ[`ùr~  TFN)rè   )r�   ÚcÚ	providersr„  ru  rx  Úprovider_lowers   &   €€€r   r‘   Ú+route_reasoning_carriers.<locals>.<genexpr>Ì  sG   øé € ð 	cÑ&?Ñ"ˆq˜UØ˜iÔ'¯3«3Õ.aÑ[`Ó.a¯3¯3ª3Õ.aÑ[`Ó.a×+a÷ 
ŠÓ&?ùs   ƒA �A µA Á
A N)Úis_local_endpoint)r  rx  r*   rÁ   rC  rd  Úagent.model_metadatarš  r   Ú_LOCAL_CARRIERSÚ_DEFAULT_CARRIERSÚRDÚ _profile_declares_native_details)rs  ru  ri  rš  rx  r˜  s   &f  @@r   r  r  Æ  sˆ   ú€ å+à—n�n "×+Ñ+Ó-×3Ñ3Ó5€NÜö	cÕ&?ó 	càó€Hð
 ÒÝ:ç&.Ñ3DÄSÈÃ]×3SÒ3S•?ÔYjˆÜ	�ÔŸhÔ+KÈN×+[Ò+[Øœr˜d•?ˆØ€Or   c               ó    € V ^8„  d   QhRRRR/# )r   r˜  r   r   r;   r   )r   s   "r   r   r   Ù  s   € ÷ fñ f°Sð f¸Tñ fr   c                óZ   € V '       g   R# ^ RI Hp \        \        V! V 4      RR4      4      # )z\A profile declaring ``native_reasoning_details_type`` consumes replayed details by contract.F)Úget_provider_profileÚnative_reasoning_details_typeN)r—  r¢  r;   rk   )r˜  r¢  s   & r   rŸ  rŸ  Ù  s'   € çÙÝ.ä”Ñ,¨^Ó<Ð>]Ð_cÓdÓeÐer   Úecho_opt_inÚrejectedc               ó4   € V ^8„  d   QhRRRRRRRRRRRR	R
R/# )r   Úapi_moder   rs  rt  ru  r¤  r;   r¥  r;  r   rf  r   )r   s   "r   r   r   â  sO   € ÷ Bñ BØðBØ ðBØ),ðBØ8;ðBØMQðBàðBð ñBr   c               óê   € \        V4      ;'       g    \        WV4      pT ;'       g    RR8w  d   \        VR4      # \        W4      \	        V4      ,
          p\        T;'       d
    \
        V9   V4      # )zµReplay decision for one route. Deterministic in its inputs, so the wire prefix is byte-stable
across turns and changes only on a route switch or a recorded rejection (``rejected``).Úchat_completionsN)r;   rú   rf  r  r)  ÚRC)r§  rs  rt  ru  r¤  r¥  rg  ri  s   &&&&$$  r   rþ   rþ   â  sj   € ô ˆ{Ó
×
NÐ
NÔ3°HÀXÓN€CØ×&Ð&Ð&Ð+=Ô=Ü# C¨Ó.Ð.Ü'¨Ó;¼iÈÓ>QÕQ€Hä × 6Ð 6¬¨h©¸ÓAÐAr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   r§  r   rs  rt  ru  r   r;   r   )r   s   "r   r   r   ð  s1   € ÷ *ñ *¨#ð *¸ð *ÀSð *ÐTWð *Ð\`ñ *r   c                ó>  € T ;'       g    RR8X  d   ^ RI Hp V! W24      '       d   R# V '       g   \        WV4      # \        WW#4      pVP                  f$   T ;'       g    RR8g  ;'       d    VP
                  # \        VP                  \        \        0,          4      # )u  True when stale assistant reasoning text is actually replayed on the wire for the route.

The single wire-truth predicate the compaction TRIGGER estimator and the tail-budget
walks must share: if they disagree, a reasoning-heavy session can look over-threshold
to preflight yet fully tail-protected to the walk â€” an infinite compaction loop.
``codex_responses`` never reads the text keys (continuity rides the encrypted sidecar).
A runtime rejection is not visible here; both sides then over-charge identically.
ru   Úanthropic_messages)Ú)native_anthropic_preserves_prior_thinkingTÚcodex_responses)	Úagent.anthropic_thinking_policyr®  rú   rþ   ri  rg  r;   rª  ÚR)r§  rs  rt  ru  r®  Úroutes   &&&&  r   r  r  ð  s€   € ð 	�ˆ�BÐ/Ô/Ý]Ù4°X×EÒEÙßä# H°XÓ>Ð>Ü" 8°uÓG€EØ‡~�~ÒØ—�˜BÐ#4Ñ4×BÐB¸¿¹ÐBÜ�—‘¤"¤a Õ(Ó)Ð)r   c               ó    € V ^8„  d   QhRRRR/# )r   rO   r   r   ztuple[Any, tuple[str, ...]]r   )r   s   "r   r   r     s   € ÷ 1/ñ 1/°Sð 1/Ð=Xñ 1/r   c                ó2  € \        V \        4      '       g   V R	3# ^ RIHp . p. pV  Fá  p\        V\        4      '       d   VP                  R4      R8w  d   VP                  V4       KB  RR/pR
 F  pWd9   g   K  WF,          WV&   K  	  VP                  R4      p\        V\        4      '       d   V'       d   WuR&   V! V4      w  r‰V	'       d   VP                  RR4       VP                  R V	 4       4       VP                  V4       Kã  	  V\        V4      3# )aú  Return the native Anthropic wire shadow plus readable replay thinking out-of-band.

Canonical history may retain storage-only reasoning alongside signed replay carriers.
Native conversion prefers ordered anthropic_content_blocks over reasoning_details and
never sends reasoning itself. The generic message estimator therefore receives only
ordinary wire-shaped fields, while readable thinking is returned separately for the
explicit Anthropic accounting seam. Opaque signature/data bytes are never priced.
)Úassistant_replay_carrierr   rµ   r   r`  Úapi_contentNc              3  óÔ   "  € T F^  pVP                  R 4      R8X  g   K  \        VP                  R4      \        4      '       g   KB  VR,          '       g   KS  VR,          x € K`  	  R# 5i)rÓ   ÚthinkingN)r>   r&   r   )r�   Úblocks   & r   r‘   Ú9native_anthropic_accounting_projection.<locals>.<genexpr>1  s\   é € ð !
á �Ø�y‰y˜Ó  JÑ.ô ä3=¸e¿i¹iÈ
Ó>SÔUX×3Yô à^cÐdn×^oÑ^oô ˆE�*×ÒÛ ùs   ‚A(Ÿ"A(ÁA(ÁA(r   )r   r   r`  Úcache_control)r&   rG   Úagent.anthropic_message_convertrµ  r=   r>   rI   r   rE   Úextendr3  )
rO   rµ  Ú	projectedÚreplayed_thinkingÚmessageÚshadowr8   Úsidecarr$   Úcarriers
   &         r   Ú&native_anthropic_accounting_projectionrÄ    s  € ô �h¤×%Ò%Ø˜ˆ|ÐåHà€IØ#%ÐÛˆÜ˜'¤4×(Ò(¨G¯K©K¸Ó,?À;Ô,NØ×Ñ˜WÔ%Ùð ˜+Ð&ˆÛRˆCØŽ~Ø%�l�“ñ Sð —+‘+˜mÓ,ˆÜ�gœs×#Ò#¯Ø '�9Ñá-¨gÓ6‰
ˆ÷ Ø�J‰JÐ*¨DÔ1à× Ñ ñ !
á ó!
ô 	
ð
 	×Ñ˜Ö ñA ðB ”eÐ-Ó.Ð.Ð.r   c               ó    € V ^8„  d   QhRRRR/# )r   rY   r=   r   r‰   r   )r   s   "r   r   r   :  s   € ÷ ñ  Dð ¨Zñ r   c                ó²   € \         \        3 FF  pV P                  V4      p\        V\        4      '       g   K,  VP                  4       '       g   KD  Vu # 	  R# )zUThe turn's reasoning text: a non-blank ``reasoning_content`` wins over ``reasoning``.N)rª  r±  r>   r&   r   r*   )rY   r8   r?   s   &  r   Ú_replayable_reasoning_textrÇ  :  s>   € ä”A‹wˆØ—‘˜“ˆÜ�eœS×!Ô! e§k¡k§m¤mØŠLñ ñ r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Ú
source_msgr=   Úapi_msgr   re   r   )r   s   "r   r   r   C  s!   € ÷ 
ñ 
¨Dð 
¸4ð 
ÀDñ 
r   c                ó>  € V P                  \        4      V P                  \        4      r2\        V\        4      '       d   T;'       g    RV\        &   R# \        V\        4      '       d*   V'       d"   V P                  R4      '       g   W1\        &   R# RV\        &   R# )a  Native-adapter wires (``carriers=None``): the pre-replay contract, byte-for-byte. An explicit
value is kept verbatim (legacy "" upgraded to " "); a tool-call turn holding only another
provider's ``reasoning`` is padded instead of converted into a native thinking block.Ú r   N)r>   rª  r±  r&   r   )rÉ  rÊ  Úexistingra  s   &&  r   Ú_apply_legacy_must_echo_padrÎ  C  sf   € ð %Ÿ.™.¬Ó,¨j¯n©n¼QÓ.?ˆiÜ�(œC× Ò Ø—o�o #ˆ”‹Ü	�Iœs×	#Ò	#¯	¸*¿.¹.È×:VÒ:VØ”‹àˆ”‹r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   rÉ  r=   rÊ  Úneeds_thinking_padr;   ri  rh  r   re   r   )r   s   "r   r   r   P  s4   € ÷ ""ñ ""Øð""Ø#ð""Ø9=ð""ØIYð""à	ñ""r   c                óú  € V P                  R4      R8w  d   R# \        V 4      pVe   TM!V'       d   \        \        04      M	\        4       pVf   V'       d   \	        W4       M=\        V9   d   Vf	   V'       d   Ve   TMRV\        &   MVP                  \        R4       \        V9   d   Ve
   WA\        &   MVP                  \        R4       Ve¤   \        V9  d—   VP                  \        R4      ;'       g    R Uu. uFX  p\        V\        4      '       g   K  \        VP                  R4      ;'       g    R4      P                  R4      '       g   KV  VNKZ  	  ppV'       d   Wq\        &   R# R# R# R# u upi )	aÇ  Shape an assistant replay message's reasoning keys for the active route (mutates ``api_msg``).

``needs_thinking_pad`` is the must-echo flag; ``carriers`` the keys the route reads
(``reasoning_replay_route``). ``carriers=None`` is a non-chat-completions wire: only the
must-echo ``reasoning_content`` rides there and ``reasoning_details`` is left to the adapter.
Keys the route does not read are removed, so a strict host never sees one (#45655, #70233).
r   rµ   NrÌ  rÓ   ru   z.native_assistantr   )r>   rÇ  r)  rª  rÎ  rE   r±  rž  r&   r=   r   r©   )rÉ  rÊ  rÐ  ri  r   Ú	effectiveÚdÚprivates   &&&&    r   rö   rö   P  s2  € ð ‡~�~�fÓ Ô,ÙÜ% jÓ1€DØ$Ò0‘×J\´yÄ"À´ÔbkÓbm€IØÒ×.Ü# JÕ8Ü	ˆyŒ˜dÒ.×2Dð #Ò.‘d°Cˆ”Šð 	�‰”B˜ÔÜˆI„~˜$Ò*Ø”Š
à�‰”A�tÔØÒ¤¨(Ô 2ð &Ÿk™k¬"¨dÓ3×9Ð9°rÐ9ó OÑ9˜¼ZÈÌ4×=P”1Ü˜1Ÿ5™5 ›=×.Ð.¨BÓ/×8Ñ8Ð9L×M÷ �1Ñ9ˆð OçØ!”B‹Kñ ñ !3ÑùòOs   Ä E8ÄE8Ä:E8ÅE8c               ó    € V ^8„  d   QhRRRR/# )r   rY   r=   r   r3  r   )r   s   "r   r   r   u  s   € ÷ =ñ =˜$ð = 5ñ =r   c                óx   a € \         ;QJ d    . V 3R  l\         4       F  NK  	  5# ! V 3R  l\         4       4      # )c              3  óF   <"  € T F  pSP                  V4      x € K  	  R # 5irŒ   )r>   )r�   r8   rY   s   & €r   r‘   Ú#_reasoning_shape.<locals>.<genexpr>v  s   øé € Ð<Ñ); #�—‘˜—�Ó);ùs   ƒ!)r3  ÚREASONING_CARRIERS)rY   s   fr   Ú_reasoning_shaperÚ  u  s'   ø€ ßŒ5Ô<Õ);Ó<�5Ð<ˆ5Ô<Õ);Ó<Ó<Ð<r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   rÚ   rG   rÐ  r;   ri  rh  r   rÆ   r   )r   s   "r   r   r   y  s*   € ÷ ñ ¨ð À4ð ÐScð Ðorñ r   c                óö   € ^ pV  Fp  pVP                  R4      R8w  d   K  \        V4      pVf&   V'       d   VP                  \        4      '       d   KO  \        WDW4       V\        V4      V8g  ,          pKr  	  V# )aä  Reconcile already-built assistant turns with the ACTIVE route.

``api_messages`` is built once under the primary; a mid-conversation fallback or a recorded
field rejection changes the route, so baked-in keys are reconciled both ways: TO a must-echo
provider the pad is re-applied (else 400), TO a strict one the keys are stripped (else 422),
and a carrier the new route reads is restored from the text that is still present.
Idempotent. Returns the number of assistant turns changed.
r   rµ   )r>   rÚ  rª  rö   )rÚ   rÐ  ri  ÚchangedrÊ  Úbefores   &&&   r   rü   rü   y  sp   € ð €GÛˆØ�;‰;�vÓ +Ô-ÙÜ! 'Ó*ˆØÒ× 2°w·{±{Ä2·²ÙÜ& wÐ9KÔVØÔ# GÓ,°Ñ6Õ6Šñ  ð €Nr   z"(?<![\w])reasoning_content(?![\w])z"(?<![\w])reasoning_details(?![\w])z.messages[^\n]{0,80}?(?<![\w])reasoning(?![\w])c               ó$   € V ^8„  d   QhRRRRRR/# )r   rà   r   Úsent_messagesr   r)  r   )r   s   "r   r   r   œ  s&   € ÷ Iñ I¨#ð I¸cð IÀiñ Ir   c                óà  a€ \        T ;'       g    R4      P                  4       o\        ;QJ d#    V3R l\         4       F  '       g   K   RM	  RM! V3R l\         4       4      '       g   \	        4       # \        V\        4      '       d   TMR UUu0 uFJ  p\        V\        4      '       g   K  VP                  R4      R8X  g   K3  \         F  q3V9   g   K  VkK  	  KL  	  pppV Uu0 uF)  p\        V,          P                  S4      '       g   K'  VkK+  	  ppV'       g   \	        4       # \	        T\        V9   d   \        ,          4      # \        \        0,          4      # u uppi u upi )aÉ  Reasoning keys to drop after an unknown-field rejection that names one this request carried.

Strict schemas report one offending key per error, so the drop is widened to the keys the
same schema will reject next: a rejected ``reasoning_details`` / ``reasoning`` takes the
other non-standard carrier too (``reasoning_content`` still carries the text); a rejected
``reasoning_content`` (the most widely accepted alias) takes all three. One retry, not three.
ru   c              3  ó,   <"  € T F	  qS9   x € K  	  R # 5irŒ   r   rã   s   & €r   r‘   Ú,rejected_reasoning_fields.<locals>.<genexpr>¥  rð   rç   TFr   rµ   r   )r   rÁ   rè   Ú_UNKNOWN_FIELD_PHRASESr)  r&   rG   r=   r>   rÙ  Ú_NAMED_FIELD_RESÚsearchrª  Ú_ALL_CARRIERSr±  rž  )rà   rà  rY   r8   ÚsentÚnamedrå   s   &&    @r   Úrejected_reasoning_fieldsrê  œ  s  ø€ ô ˆz×Ð˜RÓ ×&Ñ&Ó(€Dß‹3ÔCÕ,BÓC�3�3Š3ÔCÕ,BÓC×CÒCÜ‹{Ðä)3°MÄ4×)HÒ)H™ÈbÐPôÙP�Ü�cœ4× ô 	Ø%(§W¡W¨V£_¸Ñ%Cô 	ßOaÈÐloÑeo÷ 	ˆÙOañ 	ÑPð 	ñ ñ !ÓG™D�SÔ$4°SÕ$9×$@Ñ$@À×$F�SˆS™D€EÐGßÜ‹{ÐÜ�T¬b°E¬kœ]ÕGÓHÐHÄÄ2¸wÕGÓHÐHùóùò Hs$   ÂE%Â1E%Ã	E%Ã
E%Ã+$E+ÄE+c               ó    € V ^8„  d   QhRRRR/# )r   rc   r   r   ztuple[str, str, str]r   )r   s   "r   r   r   ±  s   € ÷ 	ñ 	˜sð 	Ð';ñ 	r   c                ó
  € ^ RI Hp \        V RR4      ;'       g    RP                  4       P	                  4       T! \        V RR4      ;'       g    R4      ;'       g    R\        V RR4      ;'       g    RP                  4       3# )z¬``(provider, base_url host, model)``: one gateway serves models on different upstream lanes,
so a rejection learned for one model must not strip carriers from its siblings.)Úbase_url_hostnamers  ru   ru  rt  )r  rí  rk   r*   rÁ   )rc   rí  s   & r   Úreasoning_route_keyrî  ±  sw   € õ (ô 
�˜
 BÓ	'×	-Ð	-¨2×4Ñ4Ó6×<Ñ<Ó>Ùœ' %¨°RÓ8×>Ð>¸BÓ?×EÐEÀ2Ü	�˜ Ó	$×	*Ð	*¨×1Ñ1Ó3ðð r   Úreasoning_rejected_carriersc               ó    € V ^8„  d   QhRRRR/# )r   rc   r   r   r)  r   )r   s   "r   r   r   À  s   € ÷ Añ A sð A¨yñ Ar   c                ó²  € V P                   P                  R/ 4      p\        V RR4      pV'       Ed   \        V RR4      V8w  dñ   W n        \        \        V RR4      RR4      p\	        V4      '       d   V! V\
        . 4      M. p\        V\        4      '       d   TMR	 F“  p\        V\        4      '       g   K  \        V4      ^8X  g   K-  \        V^,          \        4      '       g   KL  VP                  \        VR,          4      \        4       4      P                  R V^,           4       4       K•  	  \        VP                  \        V 4      R	4      4      # )
zþReasoning keys the active (provider, host, model) rejected in this session.

Persisted in the session's ``model_config`` so a resumed process (``--resume``, a gateway
restart) never re-learns a rejection with another 400. Loaded once per ``session_id``.
Ú_reasoning_rejecting_routesÚ
session_idNÚ _reasoning_rejections_loaded_forÚ_session_dbÚget_session_model_config_value:Né   Nc              3  ó>   "  € T F  q\         9   g   K  Vx € K  	  R # 5irŒ   )rç  )r�   r/  s   & r   r‘   Ú.rejected_reasoning_carriers.<locals>.<genexpr>Î  s   é € ÐAlÉXÈÔ^kÑYkÇ!Â!ËXùs   ‚“
r   )Ú__dict__Ú
setdefaultrk   rô  ÚcallableÚ_REJECTION_MODEL_CONFIG_KEYr&   rG   rv   r3  r%  r'  r)  r>   rî  )rc   Úroutesró  ÚgetterÚstoredÚentrys   &     r   r   r   À  s  € ð �^‰^×&Ñ&Ð'DÀbÓI€FÜ˜ ¨dÓ3€Jß€z”g˜eÐ%GÈÓNÐR\Ô\Ø1;Ô.Üœ ¨°tÓ<Ð>^Ð`dÓeˆÜHPÐQW×HXÒHX‘˜
Ô$?ÀÔDÐ^`ˆÜ)¨&´$×7Ò7‘V¸RÒ?ˆEÜ˜%¤×&Ô&¬3¨u«:¸®?¼zÈ%ÐPQÍ(ÔTX×?YÔ?YØ×!Ñ!¤%¨¨b­	Ó"2´C³EÓ:×AÑAÑAlÈUÐSTÎXÓAlÖlñ @ô �V—Z‘ZÔ 3°EÓ :¸BÓ?Ó@Ð@r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   rc   r   rà   rà  r   r)  r   )r   s   "r   r   r   Ò  s*   € ÷ ñ ¨Cð ¸Sð ÐQTð ÐYbñ r   c                ó  € \        V RR4      R8w  d   \        4       # \        W4      p\        \        V RR4      \        V RR4      \        V RR4      4      '       d   V\        0,          pV'       g   \        4       # V\        V 4      ,
          pV'       g   \        4       # V P                  pVP                  \        V 4      \        4       4      P                  V4       \        \        V RR4      R	R4      p\        V4      '       dx   \        V R
R4      '       de   \        V RR4      '       gR   T! V P                  \        \        VP                  4       4       UUu. uF  w  rx. VO\        V4      NNK  	  upp/4       \        V4      # u uppi )aS  Remember the reasoning keys this route rejected; returns the NEW ones (empty = no retry).

The next ``build_api_request`` re-shapes ``api_messages`` without them for this
(provider, host, model) for the rest of the session. A repeat rejection of an already
recorded key returns empty, so recovery can never loop. History is never touched.
r§  r©  rs  ru   rt  ru  rõ  NÚpatch_session_model_configró  Ú_persist_disabledF)rk   r)  rê  rú   rª  r   rò  rû  rî  r%  r'  rü  ró  rý  ÚsortedrF   )	rc   rà   rà  r]   Únewrþ  Úpatcherr8   Úvs	   &&&      r   rÿ   rÿ   Ò  sW  € ô ˆu�jÐ"4Ó5Ð9KÔKÜ‹{ÐÜ& zÓA€FÜœG E¨:°rÓ:¼GÀEÈ7ÐTVÓ<WÔY`ÐafÐhrÐtvÓYw×xÒxð 	”2�$�ˆßÜ‹{ÐØ
Ô.¨uÓ5Õ
5€CßÜ‹{ÐØ×.Ñ.€FØ
×ÑÔ)¨%Ó0´#³%Ó8×?Ñ?ÀÔDÜ”g˜e ]°DÓ9Ð;WÐY]Ó^€GÜ�×ÒœW U¨L¸$×?Ò?ÌÐPUÐWjÐlq×HrÒHrÙ�× Ñ Ô#>ÔagÐhn×htÑhtÓhvÔawÔ@xÑawÑW]ÐWZÐARÀ3ÐARÌÈqË	ÓARÑawÒ@xÐ"yÔzÜ�S‹>Ðùó Ays   ÅF	)Úinvalid_tool_call)rB  rŒ   >   ÚimageÚ	image_urlÚinput_image)z%only 'text' content type is supportedz#only text content type is supportedzimage_url is not supportedzimage content is not supportedzmultimodal is not supportedz#multimodal content is not supportedz!multimodal input is not supportedzvision is not supportedzvision input is not supportedzdoes not support imageszdoes not support image inputzdoes not support multimodalzdoes not support visionzmodel does not support imagezunexpected item type in contentzimage_url'. expectedz,unknown variant `image_url`, expected `text`z(unknown variant image_url, expected textz+no endpoints found that support image input)z8image data you provided does not represent a valid imagezfailed to decode image)rˆ  r   )r   )zchatcmpl-tool-)zapi.kimi.comzmoonshot.aizmoonshot.cn)r[  )zapi.deepseek.com)r\  )zapi.xiaomimimo.comzxiaomimimo.com)zstealth/missingno>   ÚgroqÚmistralÚcerebrasÚ	sambanova)z
mistral.aizgroq.comzcerebras.aizsambanova.aizhunyuan.cloud.tencent.com)zfireworks.ai>   ÚnousÚkilocodeÚ
openrouterú
ai-gateway)zopenrouter.aizkilo.aizai-gateway.vercel.shznousresearch.com>   ÚnovitaÚminimaxú
minimax-cnútencent-tokenhub)z	novita.aiztokenhub.tencentmaas.comz"tokenhub-intl.tencentcloudmaas.comz
minimax.iozminimaxi.com>   ÚcustomÚupstageÚlmstudioúollama-cloud)z
ollama.comz
upstage.ai)
zextra inputs are not permittedzis unsupportedzno such fieldzunknown fieldzunrecognized request argumentzunrecognized fieldzunknown parameterzunexpected fieldzadditional propertzunknown key)gÚ__conditional_annotations__rn  Ú
__future__r   r  r€   Úloggingr)   Ú	functoolsr   Útypingr   r   r   r   Ú(agent.agent_runtime_helpers_placeholdersr   r	   r¶   r
   Úagent.vision_message_prepr   Ú	getLoggerrj  r£   Úcompiler   r)  rX   r    r'   r,   r5   rA   rM   ra   ri   rô   rm   ró   rõ   rn   r}   r«   rƒ   rŽ   r˜   r¯   r¹   rÂ   rÄ   rÏ   rÕ   rØ   ré   rñ   rÝ   rë   rò   Ú__all__r  r  rø   r+  r  r  r÷   r  rL  rû   rQ  r_  ro  r€  rª  r±  rž  rÙ  rç  r�  rœ  rd  rf  rù   rý   rú   r  rŸ  rþ   r  rÄ  rÇ  rÎ  rö   rÚ  rü   rä  rå  rê  rî  rý  r   rÿ   )r‰  r  s   0@r   Ú<module>r(     s  øðôõ #ã Û Û Û 	Ý ß 6Ó 6ç oÝ 2Ý 9à	×	Ò	˜8Ó	$€ð —
’
Ð-Ó.€ñ  	¨6°<ÀÈÐYÓZÐ õ-ð —j’jÐ!7Ó8Ð ÷
$õAõõõ ñJ ")Ð)<ÐBVÔ!WÐ Ù 'Ð(:Ð@TÐ[_Ô `Ð Ù 'Ð(;ÐAQÔ RÐ Ù&Ð'9Ð?OÐV[Ô\Ð Ø9Ð õ2õ,ð* Ð õð �c˜3 Ð$€õ"O÷J7÷tðD �(Ø	ˆ6Ø�\ðÐ õ
8õ	2ò :Ð õ!ðNÐ ð6Ð õXõFõDðØðØ<ðØ>[ðà"ðà$CðàEdðð %ðð '=ðð ?Zðð "ð	ð $6ð	ð 8Xð	ð
 &ðð
 (?ðð
 ASðð ðð =ðð ?Uðð 'ðð )Aðð CZðð ðð Aðð C`ðð ðð ðð !>ðð @bðð ðð 7ðð 9Qð€õ,Kõ
T÷]õ	õlõ
5õ
÷*ðZ 1Ð õõ> ð4 ‰Y˜Ð'7Ð8Ó9¹9»;ÈÐLzÐ{Ø‘“™i¨¨Ó5°}ÐF[Ð\Ø‰Y‹[™) X JÓ/°Ð<dÐeà‘)“+™y›{Ð,BÀBÐGð Ð �uó ñ =RÓ!RÑ<Q°D q¥'¨4¢-Ñ<QÑ!RÐ à Ð.A€	€€A€rØ˜!˜R�[Ð ÙÐ,Ó-€Ù˜r˜d“OÐ Ù˜R ˜GÓ$€ñ ƒ[‘)ÒHÓIØ[ð]ñ �ˆtƒ_‘i  Ó.Ð0AÐBà‘IÒNÓOØMðOñ ��BˆxÓ™)Ò$[Ó\Ørðtà‘iÒ QÓRÐTpÐqð$Ð ˜5ó ô ˜:ô õ
õlõHõ
õ&fðBØTYðBà ÷Bõ*õ,1/õhõ
÷""õJ=÷ð,Ð ð ˆ�
Š
Ð8Ó9Øˆ�
Š
Ð8Ó9à€r‡z‚zÐCÓDð	Ð õIõ*	ð <Ð õA÷$ùòM
 "Ss   ÈM