fix: tag context messages with [CONTEXT] to prevent LLM from scoring them
The triage LLM was blending context message content into its reasoning for new messages (e.g., citing profanity from context when the new message was just "I'll be here"). Added per-message [CONTEXT] tags inline and strengthened the prompt to explicitly forbid referencing context content in reasoning/scores. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -399,6 +399,7 @@ class LLMClient:
|
||||
|
||||
lines = [f"[Current time: {now.strftime('%I:%M %p')}]", ""]
|
||||
last_user = None
|
||||
in_new_section = new_message_start is None or new_message_start == 0
|
||||
|
||||
for idx, (username, content, ts, reply_to) in enumerate(messages):
|
||||
if new_message_start is not None and idx == new_message_start:
|
||||
@@ -406,8 +407,10 @@ class LLMClient:
|
||||
lines.append("--- NEW MESSAGES (score only these) ---")
|
||||
lines.append("")
|
||||
last_user = None # reset collapse so first new msg gets full header
|
||||
in_new_section = True
|
||||
delta = now - ts.replace(tzinfo=timezone.utc) if ts.tzinfo is None else now - ts
|
||||
rel = LLMClient._format_relative_time(delta)
|
||||
tag = "" if in_new_section else " [CONTEXT]"
|
||||
|
||||
if username == last_user:
|
||||
# Continuation from same user — indent
|
||||
@@ -416,9 +419,9 @@ class LLMClient:
|
||||
else:
|
||||
# New user block
|
||||
if reply_to:
|
||||
prefix = f"[{rel}] {username} → {reply_to}: "
|
||||
prefix = f"[{rel}] {username} → {reply_to}:{tag} "
|
||||
else:
|
||||
prefix = f"[{rel}] {username}: "
|
||||
prefix = f"[{rel}] {username}:{tag} "
|
||||
msg_lines = content.split("\n")
|
||||
lines.append(prefix + msg_lines[0])
|
||||
for line in msg_lines[1:]:
|
||||
|
||||
Reference in New Issue
Block a user