Repository navigation
[v2] 交互 Agent 节点:跟进消息未送达时提示并可重发,首轮在发给 Node 前失败可续跑 - #391
Conversation
A session counted as started as soon as its first turn was claimed, before the Agent configuration was built and the model permit taken. When either of them failed, nothing had been sent to Node, yet the turn was reported as a lost Agent rather than one that never started. An interactive workflow node then parked with no answer and no conversation, and its run could only be cancelled. The session is now marked started just before the start command is sent. A turn refused before that is NotStarted, so the interactive node fails as interactive_session and the run can be resumed, and ending the session asks nothing of Node. An End that arrives while the first turn is being permitted finds no Agent to stop, so the turn does not start one afterwards; a Node whose transport fails in that window is not sent the start either.
A follow-up message is accepted before the execution service sees it. When the service then refused it (unavailable, a conflict, shutting down, or a session that ended elsewhere), the message never ran, the request had already returned 200, and only the server log knew. The node's summary now carries last_turn_error = not_delivered when it parks after such a refusal, so the run page can tell the starter. The notice is cleared in the same row update that claims the starter's next message, and a completion writes the summary without it. The summary also counts the starter's messages (sent). The notice is about the latest of them, which lets a page tell whether it concerns a message that page sent.
The run page reads last_turn_error from the node's session summary. While the node waits for input, the starter sees above the composer that the last message was not delivered and should be sent again. Once the session has ended there is nowhere to send it, so the notice says that instead. The view that sent the message offers to put its text back. It keeps the message's number, the summary's sent count plus one at the time of the send, and offers the text only when the notice is about that number, so a message sent from another tab or an earlier one is never restored in its place. A summary older than the view's last send is about an earlier message and its notice is not shown, however long the next read of the run takes.
zhangxinhao
left a comment
There was a problem hiding this comment.
LGTM(36c9d68)
@ObsisMc 我看了这个 PR,理解它是要让交互节点明确提示跟进消息未送达并支持重新填入,同时让首轮发给 Node 前的失败可以续跑。可以合并。发现一处跨标签页且摘要滞后时的消息关联问题,建议后续修正;工作流数据库测试本次未能执行。
- 📌 建议另开 PR 处理:P2-1 跨标签页时推算序号仍会关联错消息(不影响这次合并)
- 测试:
cd frontend-v2 && npm test -- src/features/chat/workflow-run/run-node-session-actions.test.tsx src/features/chat/workflow-run/run-node-session-chat.test.tsx src/features/chat/workflow-run/server-run-adapter.test.ts通过;cd v2-server && go test -race ./internal/agentruntime -run 'TestDriverIPCFirstTurn' -count=1通过;cd v2-server && go test -race ./internal/agentruntime -count=1通过;cd v2-server && go test -race ./internal/workflowhost -run 'Test(RefusedClaim|RefusedFollowUp|UndeliveredNotice|AcceptedFollowUpDoesNotRun|FirstTurnWithoutASession|AppendToAnEnded)' -v -count=1没跑(命令执行完成,但所选测试因未设置 TEST_DATABASE_URL 全部跳过。);没跑全量和 e2e。
涉及对外 API/协议、并发核心,建议 owner 再看一眼。
以上都是建议,怎么处理由你决定。
自动检视 · 基于 36c9d68 · 第 1 轮(全量)
| if (await act(() => sendNodeTurn(tenantId, runId, nodeId, draft))) setDraft('') | ||
| // v2 numbers the starter's messages as it accepts them. This one follows those on screen, | ||
| // and this view's previous one when the screen has not caught up with it yet. | ||
| const sent = { text: draft, number: Math.max(session?.sent ?? 0, lastSent?.number ?? 0) + 1 } |
There was a problem hiding this comment.
P2-1(建议) 这里推算的序号不一定是服务端实际认领的序号。例如当前页仍显示 sent: 0,另一标签页已发送第 1 条且未送达,当前页再发送的实际是第 2 条,这里却记成第 1 条。若随后读到第 1 条的旧摘要,就会错误提供当前页消息的「重新填入」,即使它已经送达;而第 2 条真的未送达时又无法恢复正文。临时用例已复现错误按钮。建议由服务端在认领响应中返回本次实际序号,或回显消息 ID,再绑定本地正文,并补充这个交错场景的测试。
改动较大,建议另开 PR 处理,不影响这次合并。
main gained the session-slot wait marker (cloud#389). The only conflict is in v2-server/README.md, where both sides edit the same long paragraph lines: main's text is kept and this branch's six sentence edits are applied to it again unchanged.
zhangxinhao
left a comment
There was a problem hiding this comment.
LGTM(e3f01e1)
@ObsisMc 我看了这个 PR,理解它是要让交互节点提示跟进消息未送达并支持重新填入,同时让首轮发给 Node 前的失败可以续跑。这是第 2 轮,我看了 36c9d68 之后的改动。本轮合并 main 后,等待会话名额与未送达提示的逻辑均保留,未发现新增问题,可以合并。上轮 P2-1 尚未处理,仍建议后续另开 PR 修正。
- ⏳ 上轮还没处理的:P2-1(仍是建议,不影响合并)。
- 测试:
cd frontend-v2 && npm test -- src/features/chat/workflow-run/run-node-session-actions.test.tsx src/features/chat/workflow-run/run-node-session-chat.test.tsx src/features/chat/workflow-run/server-run-adapter.test.ts通过;cd frontend-v2 && npm run typecheck通过;cd v2-server && go test -race ./internal/agentruntime -run 'TestDriverIPCFirstTurn' -count=1通过;没跑全量和 e2e。
涉及对外 API/协议、并发核心,建议 owner 再看一眼。
以上都是建议,怎么处理由你决定。
自动检视 · 基于 e3f01e1 · 第 2 轮(增量)
EricWvi
left a comment
There was a problem hiding this comment.
owner 验收第 1 轮(36c9d687):0H/0M/3L。请修 L1(「重新填入」用服务端返回的序号)、补 L2 的测试、README 写明 L3,并解决和 main(cloud#389)的冲突。详情见 ora-space/circus#1225。
The run page had to guess which of the starter's messages it had just sent: the summary's sent count on screen plus one. A second tab of the starter's sending at the same moment made that guess wrong, and the page could then take the other tab's undelivered message for its own. Sending a message now answers with the number the bridge claimed it under, the value payload.interactive.sent has from then on. The turns route returns it as sent, in its own response schema.
The view that sent a message keeps the number the send answered with instead of counting from the summary on screen, and offers to put the text back only when the notice is about that number. A message another tab sent meanwhile can no longer be mistaken for it. A send the server refused is not remembered, which a test now pins. The README says that only the starter sees the undelivered notice.
zhangxinhao
left a comment
There was a problem hiding this comment.
LGTM(8a60e9a)
@ObsisMc 我看了这个 PR,理解它是要让交互节点提示跟进消息未送达并支持重新填入,同时让首轮发给 Node 前的失败可以续跑;本轮改用服务端返回的消息序号,避免跨标签页关联错消息。这是第 3 轮,我看了 e3f01e1 之后的改动。整体没问题,可以合并。本轮增量已解决上轮 P2-1,未发现新增问题;相关前端测试通过,后端数据库测试因缺少配置未能执行。
- ✅ 上轮的 P2-1 已处理,谢谢。
- 测试:
cd frontend-v2 && npm test -- src/features/chat/workflow-run/run-node-session-actions.test.tsx src/features/chat/workflow-run/run-node-session-chat.test.tsx src/features/chat/workflow-run/server-run-adapter.test.ts通过;cd frontend-v2 && npm run typecheck通过;cd frontend-v2 && npm run api:check:workflows通过;cd v2-server && go test -race ./internal/workflowhost ./internal/server -run 'Test(RefusedFollowUpIsReportedAsNotDelivered|RefusedClaimKeepsTheUndeliveredNotice|UndeliveredNoticeFollowsTheLatestMessage|WorkflowNodeTurn)' -count=1 -v没跑(编译通过,但未设置 TEST_DATABASE_URL,选中的数据库测试全部跳过。);没跑全量和 e2e。
涉及对外 API/协议、并发核心,建议 owner 再看一眼。
以上都是建议,怎么处理由你决定。
自动检视 · 基于 8a60e9a · 第 3 轮(增量)
EricWvi
left a comment
There was a problem hiding this comment.
第 2 轮:L1(服务端返回序号)、L2(测试)、L3(README)已满足,冲突处理正确。
Refs ora-space/circus#1225
v2,不涉及 specs。只改
v2-server/和frontend-v2/,接口路径和数据库结构不变。两处都是 #380 owner 验收时提出的 Low。
1. 跟进消息没送达时,页面要说出来
问题:发起人给等待输入的交互节点发消息,接口在认领节点后就返回 200,消息之后才交给会话。执行服务这时拒绝(服务不可用、冲突、正在关闭,或会话已在别处结束),消息就没有执行,只留一条服务端日志,节点照原样回到等待输入。
改动
payload.interactive里写last_turn_error: "not_delivered"。发起人的下一条消息被认领时,在同一次行更新里清掉;完成节点时写入的摘要不带它。sent:发起人已发的消息数。last_turn_error说的是第sent条。认领被拒(行没能改成运行中)的那一次不计数。sent,workflows.openapi.json里的WorkflowNodeTurnResponse),页面拿它和摘要的sent比对。2. 首轮在发给 Node 之前就失败时,节点要能续跑
问题:会话在首轮被认领时就记为「已启动」,之后才构建 Agent 配置、取模型授权。这两步失败时什么都没发给 Node,但这一轮被当成「启动后丢失」。交互节点于是以
no_completed_turn停住,运行只能取消。改动:改为在发出
start_agent_session之前才记为已启动。NotStarted,交互节点按interactive_session失败,可以续跑;结束这个会话不需要 Node 配合。End到达,它找不到要停的 Agent,所以这一轮之后不再启动 Agent。end_session,结束得不到确认;现在不发了。commit
fix(v2): report a first turn refused before Node as not startedfeat(v2): record that an interactive node's message was not deliveredfeat(v2): show an undelivered message on the interactive node6b07eca9,含 cloud#389),只有v2-server/README.md有冲突fix(v2): answer an interactive message with its numberfix(v2): take the undelivered message's number from the server验证
本机 4 核,后端用
GOMAXPROCS=2 go test -p 1 -race,TEST_DATABASE_URL指向本地 PostgreSQL。都在 head36c9d687上,base 是 main5416335a(cloud#383、cloud#388 之后):gofmt、go vet ./...通过。只跑了相关的四个包:internal/workflowhost、internal/agentruntime、internal/executionruntime、internal/server。workflowhost整包跑了 6 遍:第 1 遍失败,没留住是哪个用例;之后 5 遍全过,没能复现。tsc -b、oxlint --deny-warnings、npm run build通过。vitest945 个里 944 个通过,包括本 PR 的全部用例。run-flow.test.tsx的 "analyzes a finished run once and explains each Agent from that analysis with its own list",和本 PR 无关:在未改动的 main(rebase 前的5058c817)上跑整套测试,同一个用例同样失败;单独跑这个文件 26 个全过。以 CI 为准。started改回在begin里设置,或去掉记为已启动前对「已结束」「Node 已断开」的检查(3 种):对应的TestDriverIPCFirstTurn…用例失败。last_turn_error、摘要里不带sent、认领被拒时不还原标记、认领被拒时不退回计数、运行已停止的分支不标记。对应用例都失败。sent、操作后不重新读取运行、消息序号不加一、会话结束仍可重新填入、消息序号只按屏幕上的数算、换了尝试不清空输入框。对应用例都失败。sent)。sent: 1、last_turn_error: "not_delivered")→「重新填入」→ 改发一条正常消息 → 送达、Agent 回答、提示消失(sent: 2)。截图在运行 issue 里。frontend-v2/e2e/workflow-interactive.spec.ts(真实 Node,3 个用例),都通过。这几个用例在 CI 上没有真实 Node,会跳过。interactive_session失败」由三段各自的测试覆盖:驱动报告NotStarted(本 PR 新增)、执行服务把驱动的错误记为AgentLost并保留NotStarted(已有)、工作流据此按interactive_session失败且可续跑(已有,本 PR 加了一个用例)。owner 验收第 1 轮之后(
e3f01e1d..8a60e9ad)sent、服务端返回的序号少一,对应用例都失败。go vet ./...通过;workflowhost和server两个包带-race通过;前端api:check:workflows无漂移,类型检查、lint、构建通过,单测 954 个全过。workflow-interactive.spec.ts3 个用例通过;截图流程在8a60e9ad上重走了一遍,接口对两条消息分别返回sent: 1和sent: 2。界面没有变化。已知没处理的