fix: database-conversation-store-reasoning-rehydration#362
Open
nikitaa01 wants to merge 9 commits into
Open
Conversation
Author
|
This doesn't fixed the issue |
- Split stored assistant content into a separate final AssistantMessage after tool results so the sequence is always: function_calls → tool_results → output_text (required by all providers, critical for OpenAI Responses API ordering) - Fall back to latest reasoning item on function_call_arguments.done in case response.output_item.done for reasoning fires after the function call in the stream - Use empty array fallback for null reasoningSummary in reasoning blocks to satisfy OpenAI schema validation Fixes laravel#361
Member
|
Duplicate of #301 |
pushpak1300
added a commit
to nikitaa01/laravel-ai
that referenced
this pull request
May 2, 2026
…-rehydration Resolved conflicts in MapsMessages.php (drop duplicated tool-call emission block — 0.x already groups reasoning/function_calls correctly via PR laravel#461) and DatabaseConversationStore.php (keep PR laravel#362's per- reasoning-group message split, drop 0.x's single-AssistantMessage path). Updated DatabaseConversationStoreTest to expect the corrected three- message structure (AssistantMessage with tool calls, ToolResultMessage, trailing AssistantMessage with content), and made the legacy-data result lookup fall back to ToolCall::id when resultId is missing so sparse historical records still pair correctly.
16d76e1 to
c9c19c6
Compare
…rsation-store-reasoning-rehydration # Conflicts: # src/Gateway/OpenAi/Concerns/MapsMessages.php # src/Storage/DatabaseConversationStore.php
Issue laravel#361 (rehydrating reasoningId/reasoningSummary on ToolCall) is already resolved on 0.x via laravel#301. The remaining real bug this branch addresses is multi-turn message ordering loss in DatabaseConversationStore. Drop the unrelated OpenAI/xAI streaming changes so this PR stays focused.
Drop the 'source' => 'record' content dedupe trick — store assistant content inline always. Removes hydrateAssistantContent and the $responseText param threaded into serializeMessage. Use MessageRole enum constants instead of raw 'assistant' / 'tool_result' strings. Collapse toolCallKey + toolResultKey into a single itemKey helper that accepts ToolCall|ToolResult.
The reasoningId>1 branch and the else branch were doing the same thing — emit one assistant + one tool_result per reasoning bucket. Group on reasoningId ?? '' and flatMap; the single-bucket case naturally produces one pair, identical to the old else branch.
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.
Closes #361