Skip to content

DatabaseConversationStore rehydrates every stored message as plain text and drops attachments/tool context #380

@ruttydm

Description

@ruttydm

I hit this on laravel/ai v0.1.5 while testing remembered conversations.

DatabaseConversationStore::getLatestConversationMessages() currently maps every stored row back to a plain Laravel\Ai\Messages\Message:

->map(fn ($m) => new Message($m->role, $m->content));

But the store writes richer data than that:

  • user message attachments are stored in attachments
  • assistant tool calls are stored in tool_calls
  • tool results are stored in tool_results

Because that data is ignored on rehydration, continuing a remembered conversation loses non-text context.

Impact

This breaks continued conversations in at least these cases:

  • previous user messages had attachments
  • previous assistant turns included tool calls
  • previous tool results need to remain in context for later turns

In practice, the conversation history becomes behaviorally different after retrieval than it was when originally stored.

Expected

Rehydration should restore the original message types and associated structured data, for example:

  • UserMessage with attachments
  • AssistantMessage with tool calls
  • ToolResultMessage where applicable

Actual

Every row becomes a plain text Message, so structured context is discarded.

Relevant code

  • src/Storage/DatabaseConversationStore.php
  • storeUserMessage()
  • storeAssistantMessage()
  • getLatestConversationMessages()

If useful, I can open a PR with a proposed reconstruction path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions