feat(agent): 上下文压缩 - 超预算时生成检查点并安全续轮 (#598)
Co-authored-by: ddcat666 <26564566+ddcat666@users.noreply.github.com>
This commit is contained in:
1 parent
32a2e44040
commit
c4b9a426ab
13 files changed
+1505
-16
No files matched your search
@@ -20,6 +20,20 @@ func (s *Service) finishCloudAgentCleanup(ctx context.Context, run *model.CloudA
|
||||
if decodeErr == nil {
|
||||
activeID, mediaID, canvasID = state.ActiveTaskID, state.MediaTaskID, state.Request.CanvasID
|
||||
}
|
||||
// 本轮若正停在压缩上(被取消/失败收尾),要在取消子任务之前把保底检查点落盘并清掉压缩态:
|
||||
// 终态轮次不会再被调度器推进,否则 ContextCompaction 会永远挂在"正在压缩"、检查点永久丢失。
|
||||
// keepTerminal=true:收尾只落检查点与事件,绝不把 failed/cancelled 复活成 completed。
|
||||
if decodeErr == nil && state.ContextCompaction != nil {
|
||||
if err := s.finalizeCloudAgentInterruptedCompaction(run, &state, "本轮在压缩期间结束,已使用服务端保底检查点"); err != nil && !errors.Is(err, errCloudAgentCheckpoint) {
|
||||
return err
|
||||
}
|
||||
// 收尾那一步要再写一次控制面,必须先重新读:上面的检查点写入推进了 revision。
|
||||
refreshed, readErr := s.repo.CloudAgent(run.UserID, run.ID)
|
||||
if readErr != nil {
|
||||
return readErr
|
||||
}
|
||||
run = refreshed
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, id := range []string{run.ID, activeID, mediaID} {
|
||||
if id == "" || seen[id] {
|
||||
|
||||
Reference in new issue
Block a user