night-shift: prompt-asset extraction (inline prompts -> versioned files + loader) - #5
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 sourceinto versioned plain-text assets under a new
src/personal_llm/prompts/package:rag_system.txt,agent_system.txt,review_system.txt. Addsprompts/loader.pyexposing
load_prompt(name) -> str, which the three call sites now use instead ofholding their own inline copy.
agent_system.txtkeeps its{tools}format placeholderand doubled
{{/}}JSON-example braces exactly as before -.format(tools=...)isstill applied by the caller, after loading, unchanged.
Also:
pyproject.tomlgained a[tool.setuptools.package-data]entry forpersonal_llm.prompts(*.txt) - without it, a real wheel build would silently dropthe prompt files, since setuptools does not bundle non-
.pyfiles by default. Theloader itself still reads via
Path(__file__).parent(notimportlib.resources) sincethat works identically in the source tree, an editable install, and a built wheel.
eval/harness.py's docstring, which referenced the old_SYSTEM/_SYSTEM_TEMPLATEconstant names, updated to match.
graph/kg.pyhas its own separate inline_SYSTEMconstant; left untouched, out ofscope 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
tests/test_prompts.py: each loaded prompt comparedbyte-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
FileNotFoundErrorrather than returning empty; the{tools}placeholder round-tripsthrough
.format()with the doubled JSON-example braces surviving as literal singlebraces, not double-substituted.
agent_system.txt's doubled braces during development andconfirmed the round-trip test failed loudly (
KeyErrorfrom.format()) beforerestoring it - the test genuinely catches drift, not just agreeing with itself.
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 systemprompt text sent to the (mocked) router is identical to before this change.