GDP calculates the market value delivered. In this case of the labour. If someone is paying for the labour, GDP will be affected by the value of that labour. If the net output in terms of a product at the end is zero, then that does not erase the labour.
The only case where digging and filling a hole does not increase GDP is if the labour is not paid for.
EDIT: Basically, the two methods you list are the income or expenditure ways of calculating GDP, but in both cases consumption by employers is a factor, and so the payment for the labour increases the GDP irrespective of whether they also increase the final output.
I'm not so sure calculating GDP by production would capture this. It should, mind you, as all GDP calculations should get the same answer, but a silly/stupid example of two LLMs digging and filling in a hole may not fit in a production calculation.
> the production approach estimates the total value of economic output and deducts the cost of intermediate goods that are consumed in the process (like those of materials and services)[1]
This is a very rough definition of it, but role with it. There is no economic value since the hole was dug only to be filled back in. There was a service paid for on each end of the project, but those are services that could fall into the category of intermediate goods consumed that is actually deducted. The transaction could actually have a negative GDP when using the production calculation approach.
[1] the production approach estimates the total value of economic output and deducts the cost of intermediate goods that are consumed in the process (like those of materials and services)