mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-28 05:12:26 +00:00
`SystemPromptBuilder` is fully implemented and tested in `openjarvis.prompt.builder`, and `BaseAgent.__init__` accepts a `prompt_builder` kwarg. But no production code path ever instantiates the builder, so the persona-files feature documented in `MemoryFilesConfig` (SOUL.md / MEMORY.md / USER.md) had no effect. Users could write a fully-customized `~/.openjarvis/SOUL.md` and the file was never read. This PR wires it up in `_run_agent` (called by `jarvis ask --agent <name>` and the new fallback from #294): ```python if "prompt_builder" in inspect.signature(agent_cls.__init__).parameters: agent_kwargs["prompt_builder"] = SystemPromptBuilder( agent_template=config.agent.default_system_prompt or "", memory_files_config=config.memory_files, system_prompt_config=config.system_prompt, ) ``` The `inspect` guard means agents that override `__init__` without forwarding `prompt_builder` (e.g. OrchestratorAgent, which has its own tool-aware system prompt) opt out automatically and keep working unchanged. SimpleAgent and any future agent that inherits `BaseAgent.__init__` directly picks up the persona files. Also fixes a latent bug in `SystemPromptBuilder._load_file`: it called `path.read_text()` with no encoding, which on Windows falls back to the system code page (cp950 / cp932 / cp949) and raises `UnicodeDecodeError` on any non-ASCII persona content. Pin to UTF-8. ## Tests - Add `test_soul_md_content_reaches_engine_in_simple_agent` — writes sentinel SOUL.md / MEMORY.md / USER.md to tmp_path, runs the command, and asserts each sentinel appears in the SYSTEM message passed to engine.generate. - Add `test_orchestrator_keeps_its_own_system_prompt` — exercises the `inspect`-based opt-out so OrchestratorAgent doesn't crash on the unexpected kwarg. Run: `pytest tests/cli/test_ask_agent.py tests/cli/test_ask_router.py tests/cli/test_ask_e2e.py tests/agents/ tests/prompt/` The 6 remaining failures (test_base_agent, test_loop_guard, test_manager, test_native_openhands) are pre-existing on origin/main and unrelated to this change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>