Skip to content

Conversation

@garland3
Copy link
Collaborator

Summary

Enable system prompt to be automatically loaded from prompts/system_prompt.md and injected at the start of all conversations. This ensures consistent AI behavior and user personalization.

Changes

  • PromptProvider: Added get_system_prompt() method to load and format system prompt with {user_email} template variable
  • Config: Added system_prompt_filename setting (default: system_prompt.md)
  • MessageBuilder: Updated to inject system prompt as first message in conversation
  • ChatOrchestrator: Wired PromptProvider into MessageBuilder
  • Tests: Added 5 comprehensive tests (all passing)
  • Documentation: Updated CLAUDE.md with Prompt System section

Test Results

✅ All 5 new tests pass
✅ All 271 backend tests pass
✅ All 108 frontend tests pass
✅ No regressions

Behavior

The system prompt from prompts/system_prompt.md is now:

  1. Loaded by PromptProvider with user email substitution
  2. Prepended as first message (role: system) in all conversations
  3. Can be overridden by MCP-provided prompts
  4. Gracefully handles missing file (logs warning, continues without system prompt)

🤖 Generated with Claude Code

Enable system prompt to be automatically loaded from prompts/system_prompt.md
and injected at the start of all conversations. This ensures consistent AI
behavior and user personalization via email template variable.

Changes:
- Added PromptProvider.get_system_prompt() method
- Added system_prompt_filename config setting
- Updated MessageBuilder to inject system prompt
- Added comprehensive test coverage
- Updated CLAUDE.md documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings November 25, 2025 00:01
@github-actions
Copy link

🔒 Security Scan Results

Security Scan Summary

Scan Results

Python SAST (Bandit)

⚠️ Security issues found in Python code

Recommendations

  • Review all SARIF files uploaded to GitHub Security tab
  • Address high and critical severity vulnerabilities immediately
  • Run npm audit fix and pip-audit locally to fix dependencies
  • Consider implementing additional security controls

Copilot finished reviewing on behalf of garland3 November 25, 2025 00:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds system prompt loading functionality to enable automatic injection of a configurable system prompt at the start of all conversations. The implementation integrates seamlessly with the existing prompt infrastructure and follows established code patterns.

Key Changes:

  • Added get_system_prompt() method to PromptProvider following the same pattern as existing prompt methods
  • Added system_prompt_filename configuration setting to AppSettings
  • Updated MessageBuilder to optionally prepend system prompt as the first message
  • Wired PromptProvider into MessageBuilder via ChatOrchestrator
  • Added comprehensive test coverage with 5 tests covering various scenarios

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/modules/prompts/prompt_provider.py Added get_system_prompt() method to load and format system prompt template with user_email substitution
backend/modules/config/config_manager.py Added system_prompt_filename configuration setting (default: "system_prompt.md")
backend/application/chat/preprocessors/message_builder.py Updated to accept optional PromptProvider and prepend system prompt when enabled
backend/application/chat/orchestrator.py Wired PromptProvider into MessageBuilder initialization
backend/tests/test_system_prompt_loading.py Added comprehensive test suite covering prompt loading, MessageBuilder integration, and end-to-end flow
CLAUDE.md Added Prompt System documentation section explaining system prompt functionality and configuration

async def test_system_prompt_sent_to_llm():
"""Test that system prompt is sent to LLM in chat flow"""
# Create a temporary directory for prompts
import tempfile
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate import of tempfile - already imported at line 1.

Suggested change
import tempfile

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,182 @@
import tempfile
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'tempfile' is not used.

Suggested change
import tempfile

Copilot uses AI. Check for mistakes.
@garland3 garland3 merged commit fc9f27d into main Nov 25, 2025
6 checks passed
@garland3 garland3 deleted the feature/system-prompt-loading branch November 25, 2025 02:00
@github-actions
Copy link

🔒 Security Scan Results

Security Scan Summary

Scan Results

Python SAST (Bandit)

⚠️ Security issues found in Python code

Recommendations

  • Review all SARIF files uploaded to GitHub Security tab
  • Address high and critical severity vulnerabilities immediately
  • Run npm audit fix and pip-audit locally to fix dependencies
  • Consider implementing additional security controls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants