-
Notifications
You must be signed in to change notification settings - Fork 34
Fix Ask AI conversation ID handling #2574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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
Mpdreamz
approved these changes
Jan 27, 2026
src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/StreamTransformerBase.cs
Fixed
Show fixed
Hide fixed
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Comment on lines
+85
to
+100
| catch (Exception ex) | ||
| { | ||
| Logger.LogError(ex, "Error transforming stream for transformer {TransformerType}. Stream processing will be terminated.", GetType().Name); | ||
| _ = parentActivity?.SetTag("error.type", ex.GetType().Name); | ||
| try | ||
| { | ||
| await ProcessStreamAsync(reader, writer, conversationId, parentActivity, cancellationToken); | ||
| // Complete writer first, then reader - but don't try to complete reader | ||
| // if the exception came from reading (would cause "read operation pending" error) | ||
| await writer.CompleteAsync(ex); | ||
| } | ||
| catch (OperationCanceledException ex) | ||
| catch (Exception completeEx) | ||
| { | ||
| Logger.LogDebug(ex, "Stream processing was cancelled for transformer {TransformerType}", GetType().Name); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Logger.LogError(ex, "Error transforming stream for transformer {TransformerType}. Stream processing will be terminated.", GetType().Name); | ||
| _ = parentActivity?.SetTag("error.type", ex.GetType().Name); | ||
| try | ||
| { | ||
| // Complete writer first, then reader - but don't try to complete reader | ||
| // if the exception came from reading (would cause "read operation pending" error) | ||
| await writer.CompleteAsync(ex); | ||
| } | ||
| catch (Exception completeEx) | ||
| { | ||
| Logger.LogError(completeEx, "Error completing pipe after transformation error for transformer {TransformerType}", GetType().Name); | ||
| } | ||
| return; | ||
| Logger.LogError(completeEx, "Error completing pipe after transformation error for transformer {TransformerType}", GetType().Name); | ||
| } | ||
| return; | ||
| } |
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 a bug where the Ask AI chatbot could not remember previous messages in a conversation.
Problem
When a user asked a follow-up question like "What did I ask before?", the AI responded that it had no conversation history. This happened only on the first follow-up message after starting a new conversation.
Root cause
The bug was a conversation ID mismatch between two parts of the system:
The LLM Gateway used one ID internally, but the Stream Transformer created a different ID for the frontend. When the user continued the conversation, the IDs did not match.
Solution
We now ensure one ID is used everywhere:
GeneratedConversationIdfieldNew API design
<new GUID>nullnull(it handles IDs in the stream)Test plan