Skip to content

fix: agent studio repeated output and disorder#4446

Open
SecureDong wants to merge 1 commit intoalibaba:mainfrom
SecureDong:main
Open

fix: agent studio repeated output and disorder#4446
SecureDong wants to merge 1 commit intoalibaba:mainfrom
SecureDong:main

Conversation

@SecureDong
Copy link
Copy Markdown

Describe what this PR does / why we need it

修复:spring-ai-alibaba-studio界面, 响应内容为「逐片文本 + 完整拼接文本」的重复内容且是乱序的问题
核心原因:transformFluxToGraphResponse 方法末尾的 concatWith 逻辑会在流式结束后,额外返回聚合后的完整 ChatResponse,与分片文本重复
image

Does this pull request fix one issue?

Fixes #3993

Describe how you did it

修改com.alibaba.cloud.ai.agent.studio.controller.ExecutionController类

  1. 解决内容重复问题: 在 executeAgent 方法中,识别并过滤流式结束的完整拼接文本响应,仅保留逐片分片输出
  2. 解决乱序问题: 对 executeAgent 方法的返回结果Flux<ServerSentEvent>调用.cache()方法

Describe how to verify it

  1. 启动 spring-ai-alibaba-studio 服务,打开 Agent Chat 界面;
  2. 输入任意流式对话指令(如“介绍家附近的超市”),观察响应输出:
    • 预期结果1(无重复):仅展示逐片流式文本,无最后一条完整拼接文本;
    • 预期结果2(无乱序):分片文本按自然语言顺序输出(如“你好”→“!”→“推荐以下超市”,无交叉/颠倒);

Special notes for reviews

@github-actions github-actions bot added the area/studio SAA Studio module label Mar 20, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/studio SAA Studio module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] agent studio 里面实现executeAgent函数会导致乱序返回LLM流结果

2 participants