Merge pull request #511 from linked-danis/fix/report-actual-wait-time
Report actual wait duration
This commit is contained in:
@@ -61,11 +61,13 @@ tools.set(
|
|||||||
execute: async function (this: PageAgentCore, input, { signal }) {
|
execute: async function (this: PageAgentCore, input, { signal }) {
|
||||||
// try to subtract LLM calling time from the actual wait time
|
// try to subtract LLM calling time from the actual wait time
|
||||||
const lastTimeUpdate = await this.pageController.getLastUpdateTime()
|
const lastTimeUpdate = await this.pageController.getLastUpdateTime()
|
||||||
const actualWaitTime = Math.max(0, input.seconds - (Date.now() - lastTimeUpdate) / 1000)
|
const secondsSinceLastUpdate = (Date.now() - lastTimeUpdate) / 1000
|
||||||
|
const actualWaitTime = Math.max(0, input.seconds - secondsSinceLastUpdate)
|
||||||
console.log(`actualWaitTime: ${actualWaitTime} seconds`)
|
console.log(`actualWaitTime: ${actualWaitTime} seconds`)
|
||||||
await waitFor(actualWaitTime, signal)
|
await waitFor(actualWaitTime, signal)
|
||||||
|
|
||||||
return `✅ Waited for ${input.seconds} seconds.`
|
const waitedSeconds = (secondsSinceLastUpdate + actualWaitTime).toFixed(2)
|
||||||
|
return `✅ Waited for ${waitedSeconds} seconds.`
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user