From e525e4c6dd0950b6cabba589c720f5ce44268ac8 Mon Sep 17 00:00:00 2001 From: linked-danis Date: Mon, 18 May 2026 14:53:24 +0200 Subject: [PATCH 1/2] 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.` }, }) ) From fb8c42daa4080908dd70cebd5b752fe3549652c5 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Fri, 12 Jun 2026 17:44:21 +0800 Subject: [PATCH 2/2] feat: simplify waiting response to reduce LLM cognitive load --- packages/core/src/tools/index.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/core/src/tools/index.ts b/packages/core/src/tools/index.ts index 3ab51f4..466060f 100644 --- a/packages/core/src/tools/index.ts +++ b/packages/core/src/tools/index.ts @@ -58,12 +58,8 @@ tools.set( console.log(`actualWaitTime: ${actualWaitTime} seconds`) await waitFor(actualWaitTime) - 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.` + const waitedSeconds = (secondsSinceLastUpdate + actualWaitTime).toFixed(2) + return `✅ Waited for ${waitedSeconds} seconds.` }, }) )