From e525e4c6dd0950b6cabba589c720f5ce44268ac8 Mon Sep 17 00:00:00 2001 From: linked-danis Date: Mon, 18 May 2026 14:53:24 +0200 Subject: [PATCH] fix: report actual wait duration --- packages/core/src/tools/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/core/src/tools/index.ts b/packages/core/src/tools/index.ts index 4cc8d56..3ab51f4 100644 --- a/packages/core/src/tools/index.ts +++ b/packages/core/src/tools/index.ts @@ -53,11 +53,17 @@ tools.set( execute: async function (this: PageAgentCore, input) { // try to subtract LLM calling time from the actual wait time 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`) await waitFor(actualWaitTime) - return `✅ Waited for ${input.seconds} seconds.` + const waitedSeconds = Number(actualWaitTime.toFixed(2)) + if (waitedSeconds === input.seconds) { + return `✅ Waited for ${input.seconds} seconds.` + } + + return `✅ Waited for ${waitedSeconds} seconds. ${secondsSinceLastUpdate.toFixed(2)} seconds had already passed since the last page update.` }, }) )