From 1437f371fc4ab3de030069d6c08e2c88a5fb27b7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 17:33:55 +0000 Subject: [PATCH] test: trim duplicate embedded runner setup cases --- src/agents/pi-embedded-runner.test.ts | 113 -------------------------- 1 file changed, 113 deletions(-) diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index 7cabf2419b2..d7aada2919c 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -243,119 +243,6 @@ const runDefaultEmbeddedTurn = async (sessionFile: string, prompt: string) => { }; describe("runEmbeddedPiAgent", () => { - it("writes models.json into the provided agentDir", async () => { - const sessionFile = nextSessionFile(); - - const cfg = { - models: { - providers: { - minimax: { - baseUrl: "https://api.minimax.io/anthropic", - api: "anthropic-messages", - apiKey: "sk-minimax-test", - models: [ - { - id: "MiniMax-M2.1", - name: "MiniMax M2.1", - reasoning: false, - input: ["text"], - cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, - contextWindow: 200000, - maxTokens: 8192, - }, - ], - }, - }, - }, - } satisfies OpenClawConfig; - - await expect( - runEmbeddedPiAgent({ - sessionId: "session:test", - sessionKey: testSessionKey, - sessionFile, - workspaceDir, - config: cfg, - prompt: "hi", - provider: "definitely-not-a-provider", - model: "definitely-not-a-model", - timeoutMs: 1, - agentDir, - runId: nextRunId("unknown-model"), - enqueue: immediateEnqueue, - }), - ).rejects.toThrow(/Unknown model:/); - - await expect(fs.stat(path.join(agentDir, "models.json"))).resolves.toBeTruthy(); - }); - - it("falls back to per-agent workspace when runtime workspaceDir is missing", async () => { - const sessionFile = nextSessionFile(); - const fallbackWorkspace = path.join(tempRoot ?? os.tmpdir(), "workspace-fallback-main"); - const cfg = { - ...makeOpenAiConfig(["mock-1"]), - agents: { - defaults: { - workspace: fallbackWorkspace, - }, - }, - } satisfies OpenClawConfig; - - const result = await runEmbeddedPiAgent({ - sessionId: "session:test-fallback", - sessionKey: "agent:main:subagent:fallback-workspace", - sessionFile, - workspaceDir: undefined as unknown as string, - config: cfg, - prompt: "hello", - provider: "openai", - model: "mock-1", - timeoutMs: 5_000, - agentDir, - runId: "run-fallback-workspace", - enqueue: immediateEnqueue, - }); - - expect(result.payloads?.[0]?.text).toBe("ok"); - await expect(fs.stat(fallbackWorkspace)).resolves.toBeTruthy(); - }); - - it("throws when sessionKey is malformed", async () => { - const sessionFile = nextSessionFile(); - const cfg = { - ...makeOpenAiConfig(["mock-1"]), - agents: { - defaults: { - workspace: path.join(tempRoot ?? os.tmpdir(), "workspace-fallback-main"), - }, - list: [ - { - id: "research", - workspace: path.join(tempRoot ?? os.tmpdir(), "workspace-fallback-research"), - }, - ], - }, - } satisfies OpenClawConfig; - - await expect( - runEmbeddedPiAgent({ - sessionId: "session:test-fallback-malformed", - sessionKey: "agent::broken", - agentId: "research", - sessionFile, - workspaceDir: undefined as unknown as string, - config: cfg, - prompt: "hello", - provider: "openai", - model: "mock-1", - timeoutMs: 5_000, - agentDir, - runId: "run-fallback-workspace-malformed", - enqueue: immediateEnqueue, - }), - ).rejects.toThrow("Malformed agent session key"); - }); - it("persists the user message when prompt fails before assistant output", async () => { const sessionFile = nextSessionFile(); const cfg = makeOpenAiConfig(["mock-error"]);