Stage 6: Writing
The writing stage produces the paper draft. The Writer agent works in clean, isolated sessions, receiving curated context from the Orchestrator for each section.
Entering This Stage
What you have:
- Complete analysis with paper framing (
experiments/exp-001/analysis.md) - All figures generated (
papers/figures/) - Related work summaries from Scout (
papers/related_work/) - Paper outline from Planner (
papers/outline.md)
What you don't have yet:
- Paper text
- LaTeX document
- Final bibliography
Steps
graph TD
A[1. Outline Refinement] --> B[2. Related Work Prep]
B --> C[3. Section Writing]
C --> D[4. Integration]
D --> E[5. Internal Review]
E --> F{Quality OK?}
F -->|Yes| G[Gate: Advance to Review]
F -->|No| C
style A fill:#f9f0ff,stroke:#7c3aed
style B fill:#ecfdf5,stroke:#059669
style C fill:#ede9fe,stroke:#7c3aed
style E fill:#fef3c7,stroke:#d977061. Outline Refinement
Agent: Orchestrator (Claude Opus) with Planner
The Orchestrator refines the paper outline based on actual results (which may differ from the original plan):
# papers/outline.md (refined)
## 1. Introduction (1 page)
- Problem: Attention is O(n^2), limiting long-sequence modeling
- Key insight: Flash attention tiling + recurrent formulation
- Contributions (3 bullets)
## 2. Related Work (1 page)
- Efficient attention methods
- Recurrent approaches to attention
- Hardware-aware optimization
## 3. Method (2 pages)
- 3.1 Preliminaries: Retention mechanism
- 3.2 Flash-Recurrent Attention
- 3.3 Analysis: Complexity and memory
## 4. Experiments (2 pages)
- 4.1 Setup
- 4.2 Main Results (Table 1)
- 4.3 Ablation Study (Table 2)
- 4.4 Scaling Analysis (Figure 2)
## 5. Discussion (0.5 pages)
- Limitations
- Future work
## 6. Conclusion (0.5 pages)2. Related Work Preparation
Agent: Scout (Gemini)
The Scout ensures all cited papers have proper summaries and BibTeX entries:
- Verify all baselines have entries
- Add any papers discovered during analysis
- Cross-check with analysis.md for completeness
Output: Updated papers/related_work/summaries.yaml and papers/related_work/papers.bib
3. Section Writing
Agent: Writer (Claude Opus, clean session per section)
The core writing phase. Each major section gets a fresh Writer session:
| Section | Context Provided | Key Challenge |
|---|---|---|
| Introduction | Outline, contributions, related work overview | Motivating the problem clearly |
| Related Work | Pre-digested summaries, positioning notes | Connecting prior work to ours |
| Method | Algorithm description, pseudocode, complexity analysis | Technical precision + clarity |
| Experiments | Results tables, figures, statistical tests | Honest presentation of results |
| Discussion | Analysis synthesis, known limitations | Balanced assessment |
| Conclusion | Full paper context (if space allows) | Concise, forward-looking |
| Abstract | Full paper (written last) | Compress everything into 200 words |
Sections are written in dependency order
Introduction and Method can be written in parallel. Experiments depends on having the Method section (for consistent notation). Discussion depends on Experiments. Abstract is written last.
graph LR
I[Introduction] --> E[Experiments]
M[Method] --> E
RW[Related Work] --> E
E --> D[Discussion]
D --> C[Conclusion]
C --> A[Abstract]
style A fill:#fef3c7,stroke:#d977064. Integration
Agent: Orchestrator (Claude Opus)
The Orchestrator integrates all sections into a single LaTeX document:
- Verify notation consistency across sections
- Check cross-references (figures, tables, equations)
- Ensure page limit is respected
- Compile LaTeX to verify it builds
Output: papers/drafts/v1.tex (complete first draft)
Integration is not just concatenation
The Orchestrator reads through the integrated draft looking for inconsistencies: a variable named differently in Method vs. Experiments, a claim in the Introduction not supported in Experiments, a related work paper cited but not discussed.
5. Internal Review
Agent: Orchestrator (Claude Opus)
Before the formal review stage, the Orchestrator does a self-check:
- Does the paper tell a coherent story?
- Are all claims supported by data?
- Is the contribution clearly stated?
- Are limitations acknowledged?
If issues are found, specific sections are re-dispatched to the Writer with revision instructions.
Gate
| Gate Type | Recommended | Behavior |
|---|---|---|
human | Yes | User reads the draft before formal review |
auto-judge | Possible | Judge does a quick quality check |
auto | Not recommended | Paper quality deserves review |
Read your paper before review
The writing stage gate is a critical human checkpoint. Reading your own paper draft takes 30-60 minutes and often catches issues that no automated review can find — you know your story better than any LLM.
Error Handling
| Error | Recovery |
|---|---|
| Writer context fills mid-section | Start new session, provide partial draft |
| Section too long for page limit | Orchestrator gives Writer a word budget |
| LaTeX compilation error | Coder fixes LaTeX syntax |
| Notation inconsistency | Re-dispatch affected section to Writer |
| Missing citation | Scout fetches paper, Writer integrates |
Writer Context Management
The Writer's clean context is critical for quality. Here's how it works per section:
Session starts (100% context available)
├── Outline loaded (2%)
├── Section spec loaded (3%)
├── Relevant results loaded (10%)
├── Related work summaries loaded (5%)
├── Style guidelines loaded (2%)
├── [78% available for writing]
└── Section written → saved to disk
Session endsWhat if 78% isn't enough?
For very long sections (e.g., a 4-page experiments section), the Orchestrator splits it into subsections. Each subsection gets a fresh Writer session. The integration step then ensures coherence across subsections.
Outputs Summary
| File | Contents |
|---|---|
papers/drafts/v1.tex | Complete first draft |
papers/drafts/current.tex | Symlink to latest version |
papers/related_work/papers.bib | Complete bibliography |
papers/figures/ | All figures referenced in paper |
Next Stage
When the gate passes, the pipeline advances to Review with a complete paper draft.