+
    iHàjg  ã                  óR  € R t ^ RIHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHtHt ]P                  ! R]P                  4      t]P                  ! R]P                  4      tRRRRR	R /tR
 R ltR R lt]! RR04      tR R ltRR 3RR 3RR 3RR 33tR R ltR R ltR R ltR# )!a¹  Shared Anthropic prior-turn thinking retention policy.

Anthropic preserves and bills prior assistant thinking on Opus 4.5+, Sonnet
4.6+ and Haiku 5.5+ (plus the newer Fable/Mythos families). Older models
accept replayed blocks but strip them server-side. Keep the model capability
and the per-endpoint replay contract in one place so message conversion and
context accounting cannot diverge.

Unknown or future Claude ids default to keep: replaying a block the API
strips costs nothing, while stripping on a model that keeps it rewrites the
cached prefix on every call. Only the known last-turn-only generations
(Claude 3, Haiku < 5.5, Opus < 4.5, Sonnet < 4.6) strip. Non-Claude ids never keep.
)ÚannotationsN)ÚAny)Ú_is_claude_platform_endpointÚ_is_deepseek_anthropic_endpointÚ_is_kimi_family_endpointÚ_is_minimax_anthropic_endpointÚ_is_nous_portal_endpointÚ"_is_third_party_anthropic_endpointÚ _model_name_is_deepseek_thinkingzSclaude[-_.](opus|sonnet|haiku|fable|mythos)[-_.](\d+)(?:[-_.](\d{1,2})(?=$|[-_.]))?zclaude[-_.]?3(?!\d)ÚopusÚsonnetÚhaikuc               ó    € V ^8„  d   QhRRRR/# )é   Úmodelr   Úreturnz"tuple[str, tuple[int, int]] | None© )Úformats   "ÚD/home/ubuntu/.hermes/hermes-agent/agent/anthropic_thinking_policy.pyÚ__annotate__r   *   s   € ÷ 	"ñ 	" ð 	"Ð)Kñ 	"ó    c                óP  € \        V \        4      '       g   R # \        P                  V P	                  4       4      pV'       g   R # VP                  ^4      P                  4       p\        VP                  ^4      4      p\        VP                  ^4      ;'       g    ^ 4      pW#V33# ©N)Ú
isinstanceÚstrÚ_CLAUDE_VERSION_REÚsearchÚstripÚgroupÚlowerÚint)r   ÚmatchÚfamilyÚmajorÚminors   &    r   Úclaude_family_versionr%   *   s}   € Ü�eœS×!Ò!ÙÜ×%Ñ% e§k¡k£mÓ4€EßÙØ�[‰[˜‹^×!Ñ!Ó#€FÜ�—‘˜A“Ó€EÜ�—‘˜A“×#Ð# !Ó$€EØ˜5�>Ð!Ð!r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   Úboolr   )r   s   "r   r   r   6   s   € ÷ 9ñ 9¨#ð 9°$ñ 9r   c                óî   € \        V \        4      '       d1   RV P                  4       9  g   \        P	                  V 4      '       d   R# \        V 4      pVf   R# Vw  r#V\        P                  VR4      8¬  # )zJWhether Anthropic keeps prior assistant thinking in model-visible context.ÚclaudeFT)é   é    )r   r   r   Ú_LAST_TURN_ONLY_REr   r%   Ú_KEEP_ALL_FROMÚget)r   Úparsedr"   Úversions   &   r   Úmodel_preserves_prior_thinkingr1   6   sb   € ä�eœS×!Ò! X°U·[±[³]Ô%BÔFX×F_ÑF_Ð`e×FfÒFfÙÜ" 5Ó)€FØ‚~ÙØ�O€FØ”n×(Ñ(¨°Ó8Ñ8Ð8r   ÚnativeÚminimaxc               ó    € V ^8„  d   QhRRRR/# )r   Úbase_urlr   r   r'   r   )r   s   "r   r   r   F   s   € ÷ cñ c ð c¨ñ cr   c                óH   € \        V 4      ;'       d    \        V 4      '       * # r   )r	   r   )r5   s   &r   Ú_is_off_anthropicr7   F   s   € Ü-¨hÓ7×bÐbÔ@XÐYaÓ@bÔ<bÐbr   Úkimic                ó   € \        W4      # r   )r   ©Úurlr   s   &&r   Ú<lambda>r<   M   s
   € Ô 8¸Ô Dr   Údeepseekc                ód   € \        V 4      ;'       g    \        V 4      ;'       d    \        V4      # r   )r   r7   r
   r:   s   &&r   r<   r<   N   s2   € Ô$CÀCÓ$H÷ %Pð %PÜ˜cÓ"×NÐNÔ'GÈÓ'Nð%Pr   c                óH   € \        V 4      '       * ;'       g    \        V 4      # r   )r7   r   r:   s   &&r   r<   r<   P   s   € Ô&7¸Ó&<Ô"<×"aÐ"aÔ@\Ð]`Ó@aÐ"ar   c                ó   € \        V 4      # r   )r   r:   s   &&r   r<   r<   Q   s
   € Ô#AÀ#Ô#Fr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r5   r   r   r   r   r   )r   s   "r   r   r   U   s&   € ÷ gñ g sð g°3ð g¸3ñ gr   c                ó<   a a€ \        V V3R l\         4       R4      # )aÝ  Which thinking-replay contract an Anthropic Messages request follows: ``kimi`` (replay as-is),
``deepseek`` (unsigned only), ``native`` (Anthropic-signed blocks: the direct API, Nous Portal,
Bedrock, Vertex AI, Azure AI Foundry), ``minimax`` (its own signed blocks, returned unchanged on
every turn as its docs require) or ``third_party`` (an unknown relay that cannot verify Anthropic
signatures: strip all). The converter, accounting and signature-rejection state share this.c              3  óN   <"  € T F  w  rV! SS4      '       g   K  Vx € K  	  R # 5ir   r   )Ú.0ÚrouteÚmatchesr5   r   s   &  €€r   Ú	<genexpr>Ú+anthropic_thinking_route.<locals>.<genexpr>[   s   øé € ÐV©\™>˜5¹WÀXÈu×=U—’«\ùs   ƒ%›
%Úthird_party)ÚnextÚ_ROUTE_RULES©r5   r   s   ffr   Úanthropic_thinking_routerM   U   s   ù€ ô ÕV­\ÓVÐXeÓfÐfr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   rE   r   r   r   r   r'   r   )r   s   "r   r   r   ^   s&   € ÷ _ñ _¨ð _°Cð _¸Dñ _r   c                óL   € V R8H  ;'       g    V R8H  ;'       d    \        V4      # )z\Whether ``route`` replays signed thinking on assistant turns before the in-flight tool loop.r3   r2   )r1   )rE   r   s   &&r   Úroute_replays_prior_thinkingrP   ^   s)   € à�IÑ×^Ð^ %¨8Ñ"3×"]Ð"]Ô8VÐW\Ó8]Ð^r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r5   r   r   r   r'   r   )r   s   "r   r   r   c   s&   € ÷ Zñ Z¸ð ZÀCð ZÈDñ Zr   c                ó,   € \        \        W4      V4      # )z¨True when the route replays (and the model keeps) signed thinking from earlier turns, so stale
thinking reaches the wire and accounting must charge the signed carriers.)rP   rM   rL   s   &&r   Ú)native_anthropic_preserves_prior_thinkingrS   c   s   € ô (Ô(@ÀÓ(QÐSXÓYÐYr   )é   r*   )rT   é   )r*   r*   )Ú__doc__Ú
__future__r   ÚreÚtypingr   Úagent.anthropic_endpointsr   r   r   r   r   r	   r
   ÚcompileÚ
IGNORECASEr   r,   r-   r%   r1   Ú	frozensetÚSIGNED_REPLAY_ROUTESr7   rK   rM   rP   rS   r   r   r   Ú<module>r_      sÓ   ðñõ #ã 	Ý ÷÷ ñ ð —Z’Zð [Ø‡M�Mó	Ð ð —Z’ZÐ 6¸¿¹ÓFÐ Ø˜& (¨F°G¸VÐD€õ	"õ9ñ ! (¨IÐ!6Ó7Ð õcð ÑDÐEØñ Pð QàÑaÐbØÑFÐGð€õgõ_÷
Zr   