fix(chat): 阻止同会话并发 Agent Run 导致消息错乱

前端 submit 改用 chatStateRef 同步拦截连发;后端 createRun 检测同 session 活跃任务并返回 409,避免多条回复交错落库。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-07 11:48:59 +08:00
parent ac520d8ae5
commit 1e4f432754
5 changed files with 162 additions and 5 deletions
+7
View File
@@ -127,6 +127,13 @@ export function createPostAgentRunsHandler({
});
response.status(202).json({ run });
} catch (err) {
if (err?.code === 'SESSION_RUN_CONFLICT') {
response.status(409).json({
message: err.message,
code: 'SESSION_RUN_CONFLICT',
});
return;
}
response.status(500).json({
message: err instanceof Error ? err.message : '创建任务失败',
});