§
    ÷žyj"  ã                  ó$   — d Z ddlmZ dgZd
d„Zd	S )uu  Boundary repair for providers that stream reasoning as discrete summary parts.

Reasoning-summary models (OpenAI's gpt-5.x family, and anything relaying the
Responses API onto the OpenAI chat wire) do not stream a chain of thought token
by token. They emit one ``reasoning_content`` delta per *completed* summary
part, each opening with a bold markdown heading::

    {"delta": {"reasoning_content": "**Investigating likely culprit PRs**"}}
    {"delta": {"reasoning_content": "**Inspecting message schema**"}}

On the Responses API those parts are delimited by ``summary_index``
(``response.reasoning_summary_part.added`` / ``.done``). The OpenAI chat wire
carries no such field â€” verified live against Nous Portal's
``openai/gpt-5.6-sol``, whose reasoning chunks contain nothing but
``delta.reasoning_content`` â€” so the boundary cannot be recovered from
metadata, and consumers that concatenate deltas glue the parts together:

    **Investigating likely culprit PRs****Inspecting message schema**

That ``****`` run is neither a bold close nor a bold open to a markdown parser,
so the whole trace renders as one unbroken, unspaced, half-bold paragraph.

The AI SDK hit exactly this (vercel/ai#6742) and fixed it upstream by starting
a new reasoning part per ``summary_index``. That route needs the index, which
this wire does not give us, so we re-derive the boundary from the one signal it
does carry: a delta opening a bold heading. Hermes' own Responses adapter
already joins its summary parts with a blank line
(``agent/codex_responses_adapter.py``), so this brings the chat-completions
stream in line with the path that keeps the structure.
é    )ÚannotationsÚseparate_glued_reasoning_blocksÚpreviousÚstrÚdeltaÚreturnc                óš   — | r|s|S |                      d¦  «        s|S | d                              ¦   «         r|S d|dd…         vr|S d|› �S )aÓ  Return *delta*, prefixed with a paragraph break when it glues onto *previous*.

    *previous* is the reasoning text accumulated so far (only its tail matters).
    A break is inserted when *delta* opens a bold heading and *previous* is
    mid-line, which is the summary-part boundary the chat wire drops. Both
    shapes the upstream issue reports are covered: a heading-only part butting
    against the next heading (``**One****Two**``), and a part whose prose body
    butts against the next heading (``...interaction!**Next**``).

    Token-streamed reasoning is left alone: its deltas carry their own leading
    whitespace, so *previous* ends mid-line only when the model really did run
    two parts together.
    z**éÿÿÿÿé   Nz

)Ú
startswithÚisspace)r   r   s     ú?/home/ragecks/.hermes/hermes-agent/agent/reasoning_summaries.pyr   r   %   sx   € ð ð ˜5ð Øˆà×Ò˜DÑ!Ô!ð Øˆð �„|×ÒÑÔð Øˆð
 �5˜˜˜”9ÐÐØˆà�%ˆ>ˆ>Ðó    N)r   r   r   r   r   r   )Ú__doc__Ú
__future__r   Ú__all__r   © r   r   ú<module>r      sI   ððð ð> #Ð "Ð "Ð "Ð "Ð "à,Ð
-€ðð ð ð ð ð r   