diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index 7b2d9718832..15262ddb1c0 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -301,6 +301,23 @@ describe("buildAgentSystemPrompt", () => { expect(prompt).toContain("Bravo"); }); + it("ignores context files with missing or blank paths", () => { + const prompt = buildAgentSystemPrompt({ + workspaceDir: "/tmp/openclaw", + contextFiles: [ + { path: undefined as unknown as string, content: "Missing path" }, + { path: " ", content: "Blank path" }, + { path: "AGENTS.md", content: "Alpha" }, + ], + }); + + expect(prompt).toContain("# Project Context"); + expect(prompt).toContain("## AGENTS.md"); + expect(prompt).toContain("Alpha"); + expect(prompt).not.toContain("Missing path"); + expect(prompt).not.toContain("Blank path"); + }); + it("adds SOUL guidance when a soul file is present", () => { const prompt = buildAgentSystemPrompt({ workspaceDir: "/tmp/openclaw",