diff --git a/pkg/agent/core.go b/pkg/agent/core.go index b8513fa..e7a1c53 100644 --- a/pkg/agent/core.go +++ b/pkg/agent/core.go @@ -79,7 +79,12 @@ func BuildAgentEnv(cfg *config.Config, d tools.Dispatcher, cwd string) AgentEnv } } - base := loadSystemPrompt(cwd) + path := DefaultPromptsDir() + "/SYSTEM_PROMPT.md" + data, err := os.ReadFile(path) + if err != nil { + panic(fmt.Sprintf("loadSystemPrompt: %s: %v", path, err)) + } + base := expandSystemPrompt(string(data), cwd) sp := base if agentPrompt != "" { if sp != "" { @@ -123,17 +128,6 @@ func DefaultPromptsDir() string { return paths.CfgDir() + "/prompts" } -// loadSystemPrompt reads SYSTEM_PROMPT.md from DefaultPromptsDir and expands -// environment variables, including computed PRIME_* values. -func loadSystemPrompt(cwd string) string { - path := DefaultPromptsDir() + "/SYSTEM_PROMPT.md" - data, err := os.ReadFile(path) - if err != nil { - panic(fmt.Sprintf("loadSystemPrompt: %s: %v", path, err)) - } - return expandSystemPrompt(string(data), cwd) -} - func expandSystemPrompt(content, cwd string) string { if cwd == "" { cwd, _ = os.Getwd() diff --git a/pkg/agent/core_test.go b/pkg/agent/core_test.go index c94ca88..cdb81e0 100644 --- a/pkg/agent/core_test.go +++ b/pkg/agent/core_test.go @@ -526,17 +526,17 @@ func TestAgentSpawnFiresOnce(t *testing.T) { } } -// --- loadSystemPrompt --- +// --- BuildAgentEnv: missing system prompt --- -func TestLoadSystemPrompt_MissingFile(t *testing.T) { +func TestBuildAgentEnv_MissingSystemPrompt(t *testing.T) { t.Setenv("OLLIE_CFG_PATH", t.TempDir()) // no SYSTEM_PROMPT.md written defer func() { if recover() == nil { - t.Error("expected panic from loadSystemPrompt; got none") + t.Error("expected panic from BuildAgentEnv; got none") } }() - loadSystemPrompt("") + BuildAgentEnv(nil, tools.NewDispatcher(), "") } // --- panic recovery ---