From 4440b00d9120d8041b4912b161ef0ba0dbe7161d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Feb 2026 20:46:20 +0000 Subject: [PATCH] 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 --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 348281c..718eeff 100644 --- a/main.py +++ b/main.py @@ -88,9 +88,17 @@ def run_poll_loop(agent: EmailAgent, channel: EmailChannel, poll_interval: int) for msg in messages: logger.info("Processing message from %s", msg["from"]) 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( parent_email=msg["from"], - message_text=msg["body"], + message_text=message_text, inbound_message_id=msg["message_id"], ) if reply: