Repository navigation
carry #149: filter before reading bodies in body_text search; add max_body_reads - #152
Conversation
…ll mailbox sizes Mailboxes under WHOSE_CLAUSE_SAFE_LIMIT took a path that ran 'every message of currentMailbox' and read the content of every message before checking any filter, and never stopped at the requested limit. A body search with a two-day date_from on a ~2,000-message inbox read every body and overran the client's tool timeout. Body search now always uses the newest-first index scan: date window cutoff first, cheap metadata filters (sender, subject, read, flags, attachments) next, and only then 'content of', with body reads counted against BOUNDED_BODY_SCAN_MAX_MESSAGES and an early exit once the page is filled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vce8TBD74H2bFq6V8wpi3
Walking a ~2,000-message mailbox by index costs several Apple events per message (subject, sender, read status, date), which overran the client's 80 s tool timeout even with almost no body reads (e.g. body_text + sender with no date window). For mailboxes under WHOSE_CLAUSE_SAFE_LIMIT, body search now narrows candidates with the same whose clause the metadata search uses, in one Apple event, and only body-reads the survivors newest-first. Pure body searches with no cheap filters skip the per-message metadata reads and just read content, still capped by BOUNDED_BODY_SCAN_MAX_MESSAGES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vce8TBD74H2bFq6V8wpi3
The 50-body cap was fixed in code, so a body search over a busy date window could only come back scan_limited. search_emails now accepts an optional max_body_reads (default 50, unchanged; 1-500) and documents when to raise it, so an agent can retry a scan_limited body search with a bigger budget without changing behavior for anyone else. Also adds changelog entries for this and the body-search fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vce8TBD74H2bFq6V8wpi3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014vce8TBD74H2bFq6V8wpi3
… credit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoqrHXCrA6u3ojSEtdCbxY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoqrHXCrA6u3ojSEtdCbxY
|
Posted by Claude (AI maintainer agent) on Patrick's behalf. Merging. On mailboxes under 5,000 messages, This change filters first: a CI is green on the final head, and 324 passed locally on fastmcp 4.2.1 and 3.1.0. The new tests fail against the old Generated by Claude Code |
Posted by Claude (AI maintainer agent) on Patrick's behalf.
Carries #149 by @brian-maloney, keeping their 4 commits and authorship.
What
On mailboxes under 5,000 messages,
search_emails(body_text=...)read every message's body before checking any filter, and it never stopped atlimit. That overran client timeouts on a ~2,000-message inbox and left the automation lock held. Body search now:whoseclause the metadata search uses (under the size limit), or walks the mailbox newest-first by index with a date cutoff (over the limit);max_body_reads(default 50, the current cap; range 1–500).Maintainer changes
main; moved the CHANGELOG entries into the new[Unreleased]with credit.Testing
main'ssearch.py.Known trade-off
On mailboxes over 5,000 messages, a body search that also has a metadata filter but no date window now walks up to
BOUNDED_SCAN_MAX_MESSAGES(4000) by index, the same as a metadata-only search. Before, it stopped after 50 messages. So it shares the per-message cost tracked in #132 for very large Gmail mailboxes. Addingdate_fromkeeps it fast, because the walk stops at the cutoff.Generated by Claude Code