fix: merge ShareGPT tool observations#10578
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the dataset converter to merge consecutive tool observation messages into a single observation message separated by tool response tags, and adds a corresponding unit test. A review comment identifies a critical issue where pending tool responses are not flushed if the conversation history ends with an observation message, and provides a code suggestion to resolve this bug.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "content": content, | ||
| } | ||
| ) | ||
|
|
There was a problem hiding this comment.
If the conversation history ends with an observation message (which is common in pairwise/ranking datasets where the final assistant response is stored in chosen/rejected instead of the conversations list), any pending tool_responses will not be flushed because the loop terminates before encountering a non-observation message. We should flush any remaining tool_responses after the loop finishes.
if len(tool_responses) > 0:
observation_content = "\n</tool_response>\n<tool_response>\n".join(tool_responses)
aligned_messages.append(
{
"role": Role.OBSERVATION.value,
"content": observation_content,
}
)
Summary
This addresses Issue B in #10530. The other template mismatches from that issue are intentionally left out of this PR.
To verify