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
This commit is contained in:
Claude
2026-02-21 21:54:35 +00:00
parent 8217b33f38
commit eba450c5a5
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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:
+3 -2
View File
@@ -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")