Copilot commented on code in PR #13876:
URL: https://github.com/apache/apisix/pull/13876#discussion_r3860200955


##########
apisix/plugins/ai-aws-content-moderation.lua:
##########
@@ -446,7 +446,12 @@ local function annotate_stream(ctx, body)
         table.insert(raw_events, sse.encode(event))
     end
 
-    if not contains_done_event and proto.build_done_event and 
ctx.var.llm_request_done then
+    -- llm_request_done only means "no more content is coming", which is also
+    -- set when a stream is cut short (upstream read error, stream limit).
+    -- ctx.ai_stream_aborted marks those cases: synthesizing a terminator there
+    -- would tell the client a truncated response completed successfully.
+    if not contains_done_event and proto.build_done_event
+       and ctx.var.llm_request_done and not ctx.ai_stream_aborted then

Review Comment:
   The new truncation test configures only `ai-aliyun-content-moderation`, so 
this independently changed AWS final-packet path is untested. The existing AWS 
moderation suite covers terminator synthesis but not `ai_stream_aborted`; 
please add a case with `llm_request_done` set and `ai_stream_aborted` present 
that verifies no `[DONE]`/`message_stop` is appended.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to