Skip to content

[0.x] Sync conversation state to StreamableAgentResponse after streaming#337

Open
svidskiy wants to merge 1 commit intolaravel:0.xfrom
svidskiy:fix/streamable-conversation-id
Open

[0.x] Sync conversation state to StreamableAgentResponse after streaming#337
svidskiy wants to merge 1 commit intolaravel:0.xfrom
svidskiy:fix/streamable-conversation-id

Conversation

@svidskiy
Copy link
Copy Markdown

@svidskiy svidskiy commented Mar 31, 2026

Fixes #336

StreamableAgentResponse::conversationId is always null after iterating a streaming conversational agent.

The RememberConversation middleware sets conversation state on the inner StreamedAgentResponse via thenCallbacks, but the outer StreamableAgentResponse that the caller holds is never updated.

This adds two lines after thenCallbacks complete in getIterator() to sync the state back:

$this->conversationId ??= $this->streamedResponse->conversationId;
$this->conversationUser ??= $this->streamedResponse->conversationUser;

Before: $stream->conversationId returns null after streaming.
After: $stream->conversationId returns the conversation UUID, matching prompt() behavior.

…AgentResponse

When using streaming with conversational agents, the RememberConversation
middleware sets conversationId on the StreamedAgentResponse via thenCallbacks,
but the caller holds a StreamableAgentResponse where conversationId remains null.

This syncs conversationId and conversationUser back to the StreamableAgentResponse
after thenCallbacks complete, so callers can access $stream->conversationId.

Fixes laravel#336
@svidskiy svidskiy changed the title fix: sync conversation state from StreamedAgentResponse to StreamableAgentResponse [0.x] Sync conversation state to StreamableAgentResponse after streaming Mar 31, 2026
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.

StreamableAgentResponse::conversationId is always null after streaming

1 participant