$npx -y skills add Ar9av/PaperOrchestra --skill content-refinement-agentStep 5 of the PaperOrchestra pipeline (arXiv:2604.05018). Iteratively refine drafts/paper.tex by simulating peer review and applying targeted revisions, with strict accept/revert halt rules, deterministic 0-100 decision bands (Accept/Minor/Major/Reject) that drive a target-met ea
| 1 | # Content Refinement Agent (Step 5) |
| 2 | |
| 3 | Faithful implementation of the Content Refinement Agent from PaperOrchestra |
| 4 | (Song et al., 2026, arXiv:2604.05018, §4 Step 5, App. F.1 pp. 49–51). |
| 5 | |
| 6 | **Cost: ~5–7 LLM calls** (App. B), typically ~3 refinement iterations, each |
| 7 | consisting of one reviewer call and one revision call. |
| 8 | |
| 9 | The paper highlights this step as one of the largest contributors to overall |
| 10 | quality: refinement alone accounts for +19% (CVPR) and +22% (ICLR) absolute |
| 11 | acceptance-rate improvement (Fig. 4). Get this step right. |
| 12 | |
| 13 | ## Inputs |
| 14 | |
| 15 | - `workspace/drafts/paper.tex` — output of Step 4 |
| 16 | - `workspace/inputs/conference_guidelines.md` |
| 17 | - `workspace/inputs/experimental_log.md` — used as ground truth for the |
| 18 | hallucination check |
| 19 | - `workspace/citation_pool.json` / `workspace/refs.bib` — the allowed |
| 20 | bibliography |
| 21 | |
| 22 | ## Outputs |
| 23 | |
| 24 | - `workspace/refinement/iter1/`, `iter2/`, `iter3/` — per-iteration snapshots |
| 25 | containing `paper.tex`, `paper.pdf`, `review.json`, `score.json` |
| 26 | - `workspace/refinement/worklog.json` — append-only history of decisions |
| 27 | - `workspace/final/paper.tex` and `workspace/final/paper.pdf` — copy of the |
| 28 | best accepted snapshot |
| 29 | |
| 30 | ## The refinement loop |
| 31 | |
| 32 | ``` |
| 33 | prev_score = score(paper.tex) # baseline from initial draft |
| 34 | snapshot iter0/ |
| 35 | |
| 36 | for iter in 1..ITER_CAP (default 3): |
| 37 | 1. simulate_review(paper.tex) → review.json |
| 38 | (uses `references/reviewer-rubric.md` rubric) |
| 39 | |
| 40 | 2. apply_revision(paper.tex, review.json) → new_paper.tex |
| 41 | (uses verbatim Refinement Agent prompt at `references/prompt.md`) |
| 42 | |
| 43 | 3. snapshot iter<N>/ with new_paper.tex, review.json |
| 44 | latexmk -pdf new_paper.tex → iter<N>/paper.pdf |
| 45 | |
| 46 | 4. score(new_paper.tex) → curr_score |
| 47 | |
| 48 | 5. decide via score_delta.py: |
| 49 | - if curr.overall > prev.overall: ACCEPT |
| 50 | - elif curr.overall == prev.overall and net_subaxis ≥0: ACCEPT |
| 51 | - else: REVERT |
| 52 | |
| 53 | 6. apply_worklog.py to append the decision |
| 54 | |
| 55 | 7. if REVERT or no actionable weaknesses or iter == ITER_CAP: HALT |
| 56 | |
| 57 | paper.tex ← new_paper.tex (only on ACCEPT) |
| 58 | prev_score ← curr_score |
| 59 | |
| 60 | cp <best iter>/paper.tex → workspace/final/paper.tex |
| 61 | ``` |
| 62 | |
| 63 | The "best" snapshot at HALT is the one with the highest accepted overall |
| 64 | score. On a REVERT halt, the best is the iteration immediately before the |
| 65 | revert. |
| 66 | |
| 67 | ## Step-by-step |
| 68 | |
| 69 | ### 0. Pre-refinement integrity gate |
| 70 | |
| 71 | Before snapshotting or scoring the initial draft, run two gates in order: |
| 72 | |
| 73 | **Gate A — AI failure modes** (load `references/ai-failure-modes.md`, runs once): |
| 74 | |
| 75 | Load `references/ai-failure-modes.md` (which points to `skills/shared/ai_failure_modes.md`). |
| 76 | Run all 7 checks against the draft and the inputs. This gate runs **once only**, |
| 77 | at the start of iteration 1. |
| 78 | |
| 79 | - CONFIRMED failure → write HALT entry to worklog.json, report to user, stop. |
| 80 | - SUSPECTED failure → add WARNING comment to paper.tex, log in worklog.json, continue. |
| 81 | - No failures → proceed. |
| 82 | |
| 83 | **Gate B — Claim-evidence provenance** (runs once, WARN gate): |
| 84 | |
| 85 | ```bash |
| 86 | python skills/paper-orchestra/scripts/claim_evidence_gate.py \ |
| 87 | --paper workspace/drafts/paper.tex \ |
| 88 | --log workspace/inputs/experimental_log.md \ |
| 89 | --out workspace/claim_evidence_report.json |
| 90 | ``` |
| 91 | |
| 92 | Exit 0 → PASS, proceed normally. |
| 93 | Exit 1 → WARN: unsupported numeric claims found. Log in worklog.json as: |
| 94 | `{gate: "claim_evidence", status: "WARN", unsupported_count: N, report: "workspace/claim_evidence_report.json"}` |
| 95 | Pass the `unsupported` list from the report to the revision agent in Step 3 as |
| 96 | an additional instruction: "The following numeric values appear in the paper but |
| 97 | cannot be corroborated in experimental_log.md — verify or remove them: ..." |
| 98 | Do NOT halt on Gate B warnings; the revision agent will address them. |
| 99 | |
| 100 | **Gate C — Read research brief** (every run, no exit code): |
| 101 | |
| 102 | If `workspace/research_brief.md` exists, read it before all reviewer calls. |
| 103 | Pass the "Sections where evidence was thin" list from §4 as additional |
| 104 | context to the Devil's Advocate reviewer. This surfaces the highest-risk |
| 105 | sections for CRITICAL scrutiny. |
| 106 | |
| 107 | ### 0b. Snapshot the initial draft |
| 108 | |
| 109 | ```bash |
| 110 | python skills/content-refinement-agent/scripts/snapshot.py \ |
| 111 | --src workspace/drafts/paper.tex \ |
| 112 | --dst workspace/refinement/iter0/ |
| 113 | ``` |
| 114 | |
| 115 | This creates |