Skip to content

Commit 009cd5b

Browse files
authored
test(release): expose Codex follow-through lifecycle phases (#132539)
1 parent 21890ef commit 009cd5b

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎scripts/e2e/codex-npm-plugin-live-docker.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ PROMPT
498498
499499
echo "Running Codex progress follow-through regression turn..."
500500
OPENCLAW_PACKAGE_ROOT="$(openclaw_e2e_package_root "$NPM_CONFIG_PREFIX")"
501-
if node scripts/e2e/lib/codex-npm-plugin-live/followthrough-turn.mjs \
501+
if openclaw_e2e_run_command node scripts/e2e/lib/codex-npm-plugin-live/followthrough-turn.mjs \
502502
"$OPENCLAW_PACKAGE_ROOT" \
503503
"$FOLLOWTHROUGH_SESSION_ID" \
504504
"$MODEL_REF" \
@@ -512,6 +512,7 @@ else
512512
followthrough_status=$?
513513
fi
514514
echo "followthrough_agent_status: $followthrough_status stdout_bytes=$(wc -c </tmp/openclaw-codex-followthrough.json 2>/dev/null || printf 0) stderr_bytes=$(wc -c </tmp/openclaw-codex-followthrough.err 2>/dev/null || printf 0)"
515+
openclaw_e2e_print_log /tmp/openclaw-codex-followthrough.log
515516
if [ "$followthrough_status" -ne 0 ]; then
516517
dump_debug_logs "$followthrough_status"
517518
exit "$followthrough_status"

‎scripts/e2e/lib/codex-npm-plugin-live/followthrough-turn.mjs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,26 @@ const agentRuntimePath = path.join(
2121
"plugin-sdk",
2222
"agent-runtime.js",
2323
);
24+
const startedAt = Date.now();
25+
const markPhase = (phase) => {
26+
const resources = new Map();
27+
for (const type of process.getActiveResourcesInfo()) {
28+
resources.set(type, (resources.get(type) ?? 0) + 1);
29+
}
30+
console.log(
31+
JSON.stringify({
32+
phase,
33+
elapsedMs: Date.now() - startedAt,
34+
resources: Object.fromEntries(
35+
[...resources].toSorted(([left], [right]) => left.localeCompare(right)).slice(0, 32),
36+
),
37+
}),
38+
);
39+
};
40+
process.once("beforeExit", () => markPhase("followthrough:before-exit"));
41+
markPhase("followthrough:import-start");
2442
const { agentCommandFromIngress } = await import(pathToFileURL(agentRuntimePath).href);
43+
markPhase("followthrough:import-complete");
2544
if (typeof agentCommandFromIngress !== "function") {
2645
throw new Error(
2746
`package agent runtime did not export agentCommandFromIngress: ${agentRuntimePath}`,
@@ -35,6 +54,7 @@ const quietRuntime = {
3554
throw new Error(`agent runtime exited with code ${code}`);
3655
},
3756
};
57+
markPhase("followthrough:turn-start");
3858
const result = await agentCommandFromIngress(
3959
{
4060
agentId: "main",
@@ -56,4 +76,8 @@ const result = await agentCommandFromIngress(
5676
},
5777
quietRuntime,
5878
);
79+
markPhase("followthrough:turn-and-cleanup-complete");
5980
fs.writeFileSync(outputPath, `${JSON.stringify(result)}\n`);
81+
markPhase("followthrough:result-written");
82+
// Observe lingering resources without keeping a completed one-shot process alive.
83+
setTimeout(() => markPhase("followthrough:resources-after-result"), 1_000).unref();

‎test/scripts/docker-build-helper.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5175,6 +5175,7 @@ grep -Fxq preserved "$TMPDIR/caller-fd"
51755175
"assert-agent-error",
51765176
"assert-followthrough",
51775177
"followthrough-turn.mjs",
5178+
"if openclaw_e2e_run_command node scripts/e2e/lib/codex-npm-plugin-live/followthrough-turn.mjs",
51785179
"docker_e2e_read_positive_int_env OPENCLAW_CODEX_NPM_PLUGIN_AGENT_TIMEOUT_SECONDS 420",
51795180
'docker_e2e_read_positive_int_env OPENCLAW_CODEX_NPM_PLUGIN_AGENT_TIMEOUT_SECONDS "$AGENT_TURN_TIMEOUT_SECONDS"',
51805181
'-e "OPENCLAW_CODEX_NPM_PLUGIN_AGENT_TIMEOUT_SECONDS=$AGENT_TURN_TIMEOUT_SECONDS"',
@@ -5245,6 +5246,18 @@ grep -Fxq preserved "$TMPDIR/caller-fd"
52455246
expect(result.status, result.stderr).toBe(0);
52465247
expect(result.stderr).toBe("");
52475248
expect(result.stdout).toContain("unexpected subsystem output");
5249+
const phases = result.stdout
5250+
.split("\n")
5251+
.filter((line) => line.startsWith('{"phase":"followthrough:'))
5252+
.map((line) => JSON.parse(line).phase);
5253+
expect(phases).toEqual([
5254+
"followthrough:import-start",
5255+
"followthrough:import-complete",
5256+
"followthrough:turn-start",
5257+
"followthrough:turn-and-cleanup-complete",
5258+
"followthrough:result-written",
5259+
"followthrough:before-exit",
5260+
]);
52485261
expect(JSON.parse(readFileSync(outputPath, "utf8"))).toEqual({
52495262
captured: expect.objectContaining({
52505263
sessionId: "followthrough-session",

0 commit comments

Comments
 (0)