Prepend email headers to message text passed to LLM
The LLM previously only received the stripped email body, giving it no way to extract the sender's email address for the parentGuardian.email field. Prepend Von:/Betreff: headers to every message so the LLM can read the From address and subject without asking the parent for them. The quoted_text sent back in the reply still uses only msg["body"] so the quote block stays clean. https://claude.ai/code/session_01HaUFs7SaLD5SoiuGCY27Tw
This commit is contained in:
@@ -88,9 +88,17 @@ def run_poll_loop(agent: EmailAgent, channel: EmailChannel, poll_interval: int)
|
|||||||
for msg in messages:
|
for msg in messages:
|
||||||
logger.info("Processing message from %s", msg["from"])
|
logger.info("Processing message from %s", msg["from"])
|
||||||
try:
|
try:
|
||||||
|
# Prepend email headers so the LLM can extract the
|
||||||
|
# sender's address and subject (e.g. to fill in
|
||||||
|
# parentGuardian.email automatically).
|
||||||
|
message_text = (
|
||||||
|
f"Von: {msg['from']}\n"
|
||||||
|
f"Betreff: {msg['subject']}\n\n"
|
||||||
|
f"{msg['body']}"
|
||||||
|
)
|
||||||
reply = agent.process_message(
|
reply = agent.process_message(
|
||||||
parent_email=msg["from"],
|
parent_email=msg["from"],
|
||||||
message_text=msg["body"],
|
message_text=message_text,
|
||||||
inbound_message_id=msg["message_id"],
|
inbound_message_id=msg["message_id"],
|
||||||
)
|
)
|
||||||
if reply:
|
if reply:
|
||||||
|
|||||||
Reference in New Issue
Block a user