From c6d2bad8122ee970ca08c32a14ccfe9459dc4054 Mon Sep 17 00:00:00 2001 From: larryro <371767072@qq.com> Date: Fri, 4 Sep 2026 10:06:09 +0800 Subject: [PATCH] test(sandbox): wait for the fake CLI's AGENTS.md record to be written MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fake openclaw records the AGENTS.md it saw through a shell redirection, which creates and truncates seen.txt before cat fills it. waitForSeen returned on existence alone, so on a busy runner it could read the empty in-between state and the AGENTS.md safety cases failed with Expected "TALE SYSTEM PROMPT v1", Received "" — observed on five of seven recent pull-request Unit runs. Wait for a non-empty record instead; both fake-CLI branches write one. --- .../sandbox-runtime/daemon/src/tale-openclaw-run.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/sandbox-runtime/daemon/src/tale-openclaw-run.test.ts b/services/sandbox-runtime/daemon/src/tale-openclaw-run.test.ts index 9be6a3febe..a012da0984 100644 --- a/services/sandbox-runtime/daemon/src/tale-openclaw-run.test.ts +++ b/services/sandbox-runtime/daemon/src/tale-openclaw-run.test.ts @@ -114,7 +114,14 @@ function startWrapper(opts: { mode: 'ok' | 'hang'; systemPrompt?: string }) { async function waitForSeen(): Promise { const deadline = Date.now() + 10_000; while (Date.now() < deadline) { - if (existsSync(seenPath)) return readFileSync(seenPath, 'utf8'); + // The fake CLI records through a shell redirection, which creates (and + // truncates) the file BEFORE `cat` fills it: an existence check alone can + // read that empty in-between state and fail the assertion on a busy + // runner. Both branches write a non-empty record, so wait for content. + if (existsSync(seenPath)) { + const seen = readFileSync(seenPath, 'utf8'); + if (seen !== '') return seen; + } await Bun.sleep(20); } throw new Error('fake openclaw never started');