[Technical Debt] Extract LLM prompts to versioned templates for A/B testing

Resolved 💬 3 comments Opened Nov 17, 2025 by roblafave Closed Jan 18, 2026

Summary

System prompts in Agent 7 LLM modules are currently inline in code, making it difficult to version, A/B test, or iterate on prompt improvements without code changes.

Current State

Large system prompts (40-70 lines) are defined as inline strings in:

  • app/llm/planning.py:241 - Planning system prompt (42 lines)
  • app/llm/intent_inference.py:248 - Intent inference system prompt (61 lines)
  • app/llm/draft_generation.py:211 - Draft generation system prompt (69 lines)

Problems

  1. No versioning: Cannot track prompt changes or roll back to previous versions
  2. No A/B testing: Cannot test prompt variations without code deployment
  3. Hard to iterate: Product/ops teams cannot experiment with prompt improvements
  4. No analytics: Cannot correlate prompt versions with workflow success rates

Proposed Solution

Option A: LangSmith Hub (Recommended)

  • Store prompts in LangSmith hub with version tags
  • Load at runtime via hub.pull("second-agent/planning-v1")
  • Enables web UI editing and A/B testing
  • Built-in version history and rollback

Option B: External Files

  • Store prompts in prompts/planning_system.txt
  • Load at module init time
  • Version control via git
  • Simpler but less flexible

Acceptance Criteria

  • [ ] All system prompts extracted to external templates
  • [ ] Prompt loading happens at module init (not per-call)
  • [ ] Version tags applied to all prompts (e.g., v1.0)
  • [ ] Documentation on how to update prompts without code changes
  • [ ] Monitoring dashboard shows prompt version usage

Priority

Medium - Does not block production but impacts iteration speed

Estimated Effort

  • Option A (LangSmith Hub): 4-6 hours
  • Option B (External Files): 2-3 hours

Related

  • Agent 7 (LLM Modules)
  • C4 Constraint (Observability)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗