# NousResearch/hermes-agent · IMAP email fetch: unread state and payload bugs

## Open now

- 3 issues, 6 PRs open on GitHub.
- #18106: \[Bug\]: \[Email\] IMAP fetch error: 'int' object has no attribute 'decode'
- #41340: \[Bug\] email: IMAP UID FETCH crashes with 'int object has no attribute decode' on bytes-shaped responses
- #42997: Email gateway IMAP polling marks unread Gmail messages as read
- PR #18337: fix: resolve 7 identified issues \[automated\]
- PR #41395: fix(email): use BODY.PEEK\[\] for IMAP fetch (#41340)
- PR #43017: fix(email): use BODY.PEEK\[\] to avoid marking messages as read on Gmail
- PR #43018: fix(gateway/email): use BODY.PEEK\[\] instead of RFC822 to avoid marking messages as read
- PR #48224: fix(email): use BODY.PEEK\[\] by default, configurable via platforms.email.imap_peek
- PR #72783: fix(email): preserve unread state during IMAP polling

These issues and fixes address two related IMAP problems in the email gateway: fetching messages with RFC822 inadvertently marks them as read (fixed by switching to BODY.PEEK\[\]), and FETCH responses containing non-bytes payloads cause decode crashes (fixed by guarding against malformed responses).

## TL;DR

- 17 member(s): 3 open issue(s), 1 closed issue(s), 6 open PR(s), 0 merged PR(s), 7 PR(s) closed without merging.
- No fix has been merged to main; one or more PRs were attempted (see below).
- **Recommended:** review the prior/competing PR(s) below. A fix was attempted but not merged; your case may extend or revive that work.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `unresolved`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_PARTIAL`): some members are connected by structural evidence (shared changed files, or a closing/superseded reference); the rest are joined by an automated relevance judgement over their text.
- Members outside that structural core may belong to a different underlying problem.
- Pairwise link density `0.13`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Open related issues

- #18106: \[Bug\]: \[Email\] IMAP fetch error: 'int' object has no attribute 'decode'
- #41340: \[Bug\] email: IMAP UID FETCH crashes with 'int object has no attribute decode' on bytes-shaped responses
- #42997: Email gateway IMAP polling marks unread Gmail messages as read

## Closed / duplicate issues

- #48527: Email gateway marks messages as read (IMAP \\Seen) when fetching

## Prior & competing PRs

- **#41382: fix(email): use BODY.PEEK\[\] instead of RFC822 for IMAP UID FETCH**. closed without merge · fix tier `suggested`
  - maintainer direction: category `uncategorized`; implication `needs_llm`; refs `#41395`, `#41382`, `#41395`
  - _suggested-tier fix detail withheld; re-request with `?tier=all` to include it._
- **#41486: fix(email): use BODY.PEEK\[\] for IMAP fetch and handle missing body literal (#41340)**. closed without merge · fix tier `suggested`
  - maintainer direction: category `uncategorized`; implication `needs_llm`
  - _suggested-tier fix detail withheld; re-request with `?tier=all` to include it._
- **#43002: fix(email): use BODY.PEEK\[\] to avoid marking messages as read**. closed without merge · fix tier `suggested`
  - maintainer direction: category `superseded_by_pr`; implication `superseded`; refs `#41395`, `#41395`
  - _suggested-tier fix detail withheld; re-request with `?tier=all` to include it._
- **#12498: fix(email): guard IMAP FETCH response against non-bytes payloads**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `88bd1c01e1956ef6ed35ac6cce00e02ec7cf29bb`, `#56956`
- **#18146: fix(email): guard IMAP FETCH response against non-bytes payloads**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `88bd1c01e1956ef6ed35ac6cce00e02ec7cf29bb`
- **#18337: fix: resolve 7 identified issues \[automated\]**. open
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `88bd1c01e`, `9caa12f4e`
  - files: `agent/auxiliary_client.py`, `gateway/platforms/email.py`, `gateway/run.py`, `hermes_cli/profiles.py`, `optional-skills/migration/openclaw-migration/scripts/openclaw_to_hermes.py`, `tools/approval.py`, `tools/skills_tool.py`
- **#41395: fix(email): use BODY.PEEK\[\] for IMAP fetch (#41340)**. open
  - maintainer direction: category `uncategorized`; implication `needs_llm`; refs `#42997`
  - files: `gateway/platforms/email.py`, `tests/gateway/test_email_body_peek.py`
- **#43016: fix(email): use BODY.PEEK\[\] in IMAP fetch to preserve unread state**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#43018`, `#43018`, `#42997`, `#43018`
- **#43017: fix(email): use BODY.PEEK\[\] to avoid marking messages as read on Gmail**. open
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#43016`, `#43018`
  - files: `gateway/platforms/email.py`
- **#43018: fix(gateway/email): use BODY.PEEK\[\] instead of RFC822 to avoid marking messages as read**. open
  - maintainer direction: category `uncategorized`; implication `needs_llm`; refs `#60637`
  - files: `plugins/platforms/email/adapter.py`, `tests/gateway/test_email.py`
- **#43032: fix(email): use BODY.PEEK\[\] to avoid marking messages as read on IMAP fetch**. closed without merge
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#43017`, `#43018`, `#43002`, `#42997`
- **#48224: fix(email): use BODY.PEEK\[\] by default, configurable via platforms.email.imap_peek**. open
  - maintainer direction: category `partial_fix`; implication `needs_llm`; refs `66605471e9`, `d3bf9f71f738b43626aac0593b59b72989b414b7`, `7b3a138f4b`
  - files: `plugins/platforms/email/adapter.py`, `tests/gateway/test_email.py`, `tests/gateway/test_email_imap_peek.py`, `tests/gateway/test_email_imap_retries.py`, `tests/gateway/test_email_robustness.py`, `website/docs/user-guide/messaging/email.md`
- **#72783: fix(email): preserve unread state during IMAP polling**. open
  - maintainer direction: category `duplicate_of`; implication `duplicate`; refs `#48224`
  - files: `plugins/platforms/email/adapter.py`, `tests/gateway/test_email.py`

## Fix status

- No merged fix on record.
- Subsystem: `gateway`
