workflow-escalation.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /**
  2. * 升级问答桥接的 driver 层用例(apps/zcode-cli/packages/dynamic-workflow/docs/execution-engine.md 的 Slice 1)。
  3. *
  4. * 被测对象是 driver 与停驻注册表之间的那条线:铸 qid → 停驻 deferred → 双轨发事件 →
  5. * 经注册表结算 → 工具结果 = 答案。核心工具面(`escalate` / `ResolveWorkflowQuestion`)与
  6. * 通知生产不在本切片里,所以这里**直接持 escalatePort 调用**——那正是将来 core 的工具
  7. * handler 会做的事,端口的形状因此被逐字钉住。
  8. *
  9. * 装配刻意最小:一个 executeTurn 永不 resolve 的 stub runtime(模拟一次真实的、被升级问答
  10. * 阻塞住的 turn)+ 内存 journal。不走 runWorkflowScript——引擎核心对升级零感知,把它拉进来
  11. * 只会让「谁发的这个事件」变得难以断言。
  12. */
  13. import { describe, expect, it } from "vitest";
  14. import {
  15. createRootTraceContext,
  16. createSessionId,
  17. createToolCallId,
  18. createTurnId,
  19. DYNAMIC_WORKFLOW_RUN_EVENT_PAYLOAD_LIMITS,
  20. ESCALATE_TOOL_NAME,
  21. RESOLVE_WORKFLOW_QUESTION_TOOL_NAME,
  22. type EscalateQuestionRequest,
  23. type WorkflowEscalatePort,
  24. } from "@zcode/contracts";
  25. import {
  26. InMemoryJournalStore,
  27. type ActorRef,
  28. type InstanceRef,
  29. type PersonaSpec,
  30. type RunEvent,
  31. type SessionRef,
  32. type WorkflowDriver,
  33. type WorkflowReportSink,
  34. } from "@zcode/dynamic-workflow";
  35. import { toProtocolEvent } from "../src/app/dynamic-workflow-run-launch.js";
  36. import { workflowActorToolPolicy } from "../src/app/workflow-actor-tools.js";
  37. import { createAgentRuntimeWorkflowDriver } from "../src/app/workflow-driver.js";
  38. import {
  39. createWorkflowEscalationRegistry,
  40. type WorkflowEscalationRegistry,
  41. } from "../src/app/workflow-escalation-registry.js";
  42. import { fakeFileSystemPort, unsupportedExecutionPort } from "./workflow-driver.helpers.js";
  43. const NOOP_SINK: WorkflowReportSink = {
  44. askSubmitAttempted: () => {},
  45. askTurnEnded: () => {},
  46. askProgress: () => {},
  47. askStats: () => {},
  48. askFailed: () => {},
  49. };
  50. const CAPS = { maxConcurrency: 16 };
  51. /** 一次 escalate 调用的请求袋(trace / toolCallId 对本层无语义,只为满足端口契约)。 */
  52. function escalateRequest(question: string, context?: string): EscalateQuestionRequest {
  53. const sessionId = createSessionId("escalation-test");
  54. return {
  55. toolCallId: createToolCallId("escalate-call"),
  56. question,
  57. ...(context === undefined ? {} : { context }),
  58. trace: createRootTraceContext({ sessionId, turnId: createTurnId("escalation-test") }),
  59. };
  60. }
  61. interface EscalationHarness {
  62. driver: WorkflowDriver;
  63. events: RunEvent[];
  64. journal: InMemoryJournalStore;
  65. registry: WorkflowEscalationRegistry;
  66. runId: string;
  67. /** 建会话 + 派一个 ask,回该会话的升级端口、会话与 ask 实例(升级要求有在飞 ask)。 */
  68. openAsk(
  69. ordinal?: number,
  70. persona?: PersonaSpec,
  71. ): Promise<{ port: WorkflowEscalatePort; session: SessionRef; instance: InstanceRef }>;
  72. }
  73. function makeHarness(
  74. options: { registry?: WorkflowEscalationRegistry; runId?: string } = {},
  75. ): EscalationHarness {
  76. const runId = options.runId ?? "dwfrun-11112222-3333-4444";
  77. const journal = new InMemoryJournalStore();
  78. journal.createRun({ runId, caps: CAPS, spentTokens: 0, status: "running" });
  79. const registry = options.registry ?? createWorkflowEscalationRegistry();
  80. const events: RunEvent[] = [];
  81. const ports: WorkflowEscalatePort[] = [];
  82. const driver = createAgentRuntimeWorkflowDriver({
  83. journal,
  84. emit: (event) => events.push(event),
  85. escalationRegistry: registry,
  86. executionPort: unsupportedExecutionPort(),
  87. fileSystemPort: fakeFileSystemPort({}),
  88. cwd: process.cwd(),
  89. runId,
  90. runtimeFactory: ({ escalatePort }) => {
  91. ports.push(escalatePort);
  92. // turn 永不结束:真实场景里一次停驻的升级正是这样把 turn 挂住的。
  93. return { executeTurn: () => new Promise(() => {}) } as never;
  94. },
  95. })(NOOP_SINK);
  96. return {
  97. driver,
  98. events,
  99. journal,
  100. registry,
  101. runId,
  102. async openAsk(ordinal = 1, persona: PersonaSpec = {}) {
  103. const actor: ActorRef = { siteId: "actor#1", ordinal };
  104. // persona 原样递进去,照引擎的做法(scheduler 把已规范化的 actor.persona 交给 driver)。
  105. const session = await driver.createActorSession(actor, persona);
  106. const instance: InstanceRef = { siteId: "ask#1", ordinal };
  107. driver.startAsk(session, instance, { instructions: "go", typed: false });
  108. const port = ports[ports.length - 1];
  109. if (port === undefined) throw new Error("runtimeFactory 没有交出 escalatePort");
  110. return { port, session, instance };
  111. },
  112. };
  113. }
  114. describe("workflow escalation — 停驻与结算", () => {
  115. it("停驻的问题被作答后,答案原样成为 escalate 的结果", async () => {
  116. const harness = makeHarness();
  117. const { port } = await harness.openAsk();
  118. const pending = port.escalate(escalateRequest("评分上限 95 而门槛 96,这个门是不是坏了?"));
  119. // 停驻是同步发生的:escalate 一返回 promise,注册表里就该看得见这个问题。
  120. const parked = harness.registry.pendingFor(harness.runId);
  121. expect(parked).toHaveLength(1);
  122. expect(parked[0]).toMatchObject({
  123. actor: "actor#1@1",
  124. question: "评分上限 95 而门槛 96,这个门是不是坏了?",
  125. });
  126. expect(parked[0]?.qid).toMatch(/^dwfq-11112222-1$/);
  127. expect(typeof parked[0]?.askedAt).toBe("number");
  128. const resolved = harness.registry.resolve(parked[0]!.qid, "门确实坏了,按 95 通过即可。");
  129. expect(resolved).toEqual({ ok: true, qid: parked[0]!.qid });
  130. await expect(pending).resolves.toEqual({
  131. kind: "answered",
  132. answer: "门确实坏了,按 95 通过即可。",
  133. qid: parked[0]!.qid,
  134. });
  135. // 结算后停驻表就地清空——快照的 pendingQuestions 因此自动收敛。
  136. expect(harness.registry.pendingFor(harness.runId)).toEqual([]);
  137. });
  138. it("askedAt 是提问那一刻的 epoch 毫秒,且事件与停驻记录共用同一个瞬间", async () => {
  139. const harness = makeHarness();
  140. const { port } = await harness.openAsk();
  141. const before = Date.now();
  142. void port.escalate(escalateRequest("现在几点?")).catch(() => {});
  143. const after = Date.now();
  144. const parked = harness.registry.pendingFor(harness.runId)[0]!;
  145. const event = harness.events[0] as { askedAt?: number };
  146. expect(parked.askedAt).toBeGreaterThanOrEqual(before);
  147. expect(parked.askedAt).toBeLessThanOrEqual(after);
  148. // 同一个瞬间,不是两次相近的取值:实时轨与快照上的「等了多久」因此永不分叉。
  149. expect(event.askedAt).toBe(parked.askedAt);
  150. });
  151. it("context 一并停驻,空白 context 视同缺席", async () => {
  152. const harness = makeHarness();
  153. const { port } = await harness.openAsk();
  154. void port.escalate(escalateRequest("A?", "我试过把门槛调低但脚本是只读的")).catch(() => {});
  155. void port.escalate(escalateRequest("B?", " ")).catch(() => {});
  156. const parked = harness.registry.pendingFor(harness.runId);
  157. expect(parked[0]?.context).toBe("我试过把门槛调低但脚本是只读的");
  158. expect(parked[1]).not.toHaveProperty("context");
  159. });
  160. it("每个 ask 最多停驻 3 次,第 4 次立即回「预算已尽」的普通结果", async () => {
  161. const harness = makeHarness();
  162. const { port } = await harness.openAsk();
  163. for (let index = 0; index < 3; index++) {
  164. void port.escalate(escalateRequest(`问题 ${index}`)).catch(() => {});
  165. }
  166. expect(harness.registry.pendingFor(harness.runId)).toHaveLength(3);
  167. // 第 4 次:不停驻、不发事件、不是错误——一条让模型自行推进的普通工具结果。
  168. const eventsBefore = harness.events.length;
  169. const fourth = await port.escalate(escalateRequest("问题 3"));
  170. expect(fourth).toMatchObject({ kind: "refused", reason: "budget_exhausted" });
  171. // reason 已断言;消息只验可变部分(上限次数)。
  172. expect(fourth.kind === "refused" && fourth.message).toContain("at most 3 escalations");
  173. expect(harness.registry.pendingFor(harness.runId)).toHaveLength(3);
  174. expect(harness.events).toHaveLength(eventsBefore);
  175. });
  176. it("预算按 ask 归零,且换 ask 时撤下上一个 ask 的遗留停驻项", async () => {
  177. const harness = makeHarness();
  178. const { port, session } = await harness.openAsk();
  179. const first = [0, 1, 2].map((index) =>
  180. port.escalate(escalateRequest(`第一个 ask 的问题 ${index}`)),
  181. );
  182. await expect(port.escalate(escalateRequest("第 4 次"))).resolves.toMatchObject({
  183. reason: "budget_exhausted",
  184. });
  185. // 同一个会话上派下一个 ask(per-actor FIFO 的常态):计数归零,遗留停驻项一并撤下——
  186. // 新 ask 开跑之后,那些问题已经没有听众了,留在表里只会让快照说谎。
  187. harness.driver.startAsk(session, { siteId: "ask#2", ordinal: 1 }, {
  188. instructions: "next",
  189. typed: false,
  190. });
  191. await expect(Promise.allSettled(first)).resolves.toMatchObject([
  192. { status: "rejected" },
  193. { status: "rejected" },
  194. { status: "rejected" },
  195. ]);
  196. expect(harness.registry.pendingFor(harness.runId)).toEqual([]);
  197. // 新的 ask 上预算是满的:又能停驻 3 次。
  198. for (let index = 0; index < 3; index++) {
  199. void port.escalate(escalateRequest(`第二个 ask 的问题 ${index}`)).catch(() => {});
  200. }
  201. expect(harness.registry.pendingFor(harness.runId)).toHaveLength(3);
  202. await expect(port.escalate(escalateRequest("又是第 4 次"))).resolves.toMatchObject({
  203. reason: "budget_exhausted",
  204. });
  205. });
  206. });
  207. describe("workflow escalation — actor 名", () => {
  208. it("具名 actor 的名字端到端进入停驻记录与 raised 事件", async () => {
  209. const harness = makeHarness();
  210. const { port } = await harness.openAsk(1, { name: "poet", system: "你写诗。" });
  211. void port.escalate(escalateRequest("韵脚要不要押到底?")).catch(() => {});
  212. // 停驻记录(快照 pendingQuestions 的投影源)。
  213. const parked = harness.registry.pendingFor(harness.runId)[0];
  214. expect(parked).toMatchObject({ actor: "actor#1@1", actorName: "poet" });
  215. // 事件轨:结构 ref 与人类名**并存**——前者定位,后者供人读。
  216. expect(harness.events[0]).toMatchObject({
  217. type: "escalation-raised",
  218. actor: { siteId: "actor#1", ordinal: 1 },
  219. actorName: "poet",
  220. });
  221. // durable 轨同形。
  222. const stored = harness.journal.listEvents(harness.runId, {
  223. types: "all",
  224. reportItems: "all",
  225. })[0];
  226. expect(stored?.event).toMatchObject({ actorName: "poet" });
  227. });
  228. it("匿名 actor 整个字段缺席,不合成任何兜底标签", async () => {
  229. const harness = makeHarness();
  230. const { port } = await harness.openAsk(1, { system: "你没有名字。" });
  231. void port.escalate(escalateRequest("我是谁?")).catch(() => {});
  232. const parked = harness.registry.pendingFor(harness.runId)[0];
  233. expect(parked).not.toHaveProperty("actorName");
  234. expect(parked?.actor).toBe("actor#1@1");
  235. expect(harness.events[0]).not.toHaveProperty("actorName");
  236. });
  237. it("空串名视同匿名(与引擎的 createActor 判据逐字一致)", async () => {
  238. const harness = makeHarness();
  239. const { port } = await harness.openAsk(1, { name: "" });
  240. void port.escalate(escalateRequest("空名字算具名吗?")).catch(() => {});
  241. expect(harness.registry.pendingFor(harness.runId)[0]).not.toHaveProperty("actorName");
  242. });
  243. it("只有空白的名字**不**被 trim 成匿名:引擎认它具名、占缓存身份键,这里必须给同一个答案", async () => {
  244. const harness = makeHarness();
  245. const { port } = await harness.openAsk(1, { name: " " });
  246. void port.escalate(escalateRequest("我叫两个空格。")).catch(() => {});
  247. expect(harness.registry.pendingFor(harness.runId)[0]?.actorName).toBe(" ");
  248. });
  249. });
  250. describe("workflow escalation — 取消", () => {
  251. it("cancelAsk 一并拒绝停驻中的升级 deferred,之后作答得到 run_not_in_flight", async () => {
  252. const harness = makeHarness();
  253. const { port, instance } = await harness.openAsk();
  254. const pending = port.escalate(escalateRequest("要不要跳过这个检查?"));
  255. const qid = harness.registry.pendingFor(harness.runId)[0]?.qid;
  256. expect(qid).toBeDefined();
  257. harness.driver.cancelAsk(instance);
  258. // 与 submit deferred 完全同待遇:拒 Cancelled,handler 不再悬挂(这是 spec 里
  259. // 「无答案 = 无限期阻塞」的唯一逃生舱)。
  260. await expect(pending).rejects.toMatchObject({ code: "Cancelled" });
  261. expect(harness.registry.pendingFor(harness.runId)).toEqual([]);
  262. expect(harness.registry.resolve(qid!, "太晚了")).toMatchObject({
  263. ok: false,
  264. reason: "run_not_in_flight",
  265. });
  266. });
  267. it("cancelAsk 拒绝该会话上**全部**停驻项(一轮里并发升级过几次)", async () => {
  268. const harness = makeHarness();
  269. const { port, instance } = await harness.openAsk();
  270. const pendings = [0, 1, 2].map((index) => port.escalate(escalateRequest(`并发问题 ${index}`)));
  271. expect(harness.registry.pendingFor(harness.runId)).toHaveLength(3);
  272. harness.driver.cancelAsk(instance);
  273. const settled = await Promise.allSettled(pendings);
  274. expect(settled.map((one) => one.status)).toEqual(["rejected", "rejected", "rejected"]);
  275. expect(harness.registry.pendingFor(harness.runId)).toEqual([]);
  276. });
  277. });
  278. describe("workflow escalation — qid 唯一性", () => {
  279. it("两个并发 run 共用一张表时 qid 互不碰撞(片段相同则自动加长)", async () => {
  280. // 刻意让两个 runId 的前 8 个字符完全一样:短片段会撞,铸造必须自己走到下一个候选。
  281. const registry = createWorkflowEscalationRegistry();
  282. const left = makeHarness({ registry, runId: "dwfrun-abcdef01-aaaa" });
  283. const right = makeHarness({ registry, runId: "dwfrun-abcdef01-bbbb" });
  284. const leftAsk = await left.openAsk();
  285. const rightAsk = await right.openAsk();
  286. void leftAsk.port.escalate(escalateRequest("左边的问题")).catch(() => {});
  287. void rightAsk.port.escalate(escalateRequest("右边的问题")).catch(() => {});
  288. const leftQid = registry.pendingFor(left.runId)[0]?.qid;
  289. const rightQid = registry.pendingFor(right.runId)[0]?.qid;
  290. expect(leftQid).toBe("dwfq-abcdef01-1");
  291. // 短片段已被左边占用 ⇒ 退到完整 runId 片段,仍然人类可辨认。
  292. expect(rightQid).toBe("dwfq-abcdef01-bbbb-1");
  293. expect(leftQid).not.toBe(rightQid);
  294. });
  295. it("同一个 run 内 seq 单调递增", async () => {
  296. const harness = makeHarness({ runId: "dwfrun-99887766-0000" });
  297. const { port } = await harness.openAsk();
  298. for (let index = 0; index < 3; index++) {
  299. void port.escalate(escalateRequest(`问题 ${index}`)).catch(() => {});
  300. }
  301. expect(harness.registry.pendingFor(harness.runId).map((one) => one.qid)).toEqual([
  302. "dwfq-99887766-1",
  303. "dwfq-99887766-2",
  304. "dwfq-99887766-3",
  305. ]);
  306. });
  307. });
  308. describe("workflow escalation — 事件双轨", () => {
  309. it("raised / resolved 两类事件同时落 journal 与 emit 轨,且顺序一致", async () => {
  310. const harness = makeHarness();
  311. const { port } = await harness.openAsk();
  312. const pending = port.escalate(escalateRequest("这个门是不是坏了?", "上下文若干"));
  313. // 停驻记录要在结算**之前**读:结算会把它从表里摘掉,而下面要拿它的 askedAt 与事件比对。
  314. const parked = harness.registry.pendingFor(harness.runId)[0]!;
  315. const qid = parked.qid;
  316. harness.registry.resolve(qid, "坏了,按 95 通过。");
  317. await pending;
  318. // askedAt 取自停驻记录:driver 只读一次时钟,所以两条读面上的提问时刻必须逐位相等——
  319. // 这条断言就是「不许调两次 Date.now()」的守卫(各调一次会差几毫秒,下面的 toEqual 立刻红)。
  320. const raised = {
  321. type: "escalation-raised",
  322. qid,
  323. actor: { siteId: "actor#1", ordinal: 1 },
  324. question: "这个门是不是坏了?",
  325. context: "上下文若干",
  326. askedAt: parked.askedAt,
  327. };
  328. const resolved = { type: "escalation-resolved", qid, answer: "坏了,按 95 通过。" };
  329. // 实时轨(driver.emit → progress sink)。
  330. expect(harness.events).toEqual([raised, resolved]);
  331. // durable 轨(dwf_event)。升级**不写 dwf_node 行**:等待不是工作量。
  332. const stored = harness.journal.listEvents(harness.runId, { types: "all", reportItems: "all" });
  333. expect(stored.map((one) => one.event)).toEqual([raised, resolved]);
  334. expect(harness.journal.listNodes(harness.runId, { kinds: "all", withResult: true })).toEqual(
  335. [],
  336. );
  337. });
  338. it("载荷经端口的 2048 字符界裁剪(超长问题不会原样穿过协议边界)", async () => {
  339. const harness = makeHarness();
  340. const { port } = await harness.openAsk();
  341. const huge = "问".repeat(DYNAMIC_WORKFLOW_RUN_EVENT_PAYLOAD_LIMITS.maxStringLength + 500);
  342. void port.escalate(escalateRequest(huge)).catch(() => {});
  343. const stored = harness.journal.listEvents(harness.runId, { types: "all", reportItems: "all" });
  344. // journal 里是**原始事实**(未裁剪)——界是协议边界上的事,不是存储层的事。
  345. expect((stored[0]!.event as { question: string }).question).toHaveLength(huge.length);
  346. const projected = toProtocolEvent(stored[0]!.sequence, stored[0]!.event);
  347. expect(projected.type).toBe("escalation-raised");
  348. expect(projected.truncated).toBe(true);
  349. expect((projected.payload.question as string).length).toBe(
  350. DYNAMIC_WORKFLOW_RUN_EVENT_PAYLOAD_LIMITS.maxStringLength,
  351. );
  352. });
  353. });
  354. describe("workflow escalation — 注册表的结构化拒绝", () => {
  355. it("三类拒绝各自可分辨,且文案陈述现状", async () => {
  356. const harness = makeHarness();
  357. const { port, instance } = await harness.openAsk();
  358. // (1) 从未存在的 id。
  359. const unknown = harness.registry.resolve("dwfq-nonesuch-9", "答案");
  360. expect(unknown).toMatchObject({ ok: false, reason: "unknown_question" });
  361. expect(unknown.ok === false && unknown.message).toContain("pendingQuestions");
  362. // (2) 已被回答。
  363. const answered = port.escalate(escalateRequest("第一个问题"));
  364. const firstQid = harness.registry.pendingFor(harness.runId)[0]!.qid;
  365. harness.registry.resolve(firstQid, "答案一");
  366. await answered;
  367. const again = harness.registry.resolve(firstQid, "答案二");
  368. expect(again).toMatchObject({ ok: false, reason: "already_resolved" });
  369. // (3) 随 ask 一起被撤下。
  370. const withdrawn = port.escalate(escalateRequest("第二个问题"));
  371. const secondQid = harness.registry.pendingFor(harness.runId)[0]!.qid;
  372. harness.driver.cancelAsk(instance);
  373. await expect(withdrawn).rejects.toMatchObject({ code: "Cancelled" });
  374. expect(harness.registry.resolve(secondQid, "答案三")).toMatchObject({
  375. ok: false,
  376. reason: "run_not_in_flight",
  377. });
  378. });
  379. it("撤下不覆盖「已回答」:resolved 的 qid 之后仍报 already_resolved", async () => {
  380. const harness = makeHarness();
  381. const { port, instance } = await harness.openAsk();
  382. const answered = port.escalate(escalateRequest("问题"));
  383. const qid = harness.registry.pendingFor(harness.runId)[0]!.qid;
  384. harness.registry.resolve(qid, "答案");
  385. await answered;
  386. // ask 随后被取消:已退场的 qid 不该被降级成「没人在等」——那会把「答案已送达」
  387. // 改写成另一个事实。
  388. harness.driver.cancelAsk(instance);
  389. expect(harness.registry.resolve(qid, "再来一次")).toMatchObject({
  390. ok: false,
  391. reason: "already_resolved",
  392. });
  393. });
  394. it("pendingFor 按 run 隔离:一张表上的两个 run 各看各的", async () => {
  395. const registry = createWorkflowEscalationRegistry();
  396. const left = makeHarness({ registry, runId: "dwfrun-aaaa0000-1111" });
  397. const right = makeHarness({ registry, runId: "dwfrun-bbbb0000-2222" });
  398. const leftAsk = await left.openAsk();
  399. const rightAsk = await right.openAsk();
  400. void leftAsk.port.escalate(escalateRequest("左")).catch(() => {});
  401. void rightAsk.port.escalate(escalateRequest("右")).catch(() => {});
  402. expect(registry.pendingFor(left.runId).map((one) => one.question)).toEqual(["左"]);
  403. expect(registry.pendingFor(right.runId).map((one) => one.question)).toEqual(["右"]);
  404. });
  405. });
  406. // ————————————————————————————————————————————————
  407. // actor 会话的工具面边界(Slice 2)。
  408. //
  409. // 升级问答有一条**身份**不变式:actor 提问,主代理作答。让另一个 actor 顺手回答,等于把
  410. // 「把判断权交回给创建这条工作流的那一方」悄悄退化成 actor 之间的互相说服——而那恰恰是
  411. // 本特性存在的理由(一个被挡住的 actor 需要的是能改掉那道门的人,不是另一个同样被挡住的人)。
  412. // 所以 `ResolveWorkflowQuestion` 进 actor 的禁用名单,`escalate` 绝不进。
  413. // ————————————————————————————————————————————————
  414. describe("workflow escalation — actor 会话的工具面", () => {
  415. it("actor 的工具面减掉 ResolveWorkflowQuestion,但不减 escalate", () => {
  416. const policy = workflowActorToolPolicy();
  417. expect(policy.toolDisallowlist).toContain(RESOLVE_WORKFLOW_QUESTION_TOOL_NAME);
  418. expect(policy.toolDisallowlist).not.toContain(ESCALATE_TOOL_NAME);
  419. });
  420. });