fix(agent): 看图 - 独立运行时的模型步骤带上获准图片清单 (#671)
复现:Agent 调用 canvas_inspect_image 看图后,下一步模型调用报「模型协议引用了未获准的图片」,整轮失败;只要 Agent 看过一次图就必然复现。 原因:看图之后服务端规范历史里会多一条带 resource: 图片占位的 user 消息;旧的 Go 执行循环在发请求前把这些占位对应的资源写进 input.referenceImages,独立 Agent 运行时(Pi)的模型步骤漏了这一步,预检发现占位不在获准清单里就拒绝了请求。 修法:Pi 路径的模型步在组装任务输入前复用同一个 cloudAgentImageReferences 校验与装配(资源归属、大小、图片数量上限),把获准图片清单随请求发出。
This commit is contained in:
1 parent
1924729af8
commit
dd563d3373
3 files changed
+68
No files matched your search
@@ -229,6 +229,12 @@ func (s *Service) runCloudAgentModelStep(ctx context.Context, userID, runID stri
|
||||
// 纠偏上下文只用于这一次请求,不写回运行状态,避免下一步重复出现。
|
||||
canonical.Messages = append(append([]map[string]any(nil), canonical.Messages...), correction...)
|
||||
}
|
||||
// 看图后的历史里有 resource: 图片占位,必须随请求带上获准图片清单,
|
||||
// 否则预检以「模型协议引用了未获准的图片」拒绝(见 cloud_agent_pi_image_references.go)。
|
||||
references, refErr := s.cloudAgentPiStepImageReferences(userID, state.Request, &canonical)
|
||||
if refErr != nil {
|
||||
return nil, false, refErr
|
||||
}
|
||||
input := map[string]any{
|
||||
"mode": "text",
|
||||
"prompt": state.Request.Prompt,
|
||||
@@ -244,6 +250,9 @@ func (s *Service) runCloudAgentModelStep(ctx context.Context, userID, runID stri
|
||||
"maxOutputTokens": cloudAgentStepOutputBudget(state.StepLimits, state.BoostStepOutputBudget),
|
||||
},
|
||||
}
|
||||
if len(references) > 0 {
|
||||
input["referenceImages"] = references
|
||||
}
|
||||
req := CreateTaskRequest{
|
||||
ProjectID: state.Request.CanvasID,
|
||||
Type: "canvas_text",
|
||||
|
||||
Reference in new issue
Block a user