Skip to content

fix(email): recover the request when a disclaimer shares its paragraph - #115

Merged
NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
Bruce-Yii:fix/email-fused-disclaimer-recovery
Sep 23, 2026
Merged

NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
Bruce-Yii:fix/email-fused-disclaimer-recovery

Conversation

@Bruce-Yii

Copy link
Copy Markdown
Contributor

clean_email_body drops the sender's request when an unpunctuated request line
is immediately followed by a disclaimer line in the same paragraph:

from laya import email_state
D = "This email is confidential and intended solely for the named addressee."
email_state("Locked", "My account is locked\n%s\nPlease unlock it." % D)["body"]
# before: 'Please unlock it.'
# after:  'My account is locked Please unlock it.'

Agent.predict / Router.predict then classifies an email it can no longer see,
and nothing warns.

Cause

laya/email.py::_strip_disclaimer splits a paragraph into sentences only at
[.!?], so locked\nThis ... forms one sentence that tests boilerplate-positive
and is dropped whole, carrying the request with it. The existing test pinned this
as partial recovery.

Change

A boilerplate-positive sentence containing \n is further split at newlines that
start a fresh sentence (first letter uppercase): locked\nThis ... splits, so the
request line is kept and only the disclaimer line drops; are\nconfidential
(lowercase continuation) stays glued, so a wrapped boilerplate footer still drops
whole. Paragraphs without disclaimer text return early, untouched.

Before / after

input shape before after
request\n<disclaimer>\nrequest2 'request2' 'request request2'
request.\n<disclaimer>\nrequest2 full full (unchanged)
standalone / wrapped footer paragraph dropped dropped (unchanged)
...in error,\nPlease delete it. dropped whole 'Please delete it.' (keep-ward)

Trade-off

A capitalised continuation of a boilerplate sentence stays, and an all-lowercase
fusion still loses its first line (indistinguishable from a wrapped footer) —
both pinned in tests. Like #94, this errs towards keeping text: an extra
boilerplate line does no harm, but a missing request does.

Independence from #111

Open #111 touches the same two files but a disjoint function (sign-off vs
disclaimer) and disjoint hunks. I reconstructed its 41 test expectations and ran
them with and without this change: identical 22-pass/8-fail (the 8 are #111's own
fail-before cases). Zero regression delta either way.

Verification

  • tests/test_email.py: 15 passed, 0 failed (1 updated expectation + 4 new checks)
  • test_router 150, test_criteria 34, test_shortlist 81, test_packaging 9/9,
    ruff check laya/ --select=E9,F63,F7,F82,F401,F811 --line-length=120: clean;
    compileall: OK (Python 3.11, CPU-only torch, Windows worker)
  • test_decision_model.py passed on this exact code during the hunt run, but
    aborted on a native OpenBLAS memory allocation failure when re-run on the
    publication branch in this memory-pressured worker (2.6 GB free of 16 GB) —
    environmental, no assertion involved; CI will adjudicate
  • test_download.py has 5 Windows-only path-separator failures, byte-identical
    with and without this change (green on Linux CI)

An unpunctuated request line glued to a disclaimer line fused into one boilerplate-positive sentence and was dropped whole. Split such sentences at uppercase-led newlines; lowercase continuations stay glued so wrapped footers still drop whole.
SaiDheeraj-19 added a commit to SaiDheeraj-19/laya that referenced this pull request Sep 22, 2026
Closes NandhaKishorM#115

- Uses a _FRESH_NEWLINE regex (newline followed by uppercase) to intelligently split unpunctuated user requests from boilerplate disclaimers.
- Updates regression tests in test_email to enforce full request recovery.
SaiDheeraj-19 added a commit to SaiDheeraj-19/laya that referenced this pull request Sep 22, 2026
Closes NandhaKishorM#115

- Uses a _FRESH_NEWLINE regex (newline followed by uppercase) to intelligently split unpunctuated user requests from boilerplate disclaimers.
- Updates regression tests in test_email to enforce full request recovery.
@NandhaKishorM

Copy link
Copy Markdown
Owner

Thank you, and sorry this waited a while. The fused-line split is careful: it only breaks where a new sentence starts, keeps wrapped disclaimer lines together, and leaves uncased scripts alone. The email suite passes with your new cases on today's main. Merging. #128 targets the same problem, and I'll point it here.

@NandhaKishorM
NandhaKishorM merged commit bff8104 into NandhaKishorM:main Sep 23, 2026
baninaveen pushed a commit to baninaveen/laya that referenced this pull request Sep 24, 2026
NandhaKishorM#115)

An unpunctuated request line glued to a disclaimer line fused into one boilerplate-positive sentence and was dropped whole. Split such sentences at uppercase-led newlines; lowercase continuations stay glued so wrapped footers still drop whole.

Co-authored-by: Bruce-Yii <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants