Skip to content

Commit cc296f3

Browse files
committed
docs: document subagent tests
1 parent f39aff1 commit cc296f3

10 files changed

Lines changed: 34 additions & 0 deletions

src/agents/minimax-docs.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// MiniMax docs sync tests keep provider docs and live-test guidance aligned
2+
// with the shared MiniMax model constants.
13
import fs from "node:fs";
24
import path from "node:path";
35
import { describe, expect, it } from "vitest";

src/agents/subagent-announce.live.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Live subagent announce E2E tests exercise real gateway, session, and provider
2+
// flows for subagent completion delivery.
13
import { randomBytes, randomUUID } from "node:crypto";
24
import fs from "node:fs/promises";
35
import path from "node:path";
@@ -67,6 +69,8 @@ function resolveLiveSubagentModelConfig(): LiveSubagentModelConfig {
6769
}
6870

6971
function requireLiveSubagentAuth(config: LiveSubagentModelConfig): void {
72+
// Live E2E runs need the provider credential that matches the selected model
73+
// family; fail early before gateway startup.
7074
expect(process.env[config.requiredEnv]?.trim(), config.requiredEnv).toBeTruthy();
7175
}
7276

src/agents/subagent-registry.archive.e2e.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent registry archive tests cover keep/delete cleanup modes, retryable
2+
// session deletion, and context-engine lifecycle callbacks.
13
import { promises as fs } from "node:fs";
24
import os from "node:os";
35
import path from "node:path";
@@ -10,6 +12,8 @@ let currentConfig = {
1012
};
1113
const loadConfigMock = vi.fn(() => currentConfig);
1214
const flushSweepMicrotasks = async () => {
15+
// Archive sweeps schedule follow-up work through microtasks; drain them before
16+
// asserting registry and context-engine side effects.
1317
await Promise.resolve();
1418
await Promise.resolve();
1519
};

src/agents/subagent-registry.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent registry tests cover run state, completion capture, archive cleanup,
2+
// persistence, lifecycle hooks, and orphan recovery scheduling.
13
import { promises as fs } from "node:fs";
24
import os from "node:os";
35
import path from "node:path";
@@ -59,6 +61,8 @@ function findRecordCallArg(
5961
}
6062

6163
async function expectPathMissing(targetPath: string): Promise<void> {
64+
// Cleanup assertions need ENOENT proof; fs.access success means the artifact
65+
// directory survived when lifecycle cleanup should have removed it.
6266
try {
6367
await fs.access(targetPath);
6468
} catch (error) {

src/agents/subagent-run-timeout.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent run timeout tests keep semantic deadlines separate from the maximum
2+
// delay that Node timers can safely schedule.
13
import { describe, expect, it } from "vitest";
24
import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";
35
import {
@@ -20,6 +22,8 @@ describe("subagent run timeout helpers", () => {
2022
});
2123

2224
it("caps actual timer delays without shortening semantic durations", () => {
25+
// Long-lived subagent runs retain their requested deadline even though the
26+
// watchdog timer must be scheduled in bounded chunks.
2327
const thirtyDaysSeconds = 30 * 24 * 60 * 60;
2428

2529
expect(resolveSubagentRunTimerDelayMs(thirtyDaysSeconds)).toBe(MAX_TIMER_TIMEOUT_MS);

src/agents/subagent-spawn.model-session.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent spawn model-session tests verify runtime model metadata is persisted
2+
// before a child agent run starts.
13
import os from "node:os";
24
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
35
import {
@@ -46,6 +48,8 @@ describe("spawnSubagentDirect runtime model persistence", () => {
4648
});
4749

4850
it("persists runtime model fields on the child session before starting the run", async () => {
51+
// The child run reads model/provider from session state, so persistence must
52+
// happen before the gateway accepts the agent request.
4953
const operations: string[] = [];
5054
callGatewayMock.mockImplementation(async (opts: { method?: string }) => {
5155
operations.push(`gateway:${opts.method ?? "unknown"}`);

src/agents/subagent-spawn.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent spawn tests cover target policy, session patching, runtime model
2+
// persistence, registry registration, and lifecycle event emission.
13
import os from "node:os";
24
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
35
import {
@@ -47,6 +49,8 @@ function requireRecord(value: unknown): Record<string, unknown> {
4749
}
4850

4951
function gatewayRequestRecords(): Record<string, unknown>[] {
52+
// Gateway calls are the seam proof for spawn orchestration; assertions inspect
53+
// structured requests instead of matching rendered text.
5054
return hoisted.callGatewayMock.mock.calls.map((call) => requireRecord(call[0]));
5155
}
5256

src/agents/subagent-target-policy.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Subagent target policy tests cover requester defaults, explicit allowlists,
2+
// wildcard target sets, and stale configured-agent filtering.
13
import { describe, expect, it } from "vitest";
24
import {
35
resolveSubagentAllowedTargetIds,

src/agents/tool-call-id.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Tool-call id tests cover provider-safe rewrites, collision handling, replay
2+
// preservation for signed thinking turns, and strict short-id mode.
13
import type { AgentMessage } from "openclaw/plugin-sdk/agent-core";
24
import { describe, expect, it } from "vitest";
35
import { castAgentMessages } from "./test-helpers/agent-message-fixtures.js";
@@ -148,6 +150,8 @@ function expectReplaySafeSignedTurnOwnership(params: {
148150
preservedTurn: "first" | "second";
149151
firstToolCallIndex: number;
150152
}) {
153+
// Signed thinking blocks bind the following tool call; replay repair may keep
154+
// only the safe turn's id and must rewrite the colliding sibling turn.
151155
const out = sanitizeToolCallIdsForCloudCodeAssist(params.input, "strict", {
152156
preserveReplaySafeThinkingToolCallIds: true,
153157
allowedToolNames: ["read"],

src/agents/tool-replay-repair.live.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Live tool replay repair tests validate repaired historical transcripts across
2+
// selected real model providers.
13
import type { AgentMessage } from "openclaw/plugin-sdk/agent-core";
24
import { SessionManager } from "openclaw/plugin-sdk/agent-sessions";
35
import type { Context, Model } from "openclaw/plugin-sdk/llm";

0 commit comments

Comments
 (0)