Skip to content

Fix issue 115 email parsing - #128

Closed
SaiDheeraj-19 wants to merge 1 commit into
NandhaKishorM:mainfrom
SaiDheeraj-19:fix-issue-115-email-parsing
Closed

SaiDheeraj-19 wants to merge 1 commit into
NandhaKishorM:mainfrom
SaiDheeraj-19:fix-issue-115-email-parsing

Conversation

@SaiDheeraj-19

Copy link
Copy Markdown
Contributor

Closes #115

Overview

This PR resolves the critical issue where clean_email_body silently drops the sender's actual request if an unpunctuated request line is immediately followed by a disclaimer footer in the same paragraph.

Cause

laya/email.py::_strip_disclaimer was previously splitting paragraphs into sentences only at punctuation [.!?]. This meant that unpunctuated strings (like My account is locked\nThis email is confidential...) were treated as a single sentence. Because the regex flagged the disclaimer segment, the entire chunk (including the user's request) was dropped, stripping the model of critical context.

Change

A new regex trap (_FRESH_NEWLINE = re.compile(r"\n(?=[A-Z])")) was introduced.
If a boilerplate-positive sentence contains a \n, it is now further split at newlines that start a fresh sentence (first letter uppercase).

  • locked\nThis ... splits, keeping the request line and only dropping the disclaimer line.
  • are\nconfidential (lowercase continuation) stays glued, ensuring wrapped boilerplate footers still drop whole.
  • Paragraphs without disclaimer text return early and untouched.

Verification

  • Added an exact regression test case to tests/test_email.py that verifies a missing terminal punctuation mark still results in full request recovery.
  • All 11 email parsing tests pass cleanly.

Copilot AI lite review requested due to automatic review settings September 22, 2026 04:27
@SaiDheeraj-19
SaiDheeraj-19 force-pushed the fix-issue-115-email-parsing branch from 0954b37 to 08c7003 Compare September 22, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved critical backward-compatibility issue plus moderate validation, calibration, parsing, CI, and evaluation setup findings.

Review effort: Lite
Findings: None

What changed in this PR

Fixes email disclaimer parsing and adds language-specific calibration, CLI/FastAPI tooling, and Chinese evaluation assets.

Changes:

  • Preserve unpunctuated requests before disclaimer footers.
  • Add CLI, server packaging, calibration overrides, and tests.
  • Add Chinese evaluation scripts, documentation, and results.
File Summary and review notes
tests/​test_shortlist.py Updates test stub compatibility.
tests/​test_server_example.py Adds server smoke coverage; real checkpoint use creates CI dependency and resource risk (moderate, 1 vote).
tests/​test_router.py Tests language propagation.
tests/​test_email.py Updates disclaimer regression coverage.
tests/​test_cli.py Adds CLI tests.
research/​eval_zh/​win_patch.py Adds Windows compatibility support.
research/​eval_zh/​smoke_test.py Adds Chinese smoke test; should consistently disable Xet for the documented mirror (moderate, 1 vote).
research/​eval_zh/​run.ps1 Adds PowerShell runner; virtualenv path and working-directory instructions are inconsistent (moderate, 1 vote).
research/​eval_zh/​results/​summary.json Stores aggregate evaluation results.
research/​eval_zh/​results/​per_case.jsonl Stores per-case evaluation results.
research/​eval_zh/​requirements.txt Pins evaluation dependencies.
research/​eval_zh/​README.md Documents evaluation setup; virtualenv location conflicts with the runner (nit, 1 vote).
research/​eval_zh/​LICENSE Licenses evaluation tooling.
research/​eval_zh/​eval_zh.py Implements Chinese evaluation.
research/​eval_zh/​.gitignore Ignores local evaluation artifacts.
README.md Documents CLI, server, and CJK guidance.
pyproject.toml Adds packaging metadata; CI/test installation may silently skip server coverage without httpx (moderate, 2 votes).
laya/​router.py Adds language calibration; detected languages are not forwarded for automatic routing (moderate, 1 vote), and attach() breaks legacy two-argument agents when lang is unset (critical, 1 vote).
laya/​email.py Splits disclaimer paragraphs at fresh lines; indented disclaimer lines remain incorrectly glued to requests (moderate, 1 vote).
laya/​cli.py Implements the CLI.
laya/​agent.py Applies language-specific temperatures; overrides lack shape validation and partial overrides discard checkpoint defaults (moderate, 1 vote each).
laya/​__main__.py Enables python -m laya.
examples/​server.py Adds the FastAPI demo; criteria shapes should be validated according to question type (moderate, 1 vote).
.github/​workflows/​ci.yml Expands CI coverage and dependencies.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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 for working on #115's report. #115 itself landed today with a slightly more conservative split (it leaves uncased scripts alone and keeps wrapped disclaimer lines together), so this is superseded. Thanks for the effort.

@SaiDheeraj-19

SaiDheeraj-19 commented Sep 23, 2026 via email

Copy link
Copy Markdown
Contributor Author

@SaiDheeraj-19

Copy link
Copy Markdown
Contributor Author

"Looks like the more conservative fix for this landed in main today! Closing this since it's superseded. Thanks for resolving it so quickly!"

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.

3 participants