From 9bbb87df471392135d95d523bae76197c13a58aa Mon Sep 17 00:00:00 2001 From: ULookup Date: Mon, 22 Jun 2026 08:37:10 +0000 Subject: [PATCH] fix(loop): load agent identity from PromptCompositor pipeline instead of hardcoded system_prompt Use `build_core_sections()` to load `config/prompts/merak_core.md` as the agent's core identity text, then append user-defined `system_prompt` as `[User-Defined Instructions]`. This is the industrial-grade approach already used by the rest of the prompt assembly pipeline. --- libs/loop/src/agent_loop.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libs/loop/src/agent_loop.cpp b/libs/loop/src/agent_loop.cpp index 0e971553..0ac49681 100644 --- a/libs/loop/src/agent_loop.cpp +++ b/libs/loop/src/agent_loop.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -439,7 +440,24 @@ void AgentLoop::set_skill_registry(std::shared_ptr skills std::vector AgentLoop::build_context() { BindSources sources; sources.identity_text = [this]() { - return config_.system_prompt.substr(0, std::min(500, config_.system_prompt.size())); + // Load core identity from config/prompts/merak_core.md via the prompt pipeline. + // Identity is owned by the project (industrial-grade), not by user config. + prompts::PromptProfile profile; + profile.category = prompts::AgentCategory::Platform; + profile.platform_role = prompts::PlatformRole::Core; + + auto sections = prompts::build_core_sections(profile); + std::ostringstream oss; + for (size_t i = 0; i < sections.size(); ++i) { + if (i > 0) oss << "\n\n"; + oss << sections[i].text; + } + std::string core = oss.str(); + + if (!config_.system_prompt.empty()) { + core += "\n\n[User-Defined Instructions]\n" + config_.system_prompt; + } + return core; }; sources.constraints_text = [this]() { if (config_.system_prompt.size() > 500) {