

























@@ -13,13 +13,16 @@ describe("subagent target policy", () => {
1313requestedAgentId: "main",
1414}),
1515).toEqual({ ok: true });
16-expect(
17-resolveSubagentTargetPolicy({
18-requesterAgentId: "main",
19-targetAgentId: "other",
20-requestedAgentId: "other",
21-}),
22-).toMatchObject({ ok: false, allowedText: "main" });
16+const result = resolveSubagentTargetPolicy({
17+requesterAgentId: "main",
18+targetAgentId: "other",
19+requestedAgentId: "other",
20+});
21+expect(result.ok).toBe(false);
22+if (result.ok) {
23+throw new Error("Expected target policy to reject other agent");
24+}
25+expect(result.allowedText).toBe("main");
2326});
24272528it("keeps omitted agentId self-spawns allowed even when an allowlist is configured", () => {
@@ -33,18 +36,20 @@ describe("subagent target policy", () => {
3336});
34373538it("rejects explicit self-targets when the configured allowlist excludes the requester", () => {
36-expect(
37-resolveSubagentTargetPolicy({
38-requesterAgentId: "task-manager",
39-targetAgentId: "task-manager",
40-requestedAgentId: "task-manager",
41-allowAgents: ["planner", "checker"],
42-}),
43-).toMatchObject({
44-ok: false,
45-allowedText: "checker, planner",
46-error: "agentId is not allowed for sessions_spawn (allowed: checker, planner)",
39+const result = resolveSubagentTargetPolicy({
40+requesterAgentId: "task-manager",
41+targetAgentId: "task-manager",
42+requestedAgentId: "task-manager",
43+allowAgents: ["planner", "checker"],
4744});
45+expect(result.ok).toBe(false);
46+if (result.ok) {
47+throw new Error("Expected target policy to reject explicit self-target");
48+}
49+expect(result.allowedText).toBe("checker, planner");
50+expect(result.error).toBe(
51+"agentId is not allowed for sessions_spawn (allowed: checker, planner)",
52+);
4853});
49545055it("resolves allowed target ids without auto-adding requester for explicit allowlists", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。