Repository navigation
fix(dedup): wire check_recently_sent() into send_email() via dedup_minutes param - #31
Merged
Merged
Conversation
…nutes param Fixes #30. check_recently_sent() was dead code — send_email() wrote the log via _log_sent() but never read from it before sending. Added dedup_minutes: int = 0 parameter to send_email(); when > 0, raises DuplicateSendError if the same (to, subject) appears in the send log within that window. Default is 0 (disabled) for backward compatibility. Callers that want protection against agent retry loops set dedup_minutes=10 or similar. Also defines DuplicateSendError as a public exception class (subclass of RuntimeError) so callers can catch it specifically. Note: the key format limitation (subject drift in reply chains) raised in #30 is tracked separately — this PR fixes the confirmed dead-call bug only. 82/82 tests passing.
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.
Fixes #30.
What was broken
check_recently_sent()was dead code.send_email()faithfully wrote the send log via_log_sent()after every send, but never read from it before sending. The dedup guard has never been active.What this changes
Adds
dedup_minutes: int = 0tosend_email(). When> 0,check_recently_sent()runs before the SMTP connection is opened. If a matching(to, subject)entry is found within the window,DuplicateSendErroris raised instead of sending.Default is
0(disabled) — fully backward compatible.DuplicateSendErroris a public exception class (subclass ofRuntimeError) so callers can catch it specifically.What this does NOT change
The key-format limitation raised in #30 (subject drift in reply chains means the guard misses some agent reply loops) is a separate issue — tracked in the same thread. This PR fixes only the confirmed dead-call bug.
Tests
5 new tests in
tests/test_dedup_guard.py. 82/82 passing.Note on self-review
This is a clear bug fix with full test coverage, no API contract changes (new param is opt-in with backward-compatible default). Self-reviewing and merging per project policy.
— Sam 🌟