Preserve sibling tool calls in assistant imports#336
Draft
colinbennettbrain wants to merge 3 commits into
Draft
Conversation
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.
Summary
Fixes Lingua import handling for assistant role messages that contain Anthropic-style
content[].type = "thinking"blocks alongside sibling OpenAI-styletool_calls.The importer now parses this mixed assistant shape at a typed compatibility boundary and preserves both the reasoning content and sibling tool calls in the resulting universal assistant message.
It also avoids preempting OpenAI/OpenRouter/vLLM-style messages with top-level
reasoningorreasoning_signature, allowing the existing OpenAI provider parser to preserve those fields.Root cause
try_parse_mixed_role_messages_for_importoffered role-message items to provider parsers before the lenient fallback. A provider parser could preservecontent[].thinkingwhile ignoring siblingtool_calls. The lenient assistant fallback only parsedcontent, so sibling tool calls were invisible there too.Tests
CASE_FILTER=role-message-thinking-with-sibling-tool-calls cargo +1.95.0 test -p lingua --test import_fixtures -- --nocaptureCASE_FILTER=role-message-openai-reasoning-with-sibling-tool-calls cargo +1.95.0 test -p lingua --test import_fixtures -- --nocapturecargo +1.95.0 test -p lingua --test import_fixtures -- --nocaptureRUSTUP_TOOLCHAIN=1.95.0 make typed-boundary-check