Skip to content

fix: database-conversation-store-reasoning-rehydration#362

Open
nikitaa01 wants to merge 9 commits into
laravel:0.xfrom
nikitaa01:fix/361/database-conversation-store-reasoning-rehydration
Open

fix: database-conversation-store-reasoning-rehydration#362
nikitaa01 wants to merge 9 commits into
laravel:0.xfrom
nikitaa01:fix/361/database-conversation-store-reasoning-rehydration

Conversation

@nikitaa01
Copy link
Copy Markdown

Closes #361

@nikitaa01
Copy link
Copy Markdown
Author

This doesn't fixed the issue

@nikitaa01 nikitaa01 closed this Apr 9, 2026
- 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
@nikitaa01 nikitaa01 reopened this Apr 9, 2026
@pushpak1300
Copy link
Copy Markdown
Member

Duplicate of #301

@pushpak1300 pushpak1300 marked this as a duplicate of #301 Apr 28, 2026
@pushpak1300 pushpak1300 reopened this May 2, 2026
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.
@pushpak1300 pushpak1300 force-pushed the fix/361/database-conversation-store-reasoning-rehydration branch from 16d76e1 to c9c19c6 Compare May 2, 2026 17:12
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatabaseConversationStore loses reasoningId/reasoningSummary when rehydrating ToolCall from DB

2 participants