























@@ -583,6 +583,23 @@ describe("agents.create", () => {
583583expect(mocks.writeConfigFile).not.toHaveBeenCalled();
584584});
585585586+it("returns an invalid request when a concurrent create wins the config race", async () => {
587+let findCallCount = 0;
588+mocks.findAgentEntryIndex.mockImplementation(() => {
589+findCallCount += 1;
590+return findCallCount >= 2 ? 0 : -1;
591+});
592+593+const { respond, promise } = makeCall("agents.create", {
594+name: "Race Agent",
595+workspace: "/tmp/ws",
596+});
597+await promise;
598+599+expectRespondErrorContaining(respond, "already exists");
600+expect(mocks.writeConfigFile).not.toHaveBeenCalled();
601+});
602+586603it("rejects invalid params (missing name)", async () => {
587604const { respond, promise } = makeCall("agents.create", {
588605workspace: "/tmp/ws",
@@ -770,6 +787,22 @@ describe("agents.update", () => {
770787expectNotFoundResponseAndNoWrite(respond);
771788});
772789790+it("returns not found when a concurrent delete wins the update race", async () => {
791+let findCallCount = 0;
792+mocks.findAgentEntryIndex.mockImplementation(() => {
793+findCallCount += 1;
794+return findCallCount >= 2 ? -1 : 0;
795+});
796+797+const { respond, promise } = makeCall("agents.update", {
798+agentId: "test-agent",
799+model: "gpt-5.5",
800+});
801+await promise;
802+803+expectNotFoundResponseAndNoWrite(respond);
804+});
805+773806it("ensures workspace when workspace changes", async () => {
774807const { promise } = makeCall("agents.update", {
775808agentId: "test-agent",
@@ -1132,6 +1165,22 @@ describe("agents.delete", () => {
11321165expectNotFoundResponseAndNoWrite(respond);
11331166});
113411671168+it("returns not found when a concurrent delete wins the delete race", async () => {
1169+let findCallCount = 0;
1170+mocks.findAgentEntryIndex.mockImplementation(() => {
1171+findCallCount += 1;
1172+return findCallCount >= 2 ? -1 : 0;
1173+});
1174+1175+const { respond, promise } = makeCall("agents.delete", {
1176+agentId: "test-agent",
1177+});
1178+await promise;
1179+1180+expectNotFoundResponseAndNoWrite(respond);
1181+expect(mocks.movePathToTrash).not.toHaveBeenCalled();
1182+});
1183+11351184it("rejects invalid params (missing agentId)", async () => {
11361185const { respond, promise } = makeCall("agents.delete", {});
11371186await promise;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。