Skip to content

Commit 6ee7ea4

Browse files
committed
Prevent LLM from signing follow-up messages with random names
1 parent 018fb0c commit 6ee7ea4

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

assets/templates/prompts/followup2.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Do **not** use placeholders in the output like the following:
2020
[Your Name]
2121
[Your Contact Information]
2222
[Your Company]
23+
24+
Do **not** sign the message. Do not add any name, signature, closing name, or sign-off name at the end.
25+
The message must end with the call-to-action sentence itself — never with a name like "Best, John" or "— Sarah" or similar.

tests/test_templates.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# tests/test_templates.py
22
from unittest.mock import MagicMock, patch
33

4+
from linkedin.conf import DEFAULT_FOLLOWUP_TEMPLATE_PATH
45
from linkedin.templates.renderer import render_template
56

67

@@ -71,3 +72,24 @@ def test_product_description_empty_when_not_set(self, mock_llm):
7172

7273
prompt = mock_llm.call_args[0][0]
7374
assert "Product: ''" in prompt
75+
76+
@patch("linkedin.templates.renderer.call_llm", return_value="Hi Alice, great to connect!")
77+
def test_default_followup_template_forbids_signature(self, mock_llm):
78+
template_content = DEFAULT_FOLLOWUP_TEMPLATE_PATH.read_text()
79+
80+
session = self._make_session(product_docs="We sell widgets")
81+
render_template(
82+
session,
83+
template_content,
84+
{
85+
"full_name": "Alice Smith",
86+
"headline": "Engineer",
87+
"current_company": "Acme",
88+
"location": "London",
89+
"shared_connections": 3,
90+
},
91+
)
92+
93+
prompt = mock_llm.call_args[0][0]
94+
assert "Do **not** sign the message" in prompt
95+
assert "never with a name" in prompt

0 commit comments

Comments
 (0)