01
Persona as engineered files, not a string
I split the system prompt into versioned XML — identity, knowledge, task, constraints, methodology, response_schema — loaded by a prompt loader, so the agricultural persona and its output contract are maintainable and testable rather than a wall of text. Every answer is forced through the same five sections, with a verification loop that checks soil-health and IPM thresholds before finalizing.
// src/prompts/promptLoader.ts — persona assembled from versioned files
const SYSTEM = [
"identity", "knowledge", "task",
"constraints", "methodology", "response_schema",
].map(load).join("\n\n");
// response_schema enforces: diagnosis -> yield_gap_analysis ->
// integrated_strategy (IPM) -> economic_impact -> risk_mitigation