Refine OpenClaw artifact delivery detection
This commit is contained in:
parent
9cd1cab1e1
commit
901ad10b15
@ -450,6 +450,9 @@ func openClawArtifactDeliveryRequired(params map[string]any) bool {
|
||||
if strings.TrimSpace(text) == "" {
|
||||
return false
|
||||
}
|
||||
if openClawArtifactDeliverySuppressed(text) {
|
||||
return false
|
||||
}
|
||||
fileSignals := []string{
|
||||
"ppt", "pptx", "powerpoint", "slide", "slides",
|
||||
"pdf", "docx", "word", "xlsx", "excel",
|
||||
@ -482,6 +485,27 @@ func openClawArtifactDeliveryRequired(params map[string]any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func openClawArtifactDeliverySuppressed(text string) bool {
|
||||
suppressedSignals := []string{
|
||||
"do not create file", "do not create files",
|
||||
"don't create file", "don't create files",
|
||||
"do not generate file", "do not generate files",
|
||||
"don't generate file", "don't generate files",
|
||||
"do not write file", "do not write files",
|
||||
"don't write file", "don't write files",
|
||||
"no file", "no files", "no artifact", "no artifacts",
|
||||
"without file", "without files", "without artifact", "without artifacts",
|
||||
"不要创建文件", "不要生成文件", "不要写入文件", "不创建文件", "不生成文件",
|
||||
"无需创建文件", "无需生成文件", "不需要文件", "不要产物", "无需产物",
|
||||
}
|
||||
for _, signal := range suppressedSignals {
|
||||
if strings.Contains(text, signal) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func openClawArtifactDeliveryClaimedByOutput(output string) bool {
|
||||
if strings.TrimSpace(output) == openClawNoDisplayableText {
|
||||
return false
|
||||
|
||||
@ -1455,6 +1455,19 @@ func TestOpenClawNoDisplayableOutputDoesNotClaimArtifacts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenClawArtifactDeliverySuppressionKeepsTextOnlyPrompt(t *testing.T) {
|
||||
if openClawArtifactDeliveryRequired(map[string]any{
|
||||
"taskPrompt": "Reply exactly pong. Do not create files.",
|
||||
}) {
|
||||
t.Fatalf("negative file directive must not trigger artifact delivery")
|
||||
}
|
||||
if openClawArtifactDeliveryRequired(map[string]any{
|
||||
"taskPrompt": "只回答 pong,不要生成文件。",
|
||||
}) {
|
||||
t.Fatalf("Chinese negative file directive must not trigger artifact delivery")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteSessionTaskGatewayRejectsMissingOpenClawFilesForDeliveryRequest(t *testing.T) {
|
||||
gateway := newAcpFakeOpenClawGateway(t)
|
||||
defer gateway.Close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user