From 6c45cc41beb3587ac3ada8e243ab3efe93e8e412 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 18 Jan 2026 17:21:21 +0800 Subject: [PATCH] Enhance Delivery Result Structure and Update Test Cases - Modified the DeliveryResult structure across multiple executors to include RequestID and Content fields, providing detailed summaries and bodies for dry-run, sandbox, and standard deliveries. - Updated related test cases to reflect changes in the DeliveryResult structure, ensuring accurate validation of delivery types and content handling. - Revised input formatting to display delivery summaries instead of types, improving clarity in execution summaries. --- agent/robot/executor/dryrun/executor.go | 6 +++++- agent/robot/executor/sandbox/executor.go | 6 +++++- agent/robot/executor/standard/delivery.go | 6 +++++- agent/robot/executor/standard/goals.go | 2 +- agent/robot/executor/standard/goals_test.go | 6 +++--- agent/robot/executor/standard/input.go | 7 ++++++- agent/robot/executor/standard/input_test.go | 8 ++++++-- agent/robot/job/execution_test.go | 6 +++++- 8 files changed, 36 insertions(+), 11 deletions(-) diff --git a/agent/robot/executor/dryrun/executor.go b/agent/robot/executor/dryrun/executor.go index 0aecf4d9..5aff1390 100644 --- a/agent/robot/executor/dryrun/executor.go +++ b/agent/robot/executor/dryrun/executor.go @@ -168,7 +168,11 @@ func (e *Executor) mockPhaseOutput(exec *robottypes.Execution, phase robottypes. } case robottypes.PhaseDelivery: exec.Delivery = &robottypes.DeliveryResult{ - Type: robottypes.DeliveryNotify, + RequestID: "dryrun-" + exec.ID, + Content: &robottypes.DeliveryContent{ + Summary: "Dry-run delivery completed", + Body: "# Dry-run Delivery\n\nThis is a simulated delivery result.", + }, Success: true, } case robottypes.PhaseLearning: diff --git a/agent/robot/executor/sandbox/executor.go b/agent/robot/executor/sandbox/executor.go index 3a066091..7a7d3b6f 100644 --- a/agent/robot/executor/sandbox/executor.go +++ b/agent/robot/executor/sandbox/executor.go @@ -201,7 +201,11 @@ func (e *Executor) mockPhaseOutput(exec *robottypes.Execution, phase robottypes. } case robottypes.PhaseDelivery: exec.Delivery = &robottypes.DeliveryResult{ - Type: robottypes.DeliveryNotify, + RequestID: "sandbox-" + exec.ID, + Content: &robottypes.DeliveryContent{ + Summary: "Sandbox delivery completed", + Body: "# Sandbox Delivery\n\nThis is a simulated sandbox delivery result.", + }, Success: true, } case robottypes.PhaseLearning: diff --git a/agent/robot/executor/standard/delivery.go b/agent/robot/executor/standard/delivery.go index 82c040df..a48f6d87 100644 --- a/agent/robot/executor/standard/delivery.go +++ b/agent/robot/executor/standard/delivery.go @@ -25,7 +25,11 @@ func (e *Executor) RunDelivery(ctx *robottypes.Context, exec *robottypes.Executi e.simulateStreamDelay() exec.Delivery = &robottypes.DeliveryResult{ - Type: robottypes.DeliveryNotify, + RequestID: "delivery-" + exec.ID, + Content: &robottypes.DeliveryContent{ + Summary: "Delivery completed (placeholder)", + Body: "# Delivery\n\nTODO: Implement real delivery logic.", + }, Success: true, } return nil diff --git a/agent/robot/executor/standard/goals.go b/agent/robot/executor/standard/goals.go index d7610c2b..5d531e0f 100644 --- a/agent/robot/executor/standard/goals.go +++ b/agent/robot/executor/standard/goals.go @@ -170,7 +170,7 @@ func ParseDelivery(data map[string]interface{}) *robottypes.DeliveryTarget { func IsValidDeliveryType(t robottypes.DeliveryType) bool { switch t { case robottypes.DeliveryEmail, robottypes.DeliveryWebhook, - robottypes.DeliveryFile, robottypes.DeliveryNotify: + robottypes.DeliveryProcess, robottypes.DeliveryNotify: return true default: return false diff --git a/agent/robot/executor/standard/goals_test.go b/agent/robot/executor/standard/goals_test.go index 8fcbb228..da34b84b 100644 --- a/agent/robot/executor/standard/goals_test.go +++ b/agent/robot/executor/standard/goals_test.go @@ -334,7 +334,7 @@ func TestParseDeliveryFromGoalsResponse(t *testing.T) { if exec.Goals.Delivery.Type != "" { validTypes := []types.DeliveryType{ types.DeliveryEmail, types.DeliveryWebhook, - types.DeliveryFile, types.DeliveryNotify, + types.DeliveryProcess, types.DeliveryNotify, } found := false for _, vt := range validTypes { @@ -355,7 +355,7 @@ func TestDeliveryTypeValidation(t *testing.T) { validTypes := []types.DeliveryType{ types.DeliveryEmail, types.DeliveryWebhook, - types.DeliveryFile, + types.DeliveryProcess, types.DeliveryNotify, } @@ -462,7 +462,7 @@ func TestParseDelivery(t *testing.T) { }) t.Run("parses all valid delivery types", func(t *testing.T) { - validTypes := []string{"email", "webhook", "file", "notify"} + validTypes := []string{"email", "webhook", "process", "notify"} for _, dt := range validTypes { data := map[string]interface{}{ diff --git a/agent/robot/executor/standard/input.go b/agent/robot/executor/standard/input.go index bcb4b023..d02d08dd 100644 --- a/agent/robot/executor/standard/input.go +++ b/agent/robot/executor/standard/input.go @@ -511,12 +511,17 @@ func (f *InputFormatter) FormatExecutionSummary(exec *robottypes.Execution) stri // Delivery (P4) if exec.Delivery != nil { sb.WriteString("## Delivery (P4)\n\n") - sb.WriteString(fmt.Sprintf("- **Type**: %s\n", exec.Delivery.Type)) + if exec.Delivery.Content != nil { + sb.WriteString(fmt.Sprintf("- **Summary**: %s\n", exec.Delivery.Content.Summary)) + } if exec.Delivery.Success { sb.WriteString("- **Status**: ✓ Success\n") } else { sb.WriteString(fmt.Sprintf("- **Status**: ✗ Failed (%s)\n", exec.Delivery.Error)) } + if len(exec.Delivery.Results) > 0 { + sb.WriteString(fmt.Sprintf("- **Channels**: %d\n", len(exec.Delivery.Results))) + } sb.WriteString("\n") } diff --git a/agent/robot/executor/standard/input_test.go b/agent/robot/executor/standard/input_test.go index 60f2c748..57c4a1b6 100644 --- a/agent/robot/executor/standard/input_test.go +++ b/agent/robot/executor/standard/input_test.go @@ -455,7 +455,11 @@ func TestInputFormatterFormatExecutionSummary(t *testing.T) { {TaskID: "t2", Success: true, Duration: 200}, }, Delivery: &types.DeliveryResult{ - Type: types.DeliveryEmail, + RequestID: "test-delivery-001", + Content: &types.DeliveryContent{ + Summary: "Test delivery completed", + Body: "# Test Delivery\n\nTest delivery body.", + }, Success: true, }, } @@ -476,7 +480,7 @@ func TestInputFormatterFormatExecutionSummary(t *testing.T) { assert.Contains(t, result, "## Results (P3)") assert.Contains(t, result, "✓ t1") assert.Contains(t, result, "## Delivery (P4)") - assert.Contains(t, result, "email") + assert.Contains(t, result, "Test delivery completed") }) t.Run("formats execution with error", func(t *testing.T) { diff --git a/agent/robot/job/execution_test.go b/agent/robot/job/execution_test.go index 87a6e505..e63f082d 100644 --- a/agent/robot/job/execution_test.go +++ b/agent/robot/job/execution_test.go @@ -278,8 +278,12 @@ func TestCompleteExecution(t *testing.T) { // Simulate execution progress exec.Delivery = &types.DeliveryResult{ + RequestID: "test-delivery-001", + Content: &types.DeliveryContent{ + Summary: "Test delivery completed", + Body: "# Test Delivery\n\nThis is a test delivery result.", + }, Success: true, - Type: types.DeliveryEmail, } err = job.CompleteExecution(ctx, exec)