diff --git a/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/LlmGatewayStreamTransformer.cs b/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/LlmGatewayStreamTransformer.cs index d12ae3541..4f47ee656 100644 --- a/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/LlmGatewayStreamTransformer.cs +++ b/src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/LlmGatewayStreamTransformer.cs @@ -74,9 +74,10 @@ protected override async Task ProcessStreamAsync(PipeReader reader, PipeWriter w "tool_call" when messageData.TryGetProperty("toolCalls", out var toolCalls) => TransformToolCall(id, timestamp, toolCalls), - "tool_message" when messageData.TryGetProperty("toolCallId", out var toolCallId) - && messageData.TryGetProperty("result", out var result) => - new AskAiEvent.ToolResult(id, timestamp, toolCallId.GetString()!, result.GetString()!), + // Frontend only uses tool_result to show "Analyzing..." status - result content not displayed + // Skip sending the large payload (~30KB) to prevent CloudFront OAC buffering issues + "tool_message" when messageData.TryGetProperty("toolCallId", out var toolCallId) => + new AskAiEvent.ToolResult(id, timestamp, toolCallId.GetString()!, ""), "agent_end" => new AskAiEvent.ConversationEnd(id, timestamp), diff --git a/tests/Elastic.Documentation.Api.Infrastructure.Tests/Adapters/AskAi/StreamTransformerTests.cs b/tests/Elastic.Documentation.Api.Infrastructure.Tests/Adapters/AskAi/StreamTransformerTests.cs index 384ffaaa2..9eeadeeae 100644 --- a/tests/Elastic.Documentation.Api.Infrastructure.Tests/Adapters/AskAi/StreamTransformerTests.cs +++ b/tests/Elastic.Documentation.Api.Infrastructure.Tests/Adapters/AskAi/StreamTransformerTests.cs @@ -247,7 +247,8 @@ public async Task TransformAsyncWithRealLlmGatewayPayloadParsesAllEventTypes() events[4].Should().BeOfType(); var toolResult = events[4] as AskAiEvent.ToolResult; toolResult!.ToolCallId.Should().Be("tool1"); - toolResult.Result.Should().Contain("Found 10 docs"); + // Result is intentionally empty - payload stripped to prevent CloudFront OAC buffering issues + toolResult.Result.Should().BeEmpty(); // Event 6: ai_message events[5].Should().BeOfType();