mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:57:40 +00:00
feat: refine subagents + add chat.inject
Co-authored-by: Tyler Yust <tyler6204@users.noreply.github.com>
This commit is contained in:
@@ -68,21 +68,24 @@ describe("subagent registry persistence", () => {
|
||||
const mod2 = await import("./subagent-registry.js");
|
||||
mod2.initSubagentRegistry();
|
||||
|
||||
// allow queued async wait/announce to execute
|
||||
// allow queued async wait/cleanup to execute
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
|
||||
expect(announceSpy).toHaveBeenCalled();
|
||||
|
||||
type AnnounceParams = {
|
||||
childRunId: string;
|
||||
childSessionKey: string;
|
||||
childRunId: string;
|
||||
requesterSessionKey: string;
|
||||
task: string;
|
||||
cleanup: string;
|
||||
label?: string;
|
||||
};
|
||||
const first = announceSpy.mock.calls[0]?.[0] as unknown as AnnounceParams;
|
||||
expect(first.childRunId).toBe("run-1");
|
||||
expect(first.childSessionKey).toBe("agent:main:subagent:test");
|
||||
});
|
||||
|
||||
it("retries announce even when announceHandled was persisted", async () => {
|
||||
it("skips cleanup when cleanupHandled/announceHandled was persisted", async () => {
|
||||
tempStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-subagent-"));
|
||||
process.env.CLAWDBOT_STATE_DIR = tempStateDir;
|
||||
|
||||
@@ -100,7 +103,7 @@ describe("subagent registry persistence", () => {
|
||||
createdAt: 1,
|
||||
startedAt: 1,
|
||||
endedAt: 2,
|
||||
announceHandled: true,
|
||||
cleanupHandled: true, // Already handled - should be skipped
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -113,10 +116,11 @@ describe("subagent registry persistence", () => {
|
||||
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
|
||||
// announce should NOT be called since cleanupHandled was true
|
||||
const calls = announceSpy.mock.calls.map((call) => call[0]);
|
||||
const match = calls.find(
|
||||
(params) => (params as { childRunId?: string }).childRunId === "run-2",
|
||||
(params) => (params as { childSessionKey?: string }).childSessionKey === "agent:main:subagent:two",
|
||||
);
|
||||
expect(match).toBeTruthy();
|
||||
expect(match).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user