Repository navigation
Separate reasoning summary entries in OpenAI Responses - #7229
Merged
dimitarproynov merged 2 commits intoNov 26, 2026
Merged
dimitarproynov merged 2 commits into
dimitarproynov merged 2 commits into
Conversation
Contributor
Author
Contributor
|
I'll have a look as soon as I'm able |
dimitarproynov
requested changes
Oct 29, 2026
dimitarproynov
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your contribution!
Few remarks below:
Contributor
Author
|
@dimitarproynov I’ve addressed all your review comments. Could you take another look when you have a moment? |
A reasoning item can carry several summary entries, each a separate paragraph that usually opens with its own bold heading. They were joined without a separator, both when building the summary of a called response and when accumulating streamed deltas, so the last sentence of one entry ran straight into the heading of the next. Join the entries of one item with a blank line. On the streaming path the assembler tracks the summary_index of the deltas and prefixes the first delta of each further entry with the same separator, so the raw flux, the aggregated ReasoningPart and the reasoningContent metadata all agree with the non-streaming result. Empty summary entries are skipped on both paths, and an empty delta is dropped without opening an entry or an item, so they add no paragraph break. The separator between different reasoning items and the joining of reasoning content text are unchanged. Signed-off-by: Raviteja Daggupati <raviteja5255@gmail.com>
Rename REASONING_SUMMARY_PART_SEPARATOR to REASONING_SUMMARY_ENTRY_SEPARATOR, to match the summary entries it separates. Say "non-streamed" instead of "called" in the javadoc, comments, test names and test helper, and rename the paragraph test so it starts with its subject like the tests around it. Rewrite the comment on the summary-delta separator in ResponsesStreamAssembler in plain words: when it applies (same output_index, new summary_index) and why the blank line goes into the delta itself. Signed-off-by: Raviteja Daggupati <raviteja5255@gmail.com>
draviteja
force-pushed
the
responses-reasoning-summary-entries
branch
from
November 25, 2026 21:29
9f34118 to
d565123
Compare
Contributor
|
@draviteja Thank you, again, for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A reasoning item in the Responses API can carry several summary entries. Each one is a separate paragraph that usually starts with its own bold heading.
OpenAiResponsesChatModeljoins these entries with nothing between them, so the last sentence of one entry runs straight into the heading of the next:Rendered as Markdown, these headings show up as bold text in the middle of a paragraph, and the whole summary reads as one block.
This happens on both paths:
call:ResponsesItemMapperjoins the summary entries with an empty string.stream:ResponsesStreamAssemblerappends everyresponse.reasoning_summary_text.deltato one running string and ignores the delta'ssummary_index, so the boundary between entries is lost before the chunks reach the caller.To reproduce (2.1.0-RC1,
spring.ai.openai.chat.api=responses):Summary text before and after this change:
Change
ResponsesItemMapperjoins the summary entries of one reasoning item with a blank line (\n\n).ResponsesStreamAssemblertracks thesummary_indexof the summary deltas. When a delta starts a new entry of the same item, the same separator is prepended to that delta. The raw flux, the aggregatedReasoningPartand thereasoningContentmetadata therefore all agree with the non-streaming result.Unchanged:
\nbetween different reasoning items.contenttext, which is still joined without a separator.The
reasoningContentrow of the reference docs is updated to describe both separators.Tests
Added to
ResponsesItemMapperTests:summaryEntriesAreSeparateParagraphsAndEmptyEntriesAreSkippedAdded to
ResponsesStreamAssemblerTests:reasoningSummaryDeltasStartANewParagraphForEachEntryWithinAnItemstreamedSummaryEntriesAggregateToTheSameSummaryAsTheNonStreamedResponsesummaryEntriesThatNeverStreamedComeFromTheCompletedItemsThey use a new fixture,
reasoning-with-summary-entries.json, with three reasoning items: one whose first entry is empty, one whose only entry is empty, and one ending with an empty entry. The streaming test sends an empty delta for every empty entry and checks that each item's summary, andreasoningContent, match the non-streaming result.Also checked manually against the OpenAI API with a sample application: with this change, every summary heading starts its own paragraph on both
callandstream, where before most of them were glued to the end of the previous sentence.