From eba450c5a5be0e614a2fa66c2b69d89fb8fcb630 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Feb 2026 21:54:35 +0000 Subject: [PATCH] Fix email quoting to include full conversation history fetch_unread_messages now returns both `body` (stripped, for the LLM) and `raw_body` (full with nested quotes, for the outgoing reply). main.py passes raw_body as quoted_text so each reply carries the complete conversation thread, not just the single last message. https://claude.ai/code/session_01HaUFs7SaLD5SoiuGCY27Tw --- main.py | 2 +- src/channels/email_channel.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 761e133..f91f579 100644 --- a/main.py +++ b/main.py @@ -111,7 +111,7 @@ def run_poll_loop(agent: EmailAgent, channel: EmailChannel, poll_interval: int) body=reply, in_reply_to=msg["message_id"], references=msg["references"], - quoted_text=msg["body"], + quoted_text=msg["raw_body"], quoted_from=msg["from"], ) except Exception: diff --git a/src/channels/email_channel.py b/src/channels/email_channel.py index 624407b..42e7ee8 100644 --- a/src/channels/email_channel.py +++ b/src/channels/email_channel.py @@ -178,8 +178,8 @@ class EmailChannel: in_reply_to = msg.get("In-Reply-To", "").strip() references = msg.get("References", "").strip() - body = _extract_text(msg) - body = _strip_quoted_text(body) + raw_body = _extract_text(msg) + body = _strip_quoted_text(raw_body) if not body.strip(): imap.store(num, "+FLAGS", "\\Seen") @@ -193,6 +193,7 @@ class EmailChannel: "in_reply_to": in_reply_to, "references": references, "body": body, + "raw_body": raw_body, } ) imap.store(num, "+FLAGS", "\\Seen")