diff --git a/apps/edge/internal/openai/hot_path_cleanup.go b/apps/edge/internal/openai/hot_path_cleanup.go index e82d68f3..d4bd7624 100644 --- a/apps/edge/internal/openai/hot_path_cleanup.go +++ b/apps/edge/internal/openai/hot_path_cleanup.go @@ -274,10 +274,20 @@ func (s *hotPathLightStore) consumeCleanupLocked( results []workspaceResult, coordinator *logicalRequestCoordinator, ) (logicalRequestSnapshot, hotPathLightDisposition, bool, error) { - if record.terminalIntent == nil || len(record.pending) != 1 || len(results) != 1 { + if record.terminalIntent == nil || len(record.pending) != 1 { + return logicalRequestSnapshot{}, hotPathLightDisposition{}, true, fmt.Errorf("cleanup result set mismatch") + } + var result workspaceResult + matchedResults := 0 + for _, candidate := range results { + if _, ok := record.pending[candidate.callID]; ok { + result = candidate + matchedResults++ + } + } + if matchedResults != 1 { return logicalRequestSnapshot{}, hotPathLightDisposition{}, true, fmt.Errorf("cleanup result set mismatch") } - result := results[0] pending, ok := record.pending[result.callID] if !ok || pending.payload == nil { return logicalRequestSnapshot{}, hotPathLightDisposition{}, true, fmt.Errorf("cleanup result id is not pending")