fix(acp): prefer materialized inline attachment paths
This commit is contained in:
parent
e4966473c4
commit
01c2c2ed31
@ -1025,17 +1025,28 @@ func openClawNonEmptyPathAttachments(params map[string]any) []any {
|
||||
if len(rawAttachments) == 0 {
|
||||
return nil
|
||||
}
|
||||
inlineAttachmentNames := map[string]bool{}
|
||||
for _, raw := range shared.ListArg(params, "inlineAttachments") {
|
||||
name := strings.TrimSpace(shared.StringArg(shared.AsMap(raw), "name", ""))
|
||||
if name != "" {
|
||||
inlineAttachmentNames[name] = true
|
||||
}
|
||||
}
|
||||
attachments := make([]any, 0, len(rawAttachments))
|
||||
for _, raw := range rawAttachments {
|
||||
attachment := shared.AsMap(raw)
|
||||
if len(attachment) == 0 {
|
||||
continue
|
||||
}
|
||||
name := strings.TrimSpace(shared.StringArg(attachment, "name", "attachment"))
|
||||
if inlineAttachmentNames[name] {
|
||||
continue
|
||||
}
|
||||
if strings.TrimSpace(shared.StringArg(attachment, "path", "")) == "" {
|
||||
continue
|
||||
}
|
||||
attachments = append(attachments, map[string]any{
|
||||
"name": strings.TrimSpace(shared.StringArg(attachment, "name", "attachment")),
|
||||
"name": name,
|
||||
"description": strings.TrimSpace(shared.StringArg(attachment, "description", "")),
|
||||
"path": strings.TrimSpace(shared.StringArg(attachment, "path", "")),
|
||||
})
|
||||
|
||||
@ -2549,6 +2549,13 @@ func TestOpenClawChatSendParamsVideoInlineImagesUsePromptPathsOnly(t *testing.T)
|
||||
"threadId": "thread-video-attachments",
|
||||
"taskPrompt": "制作视频",
|
||||
"workingDirectory": workspace,
|
||||
"attachments": []any{
|
||||
map[string]any{
|
||||
"name": "01-single-machine.png",
|
||||
"description": "image/png",
|
||||
"path": "/Users/shenlan/Pictures/01-single-machine.png",
|
||||
},
|
||||
},
|
||||
"inlineAttachments": []any{
|
||||
map[string]any{
|
||||
"name": "01-single-machine.png",
|
||||
@ -2599,6 +2606,9 @@ func TestOpenClawChatSendParamsVideoInlineImagesUsePromptPathsOnly(t *testing.T)
|
||||
if !strings.Contains(message, "制作视频") {
|
||||
t.Fatalf("expected message to preserve video prompt, got %q", message)
|
||||
}
|
||||
if strings.Contains(message, "/Users/shenlan/Pictures/01-single-machine.png") {
|
||||
t.Fatalf("OpenClaw message must use materialized remote paths, got %q", message)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenClawChatSendParamsMaterializesInlineAttachmentsInRemoteHint(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user