mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-29 06:00:52 +02:00
Fix finalization cleanup for pending tool executions
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"cyberstrike-ai/internal/database"
|
||||
"cyberstrike-ai/internal/mcp"
|
||||
"cyberstrike-ai/internal/multiagent"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -130,3 +131,23 @@ func TestDecideAllowsInformationalAnswerWhenExecutionEvidenceIsNotRequired(t *te
|
||||
t.Fatalf("informational response should finalize when execution evidence is not required: %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFromRunResultDoesNotReusePreviousFinalizationStatusAsRunStatus(t *testing.T) {
|
||||
db := newDecisionTestDB(t)
|
||||
saveDecisionTestExecution(t, db, "run-slow", mcp.ToolExecutionStatusRunning)
|
||||
result := &multiagent.RunResult{
|
||||
Response: "工具已触发,按用户要求直接总结。",
|
||||
MCPExecutionIDs: []string{"run-slow"},
|
||||
}
|
||||
|
||||
first := FromRunResult(db, result, Input{})
|
||||
if first.Finalizable || first.CompletionReason != ReasonPendingTools || result.Status != StatusInProgress {
|
||||
t.Fatalf("first decision should mark pending and write metadata: decision=%+v result=%+v", first, result)
|
||||
}
|
||||
|
||||
saveDecisionTestExecution(t, db, "run-slow", mcp.ToolExecutionStatusCancelled)
|
||||
second := FromRunResult(db, result, Input{})
|
||||
if !second.Finalizable || !second.Finalized || second.Status != StatusCompleted {
|
||||
t.Fatalf("second decision should ignore previous result status after pending cleanup: decision=%+v result=%+v", second, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user