






















@@ -791,7 +791,8 @@ describe("sessions tools", () => {
791791it("sessions_send supports fire-and-forget and wait", async () => {
792792const calls: Array<{ method?: string; params?: unknown }> = [];
793793let agentCallCount = 0;
794-let _historyCallCount = 0;
794+let historyCallCount = 0;
795+let waitCallCount = 0;
795796let sendCallCount = 0;
796797let lastWaitedRunId: string | undefined;
797798const replyByRunId = new Map<string, string>();
@@ -820,12 +821,13 @@ describe("sessions tools", () => {
820821};
821822}
822823if (request.method === "agent.wait") {
824+waitCallCount += 1;
823825const params = request.params as { runId?: string } | undefined;
824826lastWaitedRunId = params?.runId;
825827return { runId: params?.runId ?? "run-1", status: "ok" };
826828}
827829if (request.method === "chat.history") {
828-_historyCallCount += 1;
830+historyCallCount += 1;
829831const text = (lastWaitedRunId && replyByRunId.get(lastWaitedRunId)) ?? "";
830832return {
831833messages: [
@@ -867,9 +869,9 @@ describe("sessions tools", () => {
867869runId: "run-1",
868870delivery: { status: "pending", mode: "announce" },
869871});
870-await waitForCalls(() => calls.filter((call) => call.method === "agent").length, 3);
871-await waitForCalls(() => calls.filter((call) => call.method === "agent.wait").length, 3);
872-await waitForCalls(() => calls.filter((call) => call.method === "chat.history").length, 3);
872+await waitForCalls(() => agentCallCount, 3);
873+await waitForCalls(() => waitCallCount, 3);
874+await waitForCalls(() => historyCallCount, 3);
873875874876const waitPromise = tool.execute("call6", {
875877sessionKey: "main",
@@ -883,9 +885,9 @@ describe("sessions tools", () => {
883885delivery: { status: "pending", mode: "announce" },
884886});
885887expect(typeof (waited.details as { runId?: string }).runId).toBe("string");
886-await waitForCalls(() => calls.filter((call) => call.method === "agent").length, 6);
887-await waitForCalls(() => calls.filter((call) => call.method === "agent.wait").length, 6);
888-await waitForCalls(() => calls.filter((call) => call.method === "chat.history").length, 7);
888+await waitForCalls(() => agentCallCount, 6);
889+await waitForCalls(() => waitCallCount, 6);
890+await waitForCalls(() => historyCallCount, 7);
889891890892const agentCalls = calls.filter((call) => call.method === "agent");
891893const waitCalls = calls.filter((call) => call.method === "agent.wait");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。