fix: detect nested openclaw artifact prompts
This commit is contained in:
parent
2fbd76239c
commit
2e8240a907
@ -347,7 +347,7 @@ func openClawChatSendParams(
|
||||
}
|
||||
|
||||
func openClawArtifactDeliveryRequired(params map[string]any) bool {
|
||||
text := strings.ToLower(firstNonEmptyString(params, "taskPrompt", "prompt", "message"))
|
||||
text := strings.ToLower(strings.Join(openClawArtifactDeliveryText(params), "\n"))
|
||||
if strings.TrimSpace(text) == "" {
|
||||
return false
|
||||
}
|
||||
@ -383,6 +383,38 @@ func openClawArtifactDeliveryRequired(params map[string]any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func openClawArtifactDeliveryText(raw any) []string {
|
||||
switch value := raw.(type) {
|
||||
case string:
|
||||
if text := strings.TrimSpace(value); text != "" {
|
||||
return []string{text}
|
||||
}
|
||||
case map[string]any:
|
||||
texts := make([]string, 0, len(value))
|
||||
for key, item := range value {
|
||||
switch strings.TrimSpace(key) {
|
||||
case "taskPrompt", "prompt", "message":
|
||||
texts = append(texts, openClawArtifactDeliveryText(item)...)
|
||||
default:
|
||||
if _, ok := item.(map[string]any); ok {
|
||||
texts = append(texts, openClawArtifactDeliveryText(item)...)
|
||||
}
|
||||
if _, ok := item.([]any); ok {
|
||||
texts = append(texts, openClawArtifactDeliveryText(item)...)
|
||||
}
|
||||
}
|
||||
}
|
||||
return texts
|
||||
case []any:
|
||||
texts := make([]string, 0, len(value))
|
||||
for _, item := range value {
|
||||
texts = append(texts, openClawArtifactDeliveryText(item)...)
|
||||
}
|
||||
return texts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withOpenClawArtifactDeliveryInstructions(
|
||||
message string,
|
||||
preparedArtifact *openClawPreparedArtifactScope,
|
||||
|
||||
@ -1079,6 +1079,19 @@ func TestOpenClawChatSendParamsAddsArtifactDeliveryInstructions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpenClawArtifactDeliveryRequiredScansNestedParams(t *testing.T) {
|
||||
params := map[string]any{
|
||||
"request": map[string]any{
|
||||
"params": map[string]any{
|
||||
"taskPrompt": "请在当前任务制品目录中真实生成一个文件",
|
||||
},
|
||||
},
|
||||
}
|
||||
if !openClawArtifactDeliveryRequired(params) {
|
||||
t.Fatal("expected nested artifact delivery prompt to be detected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteSessionTaskGatewayCollectsOpenClawEventArtifacts(t *testing.T) {
|
||||
gateway := newAcpFakeOpenClawGateway(t)
|
||||
gateway.artifactMode = "unknown"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user