perf(test): shrink subagent announce fast-mode settle waits

This commit is contained in:
Peter Steinberger
2026-02-22 09:27:44 +00:00
parent 267d2193bf
commit 35d5bd4e07
2 changed files with 14 additions and 33 deletions

View File

@@ -38,6 +38,8 @@ import type { SpawnSubagentMode } from "./subagent-spawn.js";
import { readLatestAssistantReply } from "./tools/agent-step.js";
import { sanitizeTextContent, extractAssistantText } from "./tools/sessions-helpers.js";
const FAST_TEST_MODE = process.env.OPENCLAW_TEST_FAST === "1";
type ToolResultMessage = {
role?: unknown;
content?: unknown;
@@ -294,7 +296,8 @@ async function buildCompactAnnounceStatsLine(params: {
const agentId = resolveAgentIdFromSessionKey(params.sessionKey);
const storePath = resolveStorePath(cfg.session?.store, { agentId });
let entry = loadSessionStore(storePath)[params.sessionKey];
for (let attempt = 0; attempt < 3; attempt += 1) {
const tokenWaitAttempts = FAST_TEST_MODE ? 1 : 3;
for (let attempt = 0; attempt < tokenWaitAttempts; attempt += 1) {
const hasTokenData =
typeof entry?.inputTokens === "number" ||
typeof entry?.outputTokens === "number" ||
@@ -302,7 +305,9 @@ async function buildCompactAnnounceStatsLine(params: {
if (hasTokenData) {
break;
}
await new Promise((resolve) => setTimeout(resolve, 150));
if (!FAST_TEST_MODE) {
await new Promise((resolve) => setTimeout(resolve, 150));
}
entry = loadSessionStore(storePath)[params.sessionKey];
}
@@ -1037,10 +1042,11 @@ export async function runSubagentAnnounceFlow(params: {
}
if (requesterDepth >= 1 && reply?.trim()) {
const minReplyChangeWaitMs = FAST_TEST_MODE ? 120 : 250;
reply = await waitForSubagentOutputChange({
sessionKey: params.childSessionKey,
baselineReply: reply,
maxWaitMs: Math.max(250, Math.min(params.timeoutMs, 2_000)),
maxWaitMs: Math.max(minReplyChangeWaitMs, Math.min(params.timeoutMs, 2_000)),
});
}