Merge: S1 default expectedArtifactDirs (stability — artifact delivery)
This commit is contained in:
commit
02808934c8
@ -850,6 +850,12 @@ type openClawArtifactContract struct {
|
||||
SourceMessage string
|
||||
}
|
||||
|
||||
// defaultOpenClawExpectedArtifactDirs 是 agent 最常用的产物落盘目录。当任务期望产物却没有
|
||||
// 显式声明目录时,用作 openclaw-multi-session-plugins 的 workspace 根兜底扫描范围(S1)。
|
||||
func defaultOpenClawExpectedArtifactDirs() []string {
|
||||
return []string{"reports/", "artifacts/", "exports/"}
|
||||
}
|
||||
|
||||
func openClawArtifactContractForParams(params map[string]any, chatParams map[string]any) openClawArtifactContract {
|
||||
metadata := shared.AsMap(params["metadata"])
|
||||
taskLoadClass := strings.TrimSpace(shared.StringArg(metadata, "taskLoadClass", ""))
|
||||
@ -869,6 +875,14 @@ func openClawArtifactContractForParams(params map[string]any, chatParams map[str
|
||||
if len(requiredExts) == 0 {
|
||||
requiredExts = inferOpenClawRequiredArtifactExts(lowerMessage)
|
||||
}
|
||||
// S1(docs/cases/06 §7):任务期望产物(需导出 或 已推断出 requiredExts)却没有显式声明
|
||||
// expectedArtifactDirs 时,补一组缺省目录。openclaw-multi-session-plugins 在 task scope
|
||||
// 目录为空时会回扫 workspace 根的 expectedArtifactDirs;该列表为空则兜底形同虚设,
|
||||
// agent 写到 workspace 根(reports//artifacts//exports/)的产物就再也收不回(表现「暂无文件」)。
|
||||
if len(expectedDirs) == 0 && (requiresExport || len(requiredExts) > 0) {
|
||||
expectedDirs = defaultOpenClawExpectedArtifactDirs()
|
||||
requiresExport = true
|
||||
}
|
||||
expectedFileCounts := normalizeOpenClawArtifactExtCountMap(shared.AsMap(contract["expectedFileCountByExtension"]))
|
||||
if len(expectedFileCounts) == 0 {
|
||||
expectedFileCounts = normalizeOpenClawArtifactExtCountMap(shared.AsMap(metadata["expectedFileCountByExtension"]))
|
||||
|
||||
19
internal/acp/orchestrator_s1_artifact_dirs_test.go
Normal file
19
internal/acp/orchestrator_s1_artifact_dirs_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package acp
|
||||
import "testing"
|
||||
func TestS1DefaultExpectedArtifactDirs(t *testing.T) {
|
||||
// 任务消息要求产出 md → 推断 requiredExts,但未声明 expectedArtifactDirs → 应补缺省目录
|
||||
c := openClawArtifactContractForParams(
|
||||
map[string]any{}, map[string]any{"message": "采集最新AI资讯,保存在md文件"})
|
||||
if len(c.ExpectedArtifactDirs) == 0 {
|
||||
t.Fatalf("expected default artifact dirs for an md-producing task, got none")
|
||||
}
|
||||
if !c.RequiresArtifactExport {
|
||||
t.Fatalf("expected RequiresArtifactExport=true when default dirs applied")
|
||||
}
|
||||
// 纯聊天(无产物意图)→ 不应补目录、不应强制导出
|
||||
c2 := openClawArtifactContractForParams(
|
||||
map[string]any{}, map[string]any{"message": "你好,介绍一下你自己"})
|
||||
if len(c2.ExpectedArtifactDirs) != 0 || c2.RequiresArtifactExport {
|
||||
t.Fatalf("pure chat should not get default dirs / forced export, got dirs=%v export=%v", c2.ExpectedArtifactDirs, c2.RequiresArtifactExport)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user