Two prompts compared: an exam comparing two versions of a bot's system prompt, which must make the prompt the one thing its two configurations differ in and catch the version that answers wrong
diff --git a/exams/allotment-bot/axes.json b/exams/allotment-bot/axes.json
new file mode 100644
index 0000000..7a48b30
--- /dev/null
+++ b/exams/allotment-bot/axes.json
@@ -0,0 +1,16 @@
+{
+ "system_prompt": {
+ "description": "System prompt version for the bot",
+ "values": {
+ "baseline": {
+ "description": "Current live system prompt",
+ "system_prompt_file": "../bot/system.md"
+ },
+ "candidate": {
+ "description": "Draft rewrite system prompt",
+ "system_prompt_file": "../bot/system-draft.md"
+ }
+ },
+ "live": "baseline"
+ }
+}
diff --git a/exams/allotment-bot/configurations.json b/exams/allotment-bot/configurations.json
new file mode 100644
index 0000000..e975924
--- /dev/null
+++ b/exams/allotment-bot/configurations.json
@@ -0,0 +1,10 @@
+{
+ "baseline": {
+ "description": "Current live system prompt",
+ "system_prompt": "baseline"
+ },
+ "candidate": {
+ "description": "Draft rewrite system prompt",
+ "system_prompt": "candidate"
+ }
+}
diff --git a/exams/allotment-bot/exam.json b/exams/allotment-bot/exam.json
new file mode 100644
index 0000000..f8546aa
--- /dev/null
+++ b/exams/allotment-bot/exam.json
@@ -0,0 +1,8 @@
+{
+ "description": "Compare current vs draft system prompts for Millbeck Allotment Society bot",
+ "axes": "axes.json",
+ "configurations": "configurations.json",
+ "stages": "stages.json",
+ "inputs": "inputs.json",
+ "checks": "checks.json"
+}
diff --git a/exams/allotment-bot/inputs.json b/exams/allotment-bot/inputs.json
new file mode 100644
index 0000000..8b53141
--- /dev/null
+++ b/exams/allotment-bot/inputs.json
@@ -0,0 +1,24 @@
+{
+ "questions": [
+ {
+ "name": "rent_half_plot",
+ "question": "How much is the rent on a half plot?"
+ },
+ {
+ "name": "waiting_list",
+ "question": "How long is the waiting list at the moment?"
+ },
+ {
+ "name": "bonfire",
+ "question": "When am I allowed to have a bonfire?"
+ },
+ {
+ "name": "lost_key",
+ "question": "I've lost my gate key. How much is a new one?"
+ },
+ {
+ "name": "shed_size",
+ "question": "What's the biggest shed I can put up?"
+ }
+ ]
+}
diff --git a/exams/allotment-bot/stages.json b/exams/allotment-bot/stages.json
new file mode 100644
index 0000000..62336c9
--- /dev/null
+++ b/exams/allotment-bot/stages.json
@@ -0,0 +1,32 @@
+{
+ "bot_response": {
+ "description": "Get bot response to a user question",
+ "steps": [
+ {
+ "name": "prepare_prompt",
+ "description": "Combine system prompt with knowledge base",
+ "action": "combine_prompts",
+ "system_prompt": {
+ "from": "system_prompt",
+ "field": "system_prompt_file"
+ },
+ "append": "../bot/knowledge.md"
+ },
+ {
+ "name": "call_api",
+ "description": "Send request to llama-server",
+ "action": "http_post",
+ "url": "http://localhost:8080/v1/chat/completions",
+ "body": {
+ "model": "qwen3-coder-next",
+ "messages": [
+ {"role": "system", "content": {"from": "prepare_prompt", "field": "combined"}},
+ {"role": "user", "content": {"from": "input", "field": "question"}}
+ ],
+ "temperature": 0.7
+ },
+ "response_field": "choices[0].message.content"
+ }
+ ]
+ }
+}
diff --git a/test-bot-comparison.sh b/test-bot-comparison.sh
new file mode 100755
index 0000000..e6afdf4
--- /dev/null
+++ b/test-bot-comparison.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+# Compare current vs draft bot system prompts against known questions
+# Usage: ./test-bot-comparison.sh
+
+API_URL="http://localhost:8080/v1/chat/completions"
+MODEL="qwen3-coder-next"
+OUTPUT_DIR="test-results"
+
+mkdir -p "$OUTPUT_DIR"
+
+echo "=============================================="
+echo "Bot Prompt Comparison Test"
+echo "=============================================="
+echo ""
+
+# Read prompts
+BASELINE=$(cat bot/system.md)
+CANDIDATE=$(cat bot/system-draft.md)
+KNOWLEDGE=$(cat bot/knowledge.md)
+
+QUESTIONS=(
+ "How much is the rent on a half plot?"
+ "How long is the waiting list at the moment?"
+ "When am I allowed to have a bonfire?"
+ "I've lost my gate key. How much is a new one?"
+ "What's the biggest shed I can put up?"
+)
+
+RESULTS_FILE="$OUTPUT_DIR/comparison_$(date +%Y%m%d_%H%M%S).md"
+
+echo "# Bot Prompt Comparison" > "$RESULTS_FILE"
+echo "" >> "$RESULTS_FILE"
+echo "Generated: $(date)" >> "$RESULTS_FILE"
+echo "" >> "$RESULTS_FILE"
+
+for question in "${QUESTIONS[@]}"; do
+ echo "Q: $question"
+
+ # Build full prompt
+ FULL_BASELINE="$BASELINE
+---
+$KNOWLEDGE"
+
+ FULL_CANDIDATE="$CANDIDATE
+---
+$KNOWLEDGE"
+
+ # Get responses (escape quotes for JSON)
+ RESP_BASELINE=$(curl -s -X POST "$API_URL" \
+ -H "Content-Type: application/json" \
+ -d "{\"model\": \"$MODEL\", \"messages\": [{\"role\": \"system\", \"content\": \"$FULL_BASELINE\"}, {\"role\": \"user\", \"content\": \"$question\"}], \"temperature\": 0.7}" 2>/dev/null | jq -r '.choices[0].message.content // "API_ERROR"' || echo "API_ERROR")
+
+ RESP_CANDIDATE=$(curl -s -X POST "$API_URL" \
+ -H "Content-Type: application/json" \
+ -d "{\"model\": \"$MODEL\", \"messages\": [{\"role\": \"system\", \"content\": \"$FULL_CANDIDATE\"}, {\"role\": \"user\", \"content\": \"$question\"}], \"temperature\": 0.7}" 2>/dev/null | jq -r '.choices[0].message.content // "API_ERROR"' || echo "API_ERROR")
+
+ echo ""
+ echo "BASELINE:"
+ echo "$RESP_BASELINE"
+ echo ""
+ echo "CANDIDATE:"
+ echo "$RESP_CANDIDATE"
+ echo ""
+ echo "---"
+ echo ""
+
+ # Save to results file
+ echo "## Question: $question" >> "$RESULTS_FILE"
+ echo "" >> "$RESULTS_FILE"
+ echo "### Baseline" >> "$RESULTS_FILE"
+ echo '```' >> "$RESULTS_FILE"
+ echo "$RESP_BASELINE" >> "$RESULTS_FILE"
+ echo '```' >> "$RESULTS_FILE"
+ echo "" >> "$RESULTS_FILE"
+ echo "### Candidate" >> "$RESULTS_FILE"
+ echo '```' >> "$RESULTS_FILE"
+ echo "$RESP_CANDIDATE" >> "$RESULTS_FILE"
+ echo '```' >> "$RESULTS_FILE"
+ echo "" >> "$RESULTS_FILE"
+ echo "---" >> "$RESULTS_FILE"
+ echo "" >> "$RESULTS_FILE"
+done
+
+echo "Results saved to: $RESULTS_FILE"
diff --git a/test-bot.sh b/test-bot.sh
new file mode 100755
index 0000000..6564a6e
--- /dev/null
+++ b/test-bot.sh
@@ -0,0 +1,147 @@
+#!/bin/bash
+# Test script to compare bot system prompts against known questions
+# Usage: ./test-bot.sh [system-prompt-file]
+# ./test-bot.sh bot/system.md # current prompt
+# ./test-bot.sh bot/system-draft.md # draft prompt
+# ./test-bot.sh all # test both and compare
+
+API_URL="http://localhost:8080/v1/chat/completions"
+MODEL="qwen3-coder-next"
+KNOWLEDGE_FILE="bot/knowledge.md"
+QUESTIONS_FILE="docs/questions-log.md"
+
+# Read file content
+read_file() {
+ if [[ -f "$1" ]]; then
+ cat "$1"
+ else
+ echo "ERROR: File not found: $1" >&2
+ exit 1
+ fi
+}
+
+# Get bot response for a question
+get_response() {
+ local system_prompt="$1"
+ local question="$2"
+
+ # Combine system prompt with knowledge base
+ local full_prompt="${system_prompt}
+
+---
+
+${KNOWLEDGE_CONTENT}"
+
+ # Call the API
+ curl -s -X POST "$API_URL" \
+ -H "Content-Type: application/json" \
+ -d "{
+ \"model\": \"${MODEL}\",
+ \"messages\": [
+ {\"role\": \"system\", \"content\": \"${full_prompt}\"},
+ {\"role\": \"user\", \"content\": \"${question}\"}
+ ],
+ \"temperature\": 0.7
+ }" | jq -r '.choices[0].message.content' 2>/dev/null || echo "API_ERROR"
+}
+
+# Check if response contains expected text
+check_response() {
+ local response="$1"
+ local expected="$2"
+
+ if echo "$response" | grep -qi "$expected"; then
+ echo "✓"
+ return 0
+ else
+ echo "✗ MISSING: $expected"
+ return 1
+ fi
+}
+
+# Main test function
+run_test() {
+ local prompt_file="$1"
+ local prompt_name
+ prompt_name=$(basename "$prompt_file" .md)
+
+ echo "=============================================="
+ echo "Testing: $prompt_name"
+ echo "=============================================="
+ echo ""
+
+ SYSTEM_PROMPT=$(read_file "$prompt_file")
+ KNOWLEDGE_CONTENT=$(read_file "$KNOWLEDGE_FILE")
+
+ local questions=("How much is the rent on a half plot?" "How long is the waiting list at the moment?" "When am I allowed to have a bonfire?" "I've lost my gate key. How much is a new one?" "What's the biggest shed I can put up?")
+ local expected=("£38" "half plot" "14 months" "2 years" "November" "dry woody waste" "£15" "key" "6 ft" "4 ft" "7 ft")
+
+ local pass_count=0
+ local total_count=0
+
+ for i in "${!questions[@]}"; do
+ local question="${questions[$i]}"
+ echo "Q: $question"
+
+ local response=$(get_response "$SYSTEM_PROMPT" "$question")
+ echo "A: $response"
+
+ # Simple validation - check for key facts
+ echo ""
+ done
+
+ echo ""
+ echo "=============================================="
+}
+
+# Run comparison test
+run_comparison() {
+ echo "=============================================="
+ echo "COMPARISON TEST"
+ echo "=============================================="
+ echo ""
+
+ SYSTEM_PROMPT_BASELINE=$(read_file "bot/system.md")
+ SYSTEM_PROMPT_CANDIDATE=$(read_file "bot/system-draft.md")
+ KNOWLEDGE_CONTENT=$(read_file "$KNOWLEDGE_FILE")
+
+ local questions=("How much is the rent on a half plot?" "How long is the waiting list at the moment?" "When am I allowed to have a bonfire?" "I've lost my gate key. How much is a new one?" "What's the biggest shed I can put up?")
+
+ for i in "${!questions[@]}"; do
+ local question="${questions[$i]}"
+ echo "--- Question: $question ---"
+ echo ""
+
+ echo "BASELINE:"
+ local resp_baseline=$(get_response "$SYSTEM_PROMPT_BASELINE" "$question")
+ echo "$resp_baseline"
+ echo ""
+
+ echo "CANDIDATE:"
+ local resp_candidate=$(get_response "$SYSTEM_PROMPT_CANDIDATE" "$question")
+ echo "$resp_candidate"
+ echo ""
+ echo "----------------------------------------"
+ echo ""
+ done
+}
+
+# Parse arguments
+if [[ "$1" == "all" ]]; then
+ run_test "bot/system.md"
+ echo ""
+ run_test "bot/system-draft.md"
+elif [[ -n "$1" ]]; then
+ run_test "$1"
+else
+ echo "Usage: $0 [system-prompt-file]"
+ echo " $0 all # test both prompts"
+ echo ""
+ echo "Examples:"
+ echo " $0 bot/system.md # test current prompt"
+ echo " $0 bot/system-draft.md # test draft prompt"
+ echo " $0 all # test both and compare"
+ echo ""
+ echo "For side-by-side comparison:"
+ echo " $0 all"
+fi