fix: omit inline openclaw artifact content
This commit is contained in:
parent
f0f7d99e21
commit
b9f4aa80fa
@ -175,6 +175,32 @@ func (s *Server) decorateOpenClawArtifactDownloadURLs(result map[string]any, ses
|
||||
}
|
||||
}
|
||||
|
||||
func stripOpenClawArtifactInlineContent(result map[string]any) {
|
||||
if result == nil {
|
||||
return
|
||||
}
|
||||
for _, key := range []string{"artifacts", "files", "attachments"} {
|
||||
switch items := result[key].(type) {
|
||||
case []any:
|
||||
for _, item := range items {
|
||||
stripOpenClawArtifactMapInlineContent(shared.AsMap(item))
|
||||
}
|
||||
case []map[string]any:
|
||||
for _, item := range items {
|
||||
stripOpenClawArtifactMapInlineContent(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stripOpenClawArtifactMapInlineContent(artifact map[string]any) {
|
||||
if artifact == nil {
|
||||
return
|
||||
}
|
||||
delete(artifact, "encoding")
|
||||
delete(artifact, "content")
|
||||
}
|
||||
|
||||
func (s *Server) decorateOpenClawArtifactDownloadURL(
|
||||
artifact map[string]any,
|
||||
sessionKey string,
|
||||
|
||||
@ -256,6 +256,7 @@ func (o *SessionOrchestrator) runOpenClawGatewayChat(
|
||||
notifyWithCollection,
|
||||
))
|
||||
o.server.decorateOpenClawArtifactDownloadURLs(result, shared.StringArg(chatParams, "sessionKey", ""), artifactRunID)
|
||||
stripOpenClawArtifactInlineContent(result)
|
||||
guardOpenClawArtifactResult(result, artifactDeliveryRequired)
|
||||
return result, nil
|
||||
}
|
||||
@ -432,7 +433,8 @@ func (o *SessionOrchestrator) openClawArtifactExport(
|
||||
"runId": strings.TrimSpace(runID),
|
||||
"sinceUnixMs": sinceUnixMs,
|
||||
"maxFiles": 64,
|
||||
"maxInlineBytes": 10 * 1024 * 1024,
|
||||
"maxInlineBytes": 0,
|
||||
"includeContent": false,
|
||||
}
|
||||
if preparedArtifact != nil && strings.TrimSpace(preparedArtifact.ArtifactScope) != "" {
|
||||
exportParams["artifactScope"] = strings.TrimSpace(preparedArtifact.ArtifactScope)
|
||||
|
||||
@ -677,8 +677,11 @@ func TestExecuteSessionTaskGatewayExportsOpenClawArtifacts(t *testing.T) {
|
||||
if got := artifacts[0]["relativePath"]; got != "reports/final.md" {
|
||||
t.Fatalf("expected manifest artifact relative path, got %#v", artifacts[0])
|
||||
}
|
||||
if got := artifacts[0]["encoding"]; got != "base64" {
|
||||
t.Fatalf("expected inline base64 artifact, got %#v", artifacts[0])
|
||||
if _, ok := artifacts[0]["encoding"]; ok {
|
||||
t.Fatalf("expected OpenClaw task response to omit inline artifact encoding, got %#v", artifacts[0])
|
||||
}
|
||||
if _, ok := artifacts[0]["content"]; ok {
|
||||
t.Fatalf("expected OpenClaw task response to omit inline artifact content, got %#v", artifacts[0])
|
||||
}
|
||||
downloadURL := strings.TrimSpace(shared.StringArg(artifacts[0], "downloadUrl", ""))
|
||||
if downloadURL == "" {
|
||||
@ -704,6 +707,13 @@ func TestExecuteSessionTaskGatewayExportsOpenClawArtifacts(t *testing.T) {
|
||||
if parsedDownloadURL.Query().Get("sig") == "" {
|
||||
t.Fatalf("expected signed downloadUrl, got %q", downloadURL)
|
||||
}
|
||||
exportParams := gateway.LastArtifactExportParams()
|
||||
if got := strings.TrimSpace(shared.StringArg(exportParams, "maxInlineBytes", "")); got != "0" {
|
||||
t.Fatalf("expected OpenClaw artifact export to disable inline content, got %#v", exportParams)
|
||||
}
|
||||
if got := shared.BoolArg(shared.StringArg(exportParams, "includeContent", ""), true); got {
|
||||
t.Fatalf("expected OpenClaw artifact export to omit content, got %#v", exportParams)
|
||||
}
|
||||
if got := gateway.Methods(); !sameMethods(got, []string{"connect", "xworkmate.artifacts.prepare", "chat.send", "agent.wait", "xworkmate.artifacts.export"}) {
|
||||
t.Fatalf("expected connect, artifact prepare, chat.send, agent.wait, then artifact export, got %#v", got)
|
||||
}
|
||||
@ -766,6 +776,12 @@ func TestExecuteSessionTaskGatewayExportsLatestWorkspaceArtifactsWhenScopedDirec
|
||||
if got := strings.TrimSpace(shared.StringArg(artifacts[0], "downloadUrl", "")); got == "" {
|
||||
t.Fatalf("expected bridge downloadUrl on latest workspace artifact, got %#v", artifacts[0])
|
||||
}
|
||||
if _, ok := artifacts[0]["encoding"]; ok {
|
||||
t.Fatalf("expected latest workspace artifact response to omit inline encoding, got %#v", artifacts[0])
|
||||
}
|
||||
if _, ok := artifacts[0]["content"]; ok {
|
||||
t.Fatalf("expected latest workspace artifact response to omit inline content, got %#v", artifacts[0])
|
||||
}
|
||||
exportParams := gateway.LastArtifactExportParams()
|
||||
if got := strings.TrimSpace(shared.StringArg(exportParams, "artifactScope", "")); !strings.HasPrefix(got, ".xworkmate/artifacts/tasks/thread-openclaw-latest-artifact/") {
|
||||
t.Fatalf("expected scoped artifact export params, got %#v", exportParams)
|
||||
@ -773,6 +789,12 @@ func TestExecuteSessionTaskGatewayExportsLatestWorkspaceArtifactsWhenScopedDirec
|
||||
if got := shared.BoolArg(shared.StringArg(exportParams, "latestIfEmpty", ""), false); !got {
|
||||
t.Fatalf("expected latestIfEmpty export param, got %#v", exportParams)
|
||||
}
|
||||
if got := strings.TrimSpace(shared.StringArg(exportParams, "maxInlineBytes", "")); got != "0" {
|
||||
t.Fatalf("expected latest workspace export to disable inline content, got %#v", exportParams)
|
||||
}
|
||||
if got := shared.BoolArg(shared.StringArg(exportParams, "includeContent", ""), true); got {
|
||||
t.Fatalf("expected latest workspace export to omit content, got %#v", exportParams)
|
||||
}
|
||||
if got := gateway.Methods(); !sameMethods(got, []string{"connect", "xworkmate.artifacts.prepare", "chat.send", "agent.wait", "xworkmate.artifacts.export"}) {
|
||||
t.Fatalf("expected connect, artifact prepare, chat.send, agent.wait, then artifact export, got %#v", got)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user