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:
@@ -111,7 +111,7 @@ def run_poll_loop(agent: EmailAgent, channel: EmailChannel, poll_interval: int)
|
|||||||
body=reply,
|
body=reply,
|
||||||
in_reply_to=msg["message_id"],
|
in_reply_to=msg["message_id"],
|
||||||
references=msg["references"],
|
references=msg["references"],
|
||||||
quoted_text=msg["body"],
|
quoted_text=msg["raw_body"],
|
||||||
quoted_from=msg["from"],
|
quoted_from=msg["from"],
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -178,8 +178,8 @@ class EmailChannel:
|
|||||||
in_reply_to = msg.get("In-Reply-To", "").strip()
|
in_reply_to = msg.get("In-Reply-To", "").strip()
|
||||||
references = msg.get("References", "").strip()
|
references = msg.get("References", "").strip()
|
||||||
|
|
||||||
body = _extract_text(msg)
|
raw_body = _extract_text(msg)
|
||||||
body = _strip_quoted_text(body)
|
body = _strip_quoted_text(raw_body)
|
||||||
|
|
||||||
if not body.strip():
|
if not body.strip():
|
||||||
imap.store(num, "+FLAGS", "\\Seen")
|
imap.store(num, "+FLAGS", "\\Seen")
|
||||||
@@ -193,6 +193,7 @@ class EmailChannel:
|
|||||||
"in_reply_to": in_reply_to,
|
"in_reply_to": in_reply_to,
|
||||||
"references": references,
|
"references": references,
|
||||||
"body": body,
|
"body": body,
|
||||||
|
"raw_body": raw_body,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
imap.store(num, "+FLAGS", "\\Seen")
|
imap.store(num, "+FLAGS", "\\Seen")
|
||||||
|
|||||||
Reference in New Issue
Block a user