fix(agent): 插话 - 独立运行时路径的送达与退回 (#673)

复现:Agent 运行中发送插话,独立 Agent 运行时(Pi)下既不送达模型也不退回用户,插话一直停在待送队列里。

原因与修法:插话送达点原本只有旧 Go 执行循环(advanceCloudAgent 开步前出队);Pi 运行时接手执行后调度循环不再推进。现把 Pi 路径的送达搬到 /model 模型步:出队、规范历史追加与 delivered 事件同在入队的一次 CAS 写入里,响应携带 steeringMessages 交给运行时 session.steer。完成、失败、取消、审批拒绝与步数耗尽统一退回;最终回答之后的插话在预算富余时续跑一步。完成闸一次带走多条插话时,合并后的续跑提示词也记入指纹,避免被恢复闸当成遗留提示词清空。
This commit is contained in:
jiabx
2026-10-05 13:39:57 +08:00
committed by GitHub
parent dd563d3373
commit 5bf838ebbe
6 changed files with 730 additions and 6 deletions

View File

@@ -462,6 +462,7 @@ func (s *Service) DecideCloudAgentApproval(userID, id, approvalID, decision, rea
current.Status = "rejected"
current.FailureMessage = ""
state.Approval = nil
cloudAgentDropInterjections(id, "本轮已结束:已拒绝本次生成", &state)
state.event(id, "approval_decided", map[string]any{
"approvalId": approvalID,
"decision": decision,
@@ -641,6 +642,7 @@ func (s *Service) CancelCloudAgent(ctx context.Context, userID, id string) error
current.CanvasID, current.ActiveTaskID, current.MediaTaskID = state.Request.CanvasID, state.ActiveTaskID, state.MediaTaskID
if firstCancellation {
state.event(id, "run_cancelled", map[string]any{"source": "user_request", "activeTaskId": state.ActiveTaskID, "mediaTaskId": state.MediaTaskID, "text": "用户取消接口已接收请求,正在取消关联任务"})
cloudAgentDropInterjections(id, "本轮已结束:用户已取消本轮", &state)
if saveErr := cloudAgentSave(current, &state); saveErr != nil {
// Cancellation must still work if the transcript is oversized.
log.Printf("[cloud-agent] cancellation event unavailable for run %s: checkpoint rejected", id)