mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:24:30 +00:00
fix(subagents): pass group context in /subagents spawn
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { resetSubagentRegistryForTests } from "../../agents/subagent-registry.js";
|
||||
import type { SpawnSubagentResult } from "../../agents/subagent-spawn.js";
|
||||
import { resetSubagentRegistryForTests } from "../../agents/subagent-registry.js";
|
||||
|
||||
const hoisted = vi.hoisted(() => {
|
||||
const spawnSubagentDirectMock = vi.fn();
|
||||
@@ -126,6 +126,28 @@ describe("/subagents spawn command", () => {
|
||||
expect(spawnParams.task).toBe("do the thing");
|
||||
});
|
||||
|
||||
it("passes group context from session entry to spawnSubagentDirect", async () => {
|
||||
spawnSubagentDirectMock.mockResolvedValue(acceptedResult());
|
||||
const params = buildCommandTestParams("/subagents spawn beta do the thing", baseCfg);
|
||||
params.sessionEntry = {
|
||||
sessionId: "session-main",
|
||||
updatedAt: Date.now(),
|
||||
groupId: "group-1",
|
||||
groupChannel: "#group-channel",
|
||||
space: "workspace-1",
|
||||
};
|
||||
const result = await handleSubagentsCommand(params, true);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.reply?.text).toContain("Spawned subagent beta");
|
||||
|
||||
const [, spawnCtx] = spawnSubagentDirectMock.mock.calls[0];
|
||||
expect(spawnCtx).toMatchObject({
|
||||
agentGroupId: "group-1",
|
||||
agentGroupChannel: "#group-channel",
|
||||
agentGroupSpace: "workspace-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns forbidden for unauthorized cross-agent spawn", async () => {
|
||||
spawnSubagentDirectMock.mockResolvedValue(
|
||||
forbiddenResult("agentId is not allowed for sessions_spawn (allowed: alpha)"),
|
||||
|
||||
Reference in New Issue
Block a user