fix(agent): Agent 运行 - 重复读取改为软收敛并保留可纠正的媒体失败原因

重复只读和同版本识图不再把运行标成失败,下一步暂时收起只读工具。媒体能力错误改为可纠正,准入失败保留安全原因。
This commit is contained in:
ddcat666
2026-10-10 20:19:32 +08:00
parent 37b44444f0
commit 1bbc95b996
15 changed files with 394 additions and 52 deletions

View File

@@ -364,6 +364,7 @@ func (s *Service) advanceCloudAgent(run *model.CloudAgentExecution) (err error)
return s.failCloudAgent(run, &state, fmt.Sprintf("达到 %d 次模型调用上限,本轮已停止", stepLimit))
}
cloudAgentDrainInterjections(run.ID, &state)
softReadGuard := state.ReadLoopNudge
// 轮内唯一裁剪 = 图片:超出保留轮次的看图结果换成文字回执(正文一律保留)。
// 它必须在压缩判定之前跑:图片是最贵的一类内容,先移出再评估 token 压力才有意义。
if changed, pruned := cloudAgentPruneInspectedImages(&state.Canonical, nil); changed {
@@ -415,6 +416,13 @@ func (s *Service) advanceCloudAgent(run *model.CloudAgentExecution) (err error)
if tokens > contextBudget.InputBudgetTokens {
return s.failCloudAgent(run, &state, cloudAgentContextBudgetMessage(contextBudget))
}
if softReadGuard {
// 只对紧接着的一次模型请求暂时收起只读工具。运行仍保持 running,
// 下一步模型可以回复、提问或执行有实际变化的写操作。
state.ReadLoopNudge = false
state.ReadLoopToolName = ""
state.ReadLoopCount = 0
}
req := CreateTaskRequest{ProjectID: state.Request.CanvasID, Type: "canvas_text", Operation: "cloud_agent_step", Prompt: state.Request.Prompt, Model: state.Request.Model, LogicalModelID: state.Request.LogicalModelID, Input: input}
return s.enqueueCloudAgentTask(run, &state, req, nil)
}