
























@@ -555,6 +555,14 @@ async function buildDynamicToolsForTest(
555555});
556556}
557557558+function filterAllowedRuntimeToolNamesForTest(
559+params: EmbeddedRunAttemptParams,
560+tools: RuntimeDynamicToolForTest[],
561+) {
562+const toolsAllow = testing.includeForcedCodexDynamicToolAllow(params.toolsAllow, params);
563+return testing.filterCodexDynamicToolsForAllowlist(tools, toolsAllow).map((tool) => tool.name);
564+}
565+558566type RuntimeDynamicToolForTest = Parameters<
559567typeof createCodexDynamicToolBridge
560568>[0]["tools"][number];
@@ -2260,73 +2268,53 @@ describe("runCodexAppServerAttempt", () => {
22602268expect(result.assistantTexts).toEqual(["Nested done."]);
22612269});
226222702263-it("keeps forced message dynamic tool when toolsAllow omits it", async () => {
2264-testing.setOpenClawCodingToolsFactoryForTests(() => [
2265-createRuntimeDynamicTool("message"),
2266-createRuntimeDynamicTool("music_generate"),
2267-]);
2271+it("keeps forced message dynamic tool when toolsAllow omits it", () => {
22682272const workspaceDir = path.join(tempDir, "workspace");
22692273const params = createParams(path.join(tempDir, "session.jsonl"), workspaceDir);
22702274params.disableTools = false;
22712275params.runtimePlan = createCodexRuntimePlanFixture();
22722276params.sourceReplyDeliveryMode = "message_tool_only";
22732277params.toolsAllow = ["music_generate"];
227422782275-const dynamicToolNames = (
2276-await buildDynamicToolsForTest(params, workspaceDir, {
2277-forceHeartbeatTool: true,
2278-ignoreRuntimePlan: true,
2279-})
2280-).map((tool) => tool.name);
2279+const dynamicToolNames = filterAllowedRuntimeToolNamesForTest(params, [
2280+createRuntimeDynamicTool("message"),
2281+createRuntimeDynamicTool("music_generate"),
2282+]);
2281228322822284expect(dynamicToolNames).toContain("message");
22832285expect(dynamicToolNames).toContain("music_generate");
22842286});
228522872286-it("keeps forced message dynamic tool when toolsAllow is empty", async () => {
2287-testing.setOpenClawCodingToolsFactoryForTests((options) => [
2288+it("keeps forced message dynamic tool when toolsAllow is empty", () => {
2289+const tools = [
22882290createRuntimeDynamicTool("message"),
22892291createRuntimeDynamicTool("music_generate"),
2290- ...(options?.forceHeartbeatTool === true
2291- ? [createRuntimeDynamicTool("heartbeat_respond")]
2292- : []),
2293-]);
2292+createRuntimeDynamicTool("heartbeat_respond"),
2293+];
22942294const workspaceDir = path.join(tempDir, "workspace");
22952295const params = createParams(path.join(tempDir, "session.jsonl"), workspaceDir);
22962296params.disableTools = false;
22972297params.runtimePlan = createCodexRuntimePlanFixture();
22982298params.sourceReplyDeliveryMode = "message_tool_only";
22992299params.toolsAllow = [];
230023002301-const dynamicToolNames = (
2302-await buildDynamicToolsForTest(params, workspaceDir, {
2303-forceHeartbeatTool: true,
2304-ignoreRuntimePlan: true,
2305-})
2306-).map((tool) => tool.name);
2301+const dynamicToolNames = filterAllowedRuntimeToolNamesForTest(params, tools);
2307230223082303expect(dynamicToolNames).toEqual(["message"]);
23092304});
231023052311-it("keeps forced heartbeat registration inside narrow toolsAllow policy", async () => {
2312-testing.setOpenClawCodingToolsFactoryForTests((options) => [
2306+it("keeps forced heartbeat registration inside narrow toolsAllow policy", () => {
2307+const tools = [
23132308createRuntimeDynamicTool("message"),
2314- ...(options?.forceHeartbeatTool === true
2315- ? [createRuntimeDynamicTool("heartbeat_respond")]
2316- : []),
2317-]);
2309+createRuntimeDynamicTool("heartbeat_respond"),
2310+];
23182311const workspaceDir = path.join(tempDir, "workspace");
23192312const params = createParams(path.join(tempDir, "session.jsonl"), workspaceDir);
23202313params.disableTools = false;
23212314params.runtimePlan = createCodexRuntimePlanFixture();
23222315params.toolsAllow = ["message"];
232323162324-const dynamicToolNames = (
2325-await buildDynamicToolsForTest(params, workspaceDir, {
2326-forceHeartbeatTool: true,
2327-ignoreRuntimePlan: true,
2328-})
2329-).map((tool) => tool.name);
2317+const dynamicToolNames = filterAllowedRuntimeToolNamesForTest(params, tools);
2330231823312319expect(dynamicToolNames).toEqual(["message"]);
23322320});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。