DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(attachments): skip parser setup for non-PDF turns
Bingxi Zhao (Frank)f3dc7b0c3bc1
diff --git a/deeptutor/services/session/attachment_parsing.py b/deeptutor/services/session/attachment_parsing.pyindex 869c6a208..04400e440 100644--- a/deeptutor/services/session/attachment_parsing.py+++ b/deeptutor/services/session/attachment_parsing.py@@ -25,6 +25,8 @@ async def parse_chat_pdf_attachments("""Parse every chat PDF with the active engine and update model context."""updated = [dict(record) for record in records]contexts = list(document_texts)+ if not any(str(record.get("filename") or "").lower().endswith(".pdf") for record in updated):+ return updated, contextslimits = get_chat_attachment_limits()total_chars = sum(int(record.get("extracted_chars") or 0)diff --git a/tests/services/session/test_attachment_parsing.py b/tests/services/session/test_attachment_parsing.pyindex 92a7cba99..60283a2e9 100644--- a/tests/services/session/test_attachment_parsing.py+++ b/tests/services/session/test_attachment_parsing.py@@ -9,6 +9,25 @@ from deeptutor.services.session.attachment_parsing import parse_chat_pdf_attachmfrom deeptutor.services.storage.attachment_store import LocalDiskAttachmentStore+async def test_non_pdf_batch_does_not_read_parser_settings(+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path+) -> None:+ monkeypatch.setattr(+ "deeptutor.services.session.attachment_parsing.get_chat_attachment_limits",+ lambda: (_ for _ in ()).throw(AssertionError("settings should not be read")),+ )+ records, contexts = await parse_chat_pdf_attachments(+ [{"id": "txt", "filename": "notes.txt", "extracted_text": "hello"}],+ attachment_store=LocalDiskAttachmentStore(root=tmp_path / "attachments"),+ session_id="session",+ document_texts=["[File: notes.txt]\nhello"],+ )++ assert records[0]["extracted_text"] == "hello"+ assert contexts == ["[File: notes.txt]\nhello"]++@pytest.mark.asyncioasync def test_chat_pdf_always_uses_configured_parser(monkeypatch: pytest.MonkeyPatch, tmp_path: Path