From 2b38e5b8920c530a63ea860e99e2d36ce8267c0e Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Thu, 12 Feb 2026 15:09:43 -0500 Subject: [PATCH] fix: add context-file path regression test (openclaw#14903) thanks @0xRaini --- src/agents/system-prompt.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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",