Prompt Editing Guide¶
Purpose: How to safely edit UI Node prompts
Audience: Developers, Product Owners, QA
Last Updated: October 8, 2025
π Table of Contents¶
- Quick Start
- Prompt Architecture
- Editing Workflow
- Common Changes
- Testing Changes
- Best Practices
- Troubleshooting
Quick Start¶
Where Are the Prompts?¶
apps/backend/swisper/agents/supervisor/nodes/ui_helpers/prompts/
βββ simple.md β Simple chat mode (quick queries)
βββ complex.md β Complex chat mode (agent synthesis)
βββ simple_voice.md β Simple voice mode (TTS optimized)
βββ complex_voice.md β Complex voice mode (TTS optimized)
βββ greeting_voice.md β Greeting voice mode (TTS optimized)
Note:
core.mdno longer exists β its content was split into each individual prompt file.
Before You Edit¶
- β Read this guide
- β Understand UI_NODE_SYSTEM
- β Have tests running locally
- β Create a feature branch
Prompt Architecture¶
How Prompts Are Built¶
ββββββββββββββββ ββββββββββββββββ βββββββββββββββββββββ
β simple.md β β complex.md β β simple_voice.md β
β β β β β complex_voice.md β
β β β β β greeting_voice.mdβ
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββββ¬βββββββββββ
β β β
ββββββββββ¬βββββββββ΄βββββββββββββββββββββ
β
ββββββββΌβββββββ
β Placeholder β β {{FACTS_BLOCK}}, {{USER_MESSAGE}}, etc.
β Injection β
ββββββββ¬βββββββ
β
ββββββββΌβββββββ
β Final β
β Prompt β β Sent to LLM
βββββββββββββββ
Each prompt file is self-contained (core identity content is included in each file).
Fragment Roles¶
| File | When Used | Purpose |
|---|---|---|
simple.md |
Simple queries (no agent work) | Direct Q&A (includes core identity) |
complex.md |
Complex queries (with agent results) | Agent synthesis guidance (includes core identity) |
simple_voice.md |
Simple voice interactions | TTS-optimized simple chat |
complex_voice.md |
Complex voice interactions | TTS-optimized agent synthesis |
greeting_voice.md |
Voice greetings | TTS-optimized greeting flow |
Available Placeholders¶
Use these in any .md file to inject dynamic content:
| Placeholder | Example | When to Use |
|---|---|---|
{{CURRENT_TIME}} |
2025-10-08T14:30:00Z |
Time-sensitive responses |
{{USER_TIMEZONE}} |
Europe/Zurich |
Timezone awareness |
{{USER_LOCALE}} |
de-CH |
Language/formatting |
{{LOCALE_FORMATTING_RULES}} |
Swiss German: Use Γ€, ΓΆ, ΓΌ... |
Locale-specific rules |
{{PRESENTATION_POLICY}} |
Verbosity: concise. Tone: friendly. |
User preferences |
{{FACTS_BLOCK}} |
- name: Heiko\n- location: Zurich |
User personalization |
{{USER_MESSAGE}} |
What's the weather? |
Current query |
{{CONTEXT_SUMMARY}} |
User asked about Paris earlier... |
Conversation history |
{{AGENT_TEXT_SUMMARY}} |
Weather Agent: Sunny, 22Β°C... |
Agent results (complex only) |
Editing Workflow¶
Step 1: Identify What to Change¶
Use Case β File to Edit:
| I want to change... | Edit this file |
|---|---|
| Swisper's personality or tone | simple.md, complex.md (identity section in each) |
| How Swisper uses facts | simple.md, complex.md (Fact Integration section) |
| How Swisper handles context | simple.md, complex.md (Context Usage section) |
| Language matching rules | simple.md, complex.md (Language Detection section) |
| Simple chat task instructions | simple.md |
| Agent synthesis guidance | complex.md |
| Voice/TTS optimization rules | simple_voice.md, complex_voice.md, greeting_voice.md |
Step 2: Make Your Changes¶
Location:
Edit the file:
Example Change (simple.md):
# BEFORE
You are Swisper, a knowledgeable AI coordinator.
# AFTER
You are Swisper, a friendly and empathetic AI assistant.
Step 3: Test Your Changes¶
Run UI Node tests:
All tests should pass:
β
test_intro_flow_works PASSED
β
test_greeting_flow_personalized PASSED
β
test_simple_chat_flow_works PASSED
β
test_complex_chat_flow_works PASSED
Step 4: Manual Testing (Optional but Recommended)¶
Start backend:
Test in frontend: 1. Open Swisper UI 2. Start new chat 3. Test affected flow (intro, greeting, simple, or complex) 4. Verify response quality
Step 5: Commit Your Changes¶
git add apps/backend/swisper/agents/supervisor/nodes/ui_helpers/prompts/
git commit -m "feat(prompts): Update Swisper personality to be more empathetic"
Common Changes¶
Change Swisper's Personality¶
File: simple.md, complex.md (update identity section in each)
Section: # SWISPER IDENTITY
Example:
# BEFORE
**Personality:** Professional and efficient
# AFTER
**Personality:** Warm, empathetic, and supportive
Test Impact: - Intro flow should reflect new personality - All responses should feel more empathetic
Update Fact Usage Guidance¶
File: simple.md, complex.md
Section: ## FACT INTEGRATION
Example:
# BEFORE
Use facts when relevant.
# AFTER
Use facts to show deep understanding of the user's context.
Prioritize safety-critical facts (allergies, health conditions).
Test Impact: - Facts should be used more thoughtfully - Safety concerns should be highlighted
Change Context Usage Rules¶
File: simple.md, complex.md
Section: ## CONTEXT USAGE INTELLIGENCE
Example:
# BEFORE
Use context when available.
# AFTER
ALWAYS check context for:
- Unresolved questions from previous turns
- User frustrations that need addressing
- Continuity opportunities
Test Impact: - Context should be used more proactively - Conversations should feel more coherent
Update Agent Synthesis Guidance¶
File: complex.md
Section: ## AGENT RESULTS SYNTHESIS
Example:
# BEFORE
Synthesize agent results faithfully.
# AFTER
Synthesize agent results with these priorities:
1. SAFETY: Highlight any warnings or cautions first
2. CLARITY: Explain what agents did in plain language
3. ACTION: Tell user what they can do next
Test Impact: - Complex responses should be more actionable - Safety information should be prominent
Adjust Voice/TTS Rules¶
File: simple_voice.md, complex_voice.md, greeting_voice.md
Section: ## TTS OPTIMIZATION
Example:
# BEFORE
No markdown formatting.
# AFTER
CRITICAL TTS RULES:
- No markdown (**, *, #, etc.)
- No emojis
- No bullet points
- Use spoken transitions: "first", "then", "finally"
- Keep sentences under 20 words for natural pacing
Test Impact: - Voice responses should sound more natural - TTS output should have better pacing
Testing Changes¶
Automated Tests¶
Run all UI Node tests:
Expected output:
tests/test_ui_node_integration_simple.py::TestUINodeCoreFlows
β
test_intro_flow_works PASSED
β
test_greeting_flow_personalized PASSED
β
test_simple_chat_flow_works PASSED
β
test_complex_chat_flow_works PASSED
tests/test_ui_node_prompt_defaults_tdd.py
β
test_swisper_defaults_exist PASSED
β
test_preference_merging_respects_priority PASSED
[... more tests ...]
tests/test_greeting_frequency_logic.py
β
test_first_time_user_always_gets_intro PASSED
β
test_not_first_message_never_gets_greeting PASSED
[... more tests ...]
Manual Test Scenarios¶
Test 1: Intro Flow
1. Create new user account
2. Send first message: "Hello"
3. Verify: Comprehensive intro with updated personality
Test 2: Greeting Flow
1. Use existing user (has_seen_intro=True)
2. Start new chat after 24 hours
3. Verify: Personalized greeting with updated tone
Test 3: Simple Chat
Test 4: Complex Chat
1. Ask complex question: "Book flight to Paris and check weather"
2. Verify: Agent synthesis follows new rules
Test 5: Voice Mode
1. Enable voice input/output
2. Ask any question
3. Verify: Response has no markdown, sounds natural
Best Practices¶
β DO¶
- Edit
.mdfiles directly (not Python code) - Test after every change (run pytest)
- Use placeholders for dynamic content (
{{FACTS_BLOCK}}) - Keep sections clear (use markdown headers:
#,##,###) - Write for the LLM (clear, explicit instructions)
- Be principle-based (teach concepts, not hardcoded cases)
- Commit prompt changes separately (easier to review/rollback)
β DON'T¶
- Don't hardcode user data (use placeholders instead)
- Don't add brittle heuristics (e.g., "if German, say...")
- Don't make prompts too long (LLM attention degrades)
- Don't remove placeholders ({{FACTS_BLOCK}} etc. are required)
- Don't skip testing (prompt changes can break flows)
- Don't mix concerns (keep each prompt file focused on its specific variant)
Troubleshooting¶
Problem: Tests Failing After Prompt Change¶
Symptom:
Likely Cause: Prompt change altered LLM behavior unexpectedly
Fix:
1. Revert change: git checkout -- prompts/simple.md (or whichever file was changed)
2. Test again: uv run pytest tests/test_ui_node_integration_simple.py -v
3. Make smaller change: Edit only one section at a time
4. Test incrementally: Run tests after each small edit
Problem: Placeholder Not Being Replaced¶
Symptom:
Likely Cause: Typo in placeholder name
Fix:
1. Check spelling: {{FACTS_BLOCK}} (case-sensitive)
2. Check location: Placeholder must be in .md file (not Python)
3. Check Python: Ensure build_professional_prompt() replaces it
Available placeholders: See Available Placeholders section
Problem: Prompt Too Long, LLM Ignores Instructions¶
Symptom: LLM only follows first few instructions, ignores later ones
Likely Cause: Prompt exceeds LLM's attention span
Fix:
1. Shorten prompt: Remove verbose explanations
2. Use numbered lists: Makes instructions easier to scan
3. Bold key points: **CRITICAL:**, **DO NOT:**
4. Move context to end: Put {{CONTEXT_SUMMARY}} after main instructions
Good structure:
Problem: Changes Not Reflected in Production¶
Symptom: Edited prompt, but responses unchanged
Likely Cause: 1. Backend not restarted 2. Wrong file edited 3. Cache issue
Fix:
# 1. Verify file location
cd apps/backend/swisper/agents/supervisor/nodes/ui_helpers/prompts/
ls -la
# 2. Check file content
cat simple.md | grep "your change text"
# 3. Restart backend
# (If running locally)
# Ctrl+C to stop, then restart
# 4. Clear any caches
# (If running in Docker)
docker-compose restart backend
Advanced: Adding New Placeholders¶
When Needed: You want to inject new dynamic content into prompts
Example: Add current weather to prompt
Step 1: Add to Python¶
File: apps/backend/swisper/agents/supervisor/nodes/ui_helpers/professional_prompt_builder.py
def build_professional_prompt(...):
# ... existing code ...
# Fetch current weather
current_weather = get_current_weather(user_location) # Your function
# Inject placeholder
complete_prompt = complete_prompt.replace(
"{{CURRENT_WEATHER}}",
current_weather
)
return complete_prompt
Step 2: Use in Markdown¶
File: prompts/simple.md (or whichever prompt needs the placeholder)
## CURRENT CONTEXT
Current Weather: {{CURRENT_WEATHER}}
Use this to provide contextually relevant suggestions.
Step 3: Test¶
Related Documentation¶
- UI Node System: UI_NODE_SYSTEM
- Architecture: SWISPER_ARCHITECTURE
- Testing Guide: TESTING_GUIDE
Questions?¶
- Not sure which file to edit? β Check Fragment Roles
- Test failing? β See Troubleshooting
- Want to understand prompts better? β Read UI_NODE_SYSTEM
- Still stuck? β Ask the team / create an issue