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 {
|
if len(rawAttachments) == 0 {
|
||||||
return nil
|
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))
|
attachments := make([]any, 0, len(rawAttachments))
|
||||||
for _, raw := range rawAttachments {
|
for _, raw := range rawAttachments {
|
||||||
attachment := shared.AsMap(raw)
|
attachment := shared.AsMap(raw)
|
||||||
if len(attachment) == 0 {
|
if len(attachment) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
name := strings.TrimSpace(shared.StringArg(attachment, "name", "attachment"))
|
||||||
|
if inlineAttachmentNames[name] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if strings.TrimSpace(shared.StringArg(attachment, "path", "")) == "" {
|
if strings.TrimSpace(shared.StringArg(attachment, "path", "")) == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
attachments = append(attachments, map[string]any{
|
attachments = append(attachments, map[string]any{
|
||||||
"name": strings.TrimSpace(shared.StringArg(attachment, "name", "attachment")),
|
"name": name,
|
||||||
"description": strings.TrimSpace(shared.StringArg(attachment, "description", "")),
|
"description": strings.TrimSpace(shared.StringArg(attachment, "description", "")),
|
||||||
"path": strings.TrimSpace(shared.StringArg(attachment, "path", "")),
|
"path": strings.TrimSpace(shared.StringArg(attachment, "path", "")),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2549,6 +2549,13 @@ func TestOpenClawChatSendParamsVideoInlineImagesUsePromptPathsOnly(t *testing.T)
|
|||||||
"threadId": "thread-video-attachments",
|
"threadId": "thread-video-attachments",
|
||||||
"taskPrompt": "制作视频",
|
"taskPrompt": "制作视频",
|
||||||
"workingDirectory": workspace,
|
"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{
|
"inlineAttachments": []any{
|
||||||
map[string]any{
|
map[string]any{
|
||||||
"name": "01-single-machine.png",
|
"name": "01-single-machine.png",
|
||||||
@ -2599,6 +2606,9 @@ func TestOpenClawChatSendParamsVideoInlineImagesUsePromptPathsOnly(t *testing.T)
|
|||||||
if !strings.Contains(message, "制作视频") {
|
if !strings.Contains(message, "制作视频") {
|
||||||
t.Fatalf("expected message to preserve video prompt, got %q", 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) {
|
func TestOpenClawChatSendParamsMaterializesInlineAttachmentsInRemoteHint(t *testing.T) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user