+
    iHàjß  ã                  ój   € R t ^ RIHt ^ RIHt ^ RIHt RR.tR R ltRR	R
R/t	Rt
R R ltR R ltR# )aU  Boundary repair for providers that stream reasoning as discrete summary parts.

Reasoning-summary models (OpenAI gpt-5.x and Responses-API relays onto the chat wire) emit one
``reasoning_content`` delta per *completed* summary part, each opening with a bold heading.
The chat wire lacks the Responses API's ``summary_index`` delimiter (verified live on Nous
Portal ``openai/gpt-5.6-sol``), so plain concatenation glues ``**One****Two**`` into one
half-bold paragraph. The boundary is re-derived from a delta opening a bold heading, matching
the blank-line join Hermes' own Responses adapter does.
)Úannotations)ÚAny)Úflatten_message_textÚ append_streamed_reasoning_detailÚseparate_glued_reasoning_blocksc               ó$   € V ^8„  d   QhRRRRRR/# )é   ÚpreviousÚstrÚdeltar   Úreturn© )Úformats   "Ú>/home/ubuntu/.hermes/hermes-agent/agent/reasoning_summaries.pyÚ__annotate__r      s!   € ÷ .ñ .¨cð .¸#ð .À#ñ .ó    c                óô   € \        VRR7      pT ;'       dT    T;'       dJ    V R,          P                  4       '       * ;'       d&    VP                  R4      ;'       d    RVR,          9   pV'       d   RV 2# T# )u¶  Return *delta*, prefixed with a paragraph break when it glues onto *previous*.

A break is inserted when *delta* opens a *closed* bold heading and *previous* is mid-line
(heading butting heading, or prose butting heading). Token-streamed reasoning is left
alone: its deltas carry their own whitespace, and a fragment that merely opens emphasis
(``**`` alone) is not a part boundary â€” summary parts carry the whole heading in one delta.
Ú )Úsepz**:r   NNz

éÿÿÿÿ)r   ÚisspaceÚ
startswith)r	   r   Úglueds   && r   r   r      sq   € ô ! ¨BÔ/€EØ×nÐn˜×nÐn x°¥|×';Ñ';Ó'=Ô#=×nÐnÀ%×BRÑBRÐSWÓBX×nÐnÐ]aÐejÐkmÕenÑ]n€Eß"ˆT�%�ˆ>Ð-¨Ð-r   zreasoning.textÚtextzreasoning.summaryÚsummaryc               ó    € V ^8„  d   QhRRRR/# )r   Údetailr   r   r
   r   )r   s   "r   r   r   '   s   € ÷ 1ñ 1¨3ð 1°3ñ 1r   c                ój  € \        V \        4      '       d   V P                  R4      M\        V RR4      p\        V\        4      '       d   \
        P                  V4      MRpVf   R# \        V \        4      '       d   V P                  V4      M\        WR4      p\        V\        4      '       d   V# R# )zGReadable text from a detail delta; never expose opaque replay material.ÚtypeNr   )Ú
isinstanceÚdictÚgetÚgetattrr
   Ú_MERGEABLE_DETAIL_TEXT_KEYS)r   ÚdtypeÚkeyr   s   &   r   Ústreamed_reasoning_detail_textr&   '   s‹   € ä",¨V´T×":Ò":ˆF�J‰J�vÔÄÈÐPVÐX\Ó@]€EÜ4>¸uÄc×4JÒ4JÔ
%×
)Ñ
)¨%Ô
0ÐPT€CØ
‚{ÙÜ(¨´×6Ò6ˆ6�:‰:�cŒ?¼GÀFÐQUÓ<V€DÜ˜d¤C×(Ò(ˆ4Ð0¨bÐ0r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Údetails_accÚlistr   r   r   ÚNoner   )r   s   "r   r   r   1   s!   € ÷ %ñ %°$ð %Àð %Èñ %r   c                óê  € \        V\        4      '       gP   \        VR4      '       d   VP                  RR7      pM*\        VR4      '       d   \        VP                  4      pMR# VP                  R4      p\        P                  V4      pV '       d
   V R,          MRpVe·   V'       d¯   VP                  R4      V8X  d™   \        VP                  V4      \        4      '       dt   VP                  V4      ;'       g    RW,          ,           WC&   \         F=  pVP                  V4      R	9   g   K  VP                  V4      R	9  g   K3  W,          WE&   K?  	  R# V P                  \        V4      4       R# )
a  Accumulate one streamed ``reasoning_details`` delta entry into *details_acc*.

OpenRouter streams ``reasoning_details`` as word-level deltas: consecutive
``reasoning.text`` / ``reasoning.summary`` entries are fragments of one logical
block and are merged (later fragments backfill ``signature``/``id`` the first
omitted); encrypted/opaque entries stay discrete. Unmerged, a long thought
replays as hundreds of one-word entries and providers that validate the
sequence shape on the next turn reject it. SDK objects are normalized to dicts.
Ú
model_dumpF)ÚwarningsÚ__dict__Nr   r   r   )Nr   )
r   r    Úhasattrr,   r.   r!   r#   r
   Ú_BACKFILL_DETAIL_KEYSÚappend)r(   r   r$   Ú	merge_keyÚlastÚks   &&    r   r   r   1   s  € ô �fœd×#Ò#Ü�6˜<×(Ò(Ø×&Ñ&°Ð&Ó6‰FÜ�V˜Z×(Ò(Ü˜&Ÿ/™/Ó*‰FáØ�J‰J�vÓ€EÜ+×/Ñ/°Ó6€Iß)ˆ;�rŽ?¨t€DØÒŸI¨$¯(©(°6Ó*:¸eÔ*CÌ
ÐSY×S]ÑS]Ð^gÓShÔjm×HnÒHnØŸ8™8 IÓ.×4Ð4°"¸Õ8IÕIˆ‰ß&ˆAØ�x‰x˜‹{˜jÖ(¨V¯Z©Z¸«]À*Ö-LØ �)�“ñ 'ñ 	Ø×Ñ”t˜F“|Ö$r   N)Ú	signatureÚidr   Úindex)Ú__doc__Ú
__future__r   Útypingr   Úagent.message_contentr   Ú__all__r   r#   r0   r&   r   r   r   r   Ú<module>r=      sG   ðñõ #å å 6à-Ð/PÐ
Q€õ.ð  0°Ð9LÈiÐXÐ Ø>Ð õ1÷%r   