Add read_email_thread: read a specific email thread - #9
Merged
Conversation
…'t access Gmail") Logs showed the agent telling the user "I can't access your Gmail" for "what's the X email thread about?" — while the engine was reading Gmail fine. Root cause: no tool to read a SPECIFIC thread (only read_and_summarize_emails, a broad digest, and draft_email_reply). The agent had no fit and wrongly claimed no access. Adds read-only read_email_thread(search_query): same Gmail search draft_email_reply uses, but returns the thread's text (From/Subject/Date + body, plain preferred, HTML stripped); IMAP fallback returns the matched snippet. Uses the existing scoped get_gmail_service — no new send/delete surface. Prompt now steers specific-thread questions here and forbids claiming no email access. 4 tests; 196 pass. Assisted-by: Claude Code (Opus 4.8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (from the logs): the agent told the user "I can't access your Gmail" for "what's the project X email thread about?" — while the proactivity engine was reading Gmail fine at that very moment. Not an access failure: there was simply no tool to read a specific thread (only
read_and_summarize_emails, a broad inbox digest that also deletes junk, anddraft_email_reply). With no fit, the model overstated and claimed no access.Fix: a read-only
read_email_thread(search_query)— the same Gmail searchdraft_email_replyalready uses to locate a thread, but it returns the contents (From/Subject/Date + body; plain-text preferred, HTML tag-stripped; last few messages of the thread). IMAP/app-password mode returns the matched snippet. Uses the existing scopedget_gmail_service— no new send/delete surface.Also a prompt line steering specific-thread questions to this tool and explicitly forbidding "I can't access your Gmail."
4 new tests (returns contents / not-found-doesn't-claim-no-access / no-service / body extraction); 196 pass.
🤖 Generated with Claude Code