Repository navigation
feat(paper): 重构 FAROS paper 写作流程,引入 compile/review 多 agent 反馈循环 - #42
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the FAROS “paper” module into a multi-agent feedback loop (writing → LaTeX compile → simple review → writing revisions), updates artifact layout to JSON-only feedback rounds, and revamps the frontend into a 4-stage paper-writing workspace with richer status/feedback visualization.
Changes:
- Introduces dedicated compile/review agents and an orchestrator-driven loop; refines completion criteria (compile success + review passed) and persists compile/review status fields.
- Reworks evidence collection and prompt formatting to include code-stage evidence/tables/figures (without copying raw artifact bodies into the manuscript).
- Replaces the paper UI flow with a new multi-step workspace, updated routes, paper deletion, and unified display status mapping.
Reviewed changes
Copilot reviewed 40 out of 41 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/pages/Papers/PaperWritingWorkspace.tsx | New 4-stage writing workspace UI (start/brief/writing/result) with feedback-loop rendering and file/PDF preview. |
| frontend/src/pages/Papers/paperStatus.ts | Adds derived display statuses (loop revising / compile failed / review issues / review passed) with label/class helpers. |
| frontend/src/pages/Papers/PapersList.tsx | Navigates into new workspace flow, adds delete paper action, and switches status rendering to derived display status helpers. |
| frontend/src/pages/Papers/PaperEditor.tsx | Updates legacy editor badge rendering to use derived display status helpers. |
| frontend/src/App.tsx | Routes papers to the new workspace (/papers/:id/:stage) and moves legacy editor to /papers/legacy/:id. |
| backend/tests/test_paper_prompt_formatting.py | Extends prompt-formatting tests (FakeClient sequencing, truncated outline fallback, simple review prompt evidence audit). |
| backend/tests/test_paper_latex_safety.py | Adds tests for LaTeX preflight sanitization, storage path safety, rewrite sanitization, and PDF render status fields. |
| backend/data/plan_packages/demo_ppkg_math.json | Removes demo plan package JSON. |
| backend/app/storage/paper_storage.py | Adds compile/pdf fields defaults, delete_paper, and path traversal protection for write_paper_file. |
| backend/app/services/pdf_renderer.py | Adds latexmk compile timeout handling and better timeout error reporting. |
| backend/app/modules/paper/storage.py | Re-exports delete_paper. |
| backend/app/modules/paper/skills/utils.py | Introduces reset_artifacts_dir and stable JSON-only artifact paths; expands collected context with code evidence/tables. |
| backend/app/modules/paper/skills/section_writers/experiments.py | Adds code table artifact guidance in experiments writer prompt. |
| backend/app/modules/paper/skills/section_writers/base.py | Tightens figure requirements; expands prompt context budgets; adjusts figure/table requirement triggering. |
| backend/app/modules/paper/skills/section_write.py | Stops emitting section_write artifacts (artifacts list now empty). |
| backend/app/modules/paper/skills/section_rewrite.py | Adds Markdown→LaTeX sanitizers (inline code/emphasis) and removes rewrite artifact emission. |
| backend/app/modules/paper/skills/review_feedback.py | New compile-feedback and simple-review feedback prompt builders (JSON schema) with source bundling. |
| backend/app/modules/paper/skills/qa_audit.py | Replaces legacy evidence gates summary with evidence-usage suggestions extracted from simple reviews. |
| backend/app/modules/paper/skills/paper_brief.py | Incorporates code-stage evidence into brief prompts and normalizes must-use evidence/figures from code artifacts. |
| backend/app/modules/paper/skills/outline.py | Adds compact retry prompt and robust fallback outline generation without injecting default references. |
| backend/app/modules/paper/skills/leader.py | Renames default chain semantics to writing-only chain; removes compile/figure/evidence gates steps from chain. |
| backend/app/modules/paper/skills/latex_compile_support.py | Adds preflight text-special sanitization, skips artifacts dir, and replaces compile step with compile_latex_once result fields. |
| backend/app/modules/paper/skills/figure_generate.py | Removes generic figure generation skill. |
| backend/app/modules/paper/skills/evidence_collect.py | Collects both plan and code evidence and writes combined evidence record. |
| backend/app/modules/paper/skills/collect_context.py | Stops emitting collect_context artifacts (artifacts list now empty). |
| backend/app/modules/paper/skills/code_evidence.py | New code-stage evidence collector (repo/runs/experiments/CART summaries) and artifact materialization helpers. |
| backend/app/modules/paper/skills/code_artifact_collect.py | New step to materialize code figures/tables into the paper LaTeX tree and merge into context summaries. |
| backend/app/modules/paper/skills/init.py | Exposes build_writing_skill_chain. |
| backend/app/modules/paper/service.py | Switches generation to PaperAgentOrchestrator loop; resets artifacts; updates final status fields; refactors skill running helpers. |
| backend/app/modules/paper/papers_api.py | Adds delete and metadata PATCH endpoints; records PDF render status (latexmk vs fallback) with compile errors. |
| backend/app/modules/paper/agents/writing.py | New writing agent that runs writing-only skills and applies compile/review feedback via targeted rewrites. |
| backend/app/modules/paper/agents/simple_review.py | New simple review agent with evidence-usage audit + iterative review/repair loop. |
| backend/app/modules/paper/agents/orchestrator.py | New orchestrator to sequence writing → compile → (optional) review. |
| backend/app/modules/paper/agents/latex_compile.py | New compile agent with iterative compile-feedback loop and targeted rewrite application. |
| backend/app/modules/paper/agents/base.py | New shared agent base for timing/logging and ctx data application. |
| backend/app/modules/paper/agents/init.py | Exports new paper agents/orchestrator. |
| backend/app/modules/code/tests/test_challenge_cup_code.py | Adds regression test for zip directory entries without trailing slash. |
| backend/app/modules/code/code_bundle_import.py | Improves safe zip extraction handling for implicit directory entries. |
| backend/app/llm/provider_client.py | Plumbs timeout kwarg into provider API config. |
| backend/app/faros/capabilities/adapters/paper_drafting.py | Populates compile/pdf render fields for provider-backed drafting payloads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+123
to
+128
| def delete_paper(paper_id: str) -> bool: | ||
| paper_dir = os.path.join(PAPERS_DIR, paper_id) | ||
| if not os.path.isdir(paper_dir): | ||
| return False | ||
| shutil.rmtree(paper_dir) | ||
| return True |
Comment on lines
+1514
to
+1524
| {paperDisplayStatusLabel(selectedPaper) === 'Review passed' | ||
| ? 'PDF is being generated...' | ||
| : selectedPaper.status === 'generating' | ||
| : paperDisplayStatusLabel(selectedPaper) === 'Generating' | ||
| ? 'Paper generation in progress...' | ||
| : 'Generate the paper to see the PDF preview.'} | ||
| : paperDisplayStatusLabel(selectedPaper) === 'Loop revising' | ||
| ? 'Agent feedback loop is revising the paper...' | ||
| : paperDisplayStatusLabel(selectedPaper) === 'Compile failed' | ||
| ? 'LaTeX compile failed; review compile feedback before previewing the PDF.' | ||
| : paperDisplayStatusLabel(selectedPaper) === 'Review issues' | ||
| ? 'Review loop ended with remaining issues.' | ||
| : 'Generate the paper to see the PDF preview.'} |
Icakacm
added a commit
that referenced
this pull request
Oct 21, 2026
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.
概述
本 PR 重构了 FAROS paper 模块的论文写作流程和前端页面,引入了多 agent 协作的论文生成与反馈修改循环。
新的 paper writing 流程中,三个 agent 分工如下:
Compile agent 和 review agent 不直接修改论文内容。所有修改都由 writing agent 根据反馈进行。
主要改动
后端
compile_pdf/ 通用 figure 生成路径。figure_generate,避免论文中引入通用占位图表。artifacts/feedback/round_XX/compile.jsonartifacts/feedback/round_XX/review.jsonartifacts/feedback/round_XX/rewrite_compile.jsonartifacts/feedback/round_XX/rewrite_review.json前端
验证
已在 FAROS conda 环境中运行相关测试:
测试结果:
说明
本 PR 中 compile agent 和 review agent 均保持只读,不直接修改论文。所有实际论文内容修改都由 writing agent 根据反馈执行。