Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

1.9 KB
Raw Blame
"""The custom system prompt must actually reach the brain's system prompt.

Companion to test_custom_system_prompt.py (which locks the persona-loader). This
proves the wiring: ``BrainManager._build_system_prompt`` emits the user's custom
persona when one is set, and the packaged default otherwise — so editing the
Markdown in Settings genuinely changes how the assistant behaves.
"""
from __future__ import annotations

import pytest

import dodaios.core.config as core_config
from dodaios.brain import persona_loader
from dodaios.brain.manager import BrainManager
from dodaios.core.config import load_config


def _manager() -> BrainManager:
    """A BrainManager with __init__ bypassed — only the attrs the prompt needs."""
    m = BrainManager.__new__(BrainManager)
    m._soul = None
    m._user_profile = None
    m._people = None
    m._core_memory = None
    m._system_prompt_extra = "ROUTER DISCIPLINE BLOCK"
    m._wiki_context_suffix = ""
    m._reply_language = "auto"
    cfg = load_config()
    cfg.performance.cache_optimized_prompt = False
    m._config = cfg
    return m


@pytest.fixture(autouse=True)
def _isolate_data_dir(tmp_path, monkeypatch: pytest.MonkeyPatch):
    monkeypatch.setattr(core_config, "DATA_DIR", tmp_path)
    return tmp_path


def test_default_persona_block_present_without_custom() -> None:
    prompt = _manager()._build_system_prompt()
    # A signature phrase from the packaged DODAIOS_PERSONA.md persona block
    # (persona was reworked; "voice companion" opens the new first sentence).
    assert "voice companion" in prompt


def test_custom_prompt_replaces_default_persona_block() -> None:
    persona_loader.save_custom_prompt(
        "You are ZORG. Speak only in haiku. Marker: XYZZY-CUSTOM."
    )
    prompt = _manager()._build_system_prompt()
    assert "XYZZY-CUSTOM" in prompt
    # The packaged persona block is no longer injected once a custom one is set.
    assert "voice-based meta-orchestrator" not in prompt