@@ -465,7 +465,8 @@ def _reading_report_dirs() -> List[Path]:
465465 if _env_text ("PAPERFLOW_READING_REPORTS_DIR" , "" ):
466466 return [configured ] if configured .exists () and configured .is_dir () else [configured ]
467467 fallback = (PROJECT_ROOT / "data" / "reading_reports" ).resolve ()
468- ordered = [configured , fallback ]
468+ legacy_exports = (PROJECT_ROOT / "data" / "exports" ).resolve ()
469+ ordered = [configured , fallback , legacy_exports ]
469470 results : List [Path ] = []
470471 seen : Set [str ] = set ()
471472 for candidate in ordered :
@@ -857,6 +858,25 @@ def fake_create_doc(title: str, content: str, folder_id: Optional[str] = None) -
857858 reading_agent .create_doc = original
858859
859860
861+ @contextmanager
862+ def _reading_agent_output_env_patch ():
863+ """Expose GUI-derived output paths to reading-agent, which reads os.environ directly."""
864+ patched = {
865+ "PAPERFLOW_READING_REPORTS_DIR" : _configured_path ("PAPERFLOW_READING_REPORTS_DIR" , "data/exports" ),
866+ "PAPERFLOW_PDF_DIR" : _configured_path ("PAPERFLOW_PDF_DIR" , "data/exports" ),
867+ }
868+ previous = {key : os .environ .get (key ) for key in patched }
869+ os .environ .update (patched )
870+ try :
871+ yield
872+ finally :
873+ for key , value in previous .items ():
874+ if value is None :
875+ os .environ .pop (key , None )
876+ else :
877+ os .environ [key ] = value
878+
879+
860880def health () -> Dict [str , Any ]:
861881 return {
862882 "ok" : True ,
@@ -2206,7 +2226,7 @@ def create_reading_reports(
22062226 if not selected :
22072227 return _reports_payload ([], write_feishu_requested = should_write_feishu )
22082228
2209- with _local_only_feishu_doc_patch (not should_write_feishu ):
2229+ with _reading_agent_output_env_patch (), _local_only_feishu_doc_patch (not should_write_feishu ):
22102230 docs = reading_agent .create_reading_report (
22112231 user_id = user_id ,
22122232 paper_ids = selected ,
@@ -2262,7 +2282,7 @@ def read_arxiv(
22622282
22632283 should_write_feishu = _env_bool ("PAPERFLOW_WRITE_FEISHU" , default = False ) if write_feishu is None else bool (write_feishu )
22642284 language = _normalize_response_language (response_language )
2265- with _local_only_feishu_doc_patch (not should_write_feishu ):
2285+ with _reading_agent_output_env_patch (), _local_only_feishu_doc_patch (not should_write_feishu ):
22662286 docs = reading_agent .create_reading_report (
22672287 user_id = user_id ,
22682288 paper_ids = [],
@@ -2305,7 +2325,7 @@ def read_local_pdf(
23052325 }
23062326 should_write_feishu = _env_bool ("PAPERFLOW_WRITE_FEISHU" , default = False ) if write_feishu is None else bool (write_feishu )
23072327 language = _normalize_response_language (response_language )
2308- with _local_only_feishu_doc_patch (not should_write_feishu ):
2328+ with _reading_agent_output_env_patch (), _local_only_feishu_doc_patch (not should_write_feishu ):
23092329 docs = reading_agent .create_reading_report (
23102330 user_id = user_id ,
23112331 paper_ids = [],
0 commit comments