Skip to content

night-shift: prompt-asset extraction (inline prompts -> versioned files + loader) - #5

Merged
syzayd merged 1 commit into
masterfrom
night-shift/2026-07-21
Jul 25, 2026
Merged

night-shift: prompt-asset extraction (inline prompts -> versioned files + loader)#5
syzayd merged 1 commit into
masterfrom
night-shift/2026-07-21

Conversation

@syzayd

@syzayd syzayd commented Jul 21, 2026

Copy link
Copy Markdown
Owner

What

Extracts the three inline system-prompt string constants (rag/pipeline.py's _SYSTEM,
agent/loop.py's _SYSTEM_TEMPLATE, review/weekly.py's _SYSTEM) out of Python source
into versioned plain-text assets under a new src/personal_llm/prompts/ package:
rag_system.txt, agent_system.txt, review_system.txt. Adds prompts/loader.py
exposing load_prompt(name) -> str, which the three call sites now use instead of
holding their own inline copy. agent_system.txt keeps its {tools} format placeholder
and doubled {{/}} JSON-example braces exactly as before - .format(tools=...) is
still applied by the caller, after loading, unchanged.

Also:

  • pyproject.toml gained a [tool.setuptools.package-data] entry for
    personal_llm.prompts (*.txt) - without it, a real wheel build would silently drop
    the prompt files, since setuptools does not bundle non-.py files by default. The
    loader itself still reads via Path(__file__).parent (not importlib.resources) since
    that works identically in the source tree, an editable install, and a built wheel.
  • eval/harness.py's docstring, which referenced the old _SYSTEM/_SYSTEM_TEMPLATE
    constant names, updated to match.
  • README test-count badge/section: 118 -> 124.

graph/kg.py has its own separate inline _SYSTEM constant; left untouched, out of
scope for this task (only the three prompts named in the queue item were moved).

Why

PROJECT-GENESIS.md section 9, Tier 5, item #36 (aliased with Tier 9 item #78):
"personal-llm: prompt-asset extraction (inline prompts -> versioned files + tests)".
Verify clause: "tests confirm each prompt loads and round-trips."

How verified

  • 6 new offline tests in tests/test_prompts.py: each loaded prompt compared
    byte-for-byte against a literal copy of the original inline string (not re-derived from
    the .txt file, so an accidental future edit is actually caught); unknown-name raises
    FileNotFoundError rather than returning empty; the {tools} placeholder round-trips
    through .format() with the doubled JSON-example braces surviving as literal single
    braces, not double-substituted.
  • Deliberately corrupted agent_system.txt's doubled braces during development and
    confirmed the round-trip test failed loudly (KeyError from .format()) before
    restoring it - the test genuinely catches drift, not just agreeing with itself.
  • Full suite: 124/124 passed (venv/bin/python -m pytest tests/ -q), 118 pre-existing +
    6 new, nothing weakened. The three existing call-site test files
    (test_rag.py/test_agent.py/test_review.py) pass unchanged, confirming the system
    prompt text sent to the (mocked) router is identical to before this change.

…es + loader)

PROJECT-GENESIS.md section 9 Tier 5 item #36 (alias Tier 9 item #78). Moves the
three inline system-prompt constants (rag/pipeline.py, agent/loop.py,
review/weekly.py) into src/personal_llm/prompts/*.txt loaded via a new
load_prompt() helper, byte-for-byte preserved including the agent template's
{tools} placeholder and doubled JSON-example braces; tests/test_prompts.py
covers exact round-trip text, unknown-name errors, and .format() substitution.
Full suite verified green: 124 passed (118 existing + 6 new), same count the
run before this change reports as its baseline.
@syzayd
syzayd merged commit 1b95167 into master Jul 25, 2026
1 check passed
@syzayd
syzayd deleted the night-shift/2026-07-21 branch July 25, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants