Section Writing AgentSAFE
An automated AI research-paper writer based off Google's PaperOrchestra paper's implementation through a skills - benchmark + autoraters using any coding agent (Claude Code, Cursor, Antigravity, Cline, Aider). No API keys, no LLM SDKs.
Overview
An automated AI research-paper writer based off Google's PaperOrchestra paper's implementation through a skills - benchmark + autoraters using any coding agent (Claude Code, Cursor, Antigravity, Cline, Aider). No API keys, no LLM SDKs.
6a03bc20d0c1OBSERVED · 2026-10-14What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
---
name: section-writing-agent
description: Step 4 of the PaperOrchestra pipeline (arXiv:2604.05018). ONE single multimodal LLM call that drafts the remaining paper sections (Abstract, Methodology, Experiments, Conclusion), extracts numeric values from experimental_log.md into LaTeX booktabs tables, splices the generated figures from Step 2, and merges everything into the template that already contains Intro + Related Work from Step 3. TRIGGER when the orchestrator delegates Step 4 or when the user asks to "write the methodology and experiments sections" or "fill in the rest of the paper".
---
# Section Writing Agent (Step 4)
Faithful implementation of the Section Writing Agent from PaperOrchestra
(Song et al., 2026, arXiv:2604.05018, §4 Step 4, App. F.1 pp. 47–49).
**Cost: ONE LLM call** (App. B: "Section Writing Agent (1 call): A single,
comprehensive multimodal call to draft and compile the complete LaTeX
manuscript"). Do NOT split this into per-section calls — the paper
explicitly designs it as one comprehensive call so the model can maintain
global coherence across sections.
## Inputs
- `workspace/outline.json` — the master plan
- `workspace/inputs/idea.md` — technical details
- `workspace/inputs/experimental_log.md` — raw data for tables and qualitative analysis
- `workspace/drafts/intro_relwork.tex` — the template **with Intro + Related
Work already filled in by Step 3**. This is your starting point. The
preamble, package list, style, and the two pre-filled sections must be
preserved verbatim.
- `workspace/citation_pool.json` — the citation map (`{key, title, abstract}`
for each verified paper)
- `workspace/refs.bib` — the BibTeX file
- `workspace/inputs/conference_guidelines.md` — formatting rules
- `workspace/figures/` — the actual PNG files from Step 2 (used as
multimodal vision input!)
- `workspace/figures/captions.json` — caption text per figure_id
- `workspace/tex_profile.json` — TeX package availability flags (written by
`check_tex_packages.py` at Step 0). **Read this before generating any
LaTeX.** It tells you which packages are installed so you select the right
cross-reference pattern, font packages, etc. before you write — not after
you try to compile.
## Output
- `workspace/drafts/paper.tex` — the complete LaTeX paper, with all sections
filled. The Step 5 Refinement Agent will iterate on this file.
## How to do it
### 0.5. Read tex_profile.json and select LaTeX patterns
Before composing the prompt, read `workspace/tex_profile.json` and apply
these rules to every LaTeX choice in the generated paper:
| Profile flag | True → use | False → use instead |
|---|---|---|
| `use_cleveref` | `\cref{fig:X}`, `\cref{tab:Y}` | `Figure~\ref{fig:X}`, `Table~\ref{tab:Y}` |
| `use_nicefrac` | `\nicefrac{a}{b}` | `$a/b$` |
| `use_microtype` | `\usepackage{microtype}` | omit the line |
| `use_t1_fontenc` | `\usepackage[T1]{fontenc}` | omit the line |
If `tex_profile.json` does not exist (old workspace), default to the safe
fallback column (no cleveref, no nicefrac, no microtype, no T1 fontenc).
### 1. Pre-extract metrics from the experimental log
Run the deterministic helper:
```bash
python skills/section-writing-agent/scripts/extract_metrics.py \
--log workspace/inputs/experimental_log.md \
--out workspace/metrics.json
```
This parses the `## 2. Raw Numeric Data` section's markdown tables into
structured JSON. The Section Writing Agent uses this to construct LaTeX
booktabs tables without re-deriving values from raw text. Read
`references/latex-table-patterns.md` for the booktabs conventions.
### 2. Compose the prompt and make ONE multimodal call
Load `references/prompt.md` (verbatim Section Writing Agent prompt from App.
F.1). Prepend the Anti-Leakage Prompt from
`../paper-orchestra/references/anti-leakage-prompt.md`.
Then append the **craft constraints** for the sections being drafted. Pull
them from `skills/shared/section_rhetoric.md` — the global rules plus only
the templates for Abstract, Method, Experiments, and Conclusion (Intro and
Related Work are already written by Step 3; do not re-open them). The App.
F.1 prompt specifies what each section must *contain*; the rhetoric
templates specify the paragraph roles and their order. Without them the
model produces content-complete sections whose paragraphs all make the same
kind of move, which the Step 5 reviewer scores down on Logical Flow.
The user message contains:
- `outline.json` — full content
- `idea.md` — full content
- `experimental_log.md` — full content (tables AND prose)
- `intro_relwork.tex` — full content (this becomes `template.tex` for the prompt)
- `citation_pool.json` — full content (becomes `citation_map.json`)
- `conference_guidelines.md` — full content
- `figures_list` — array of `{figure_id, filename, caption}` from
`captions.json` and the file listing
- **The actual figure PNGs** as multimodal image inputs, so the model can
visually inspect them and write accurate descriptions / refer to them
correctly in the prose.
If your host LLM has no vision input, fall back to text-only mode: pass the
captions in `captions.json` as descriptions and tell the agent it cannot see
the images directly. Quality drops noticeably (the paper notes that visual
grounding measurably improves figure-text alignment), but the pipeline
still completes.
### 3. Save the output
The agent's response is wrapped in `\`\`\`latex ... \`\`\`` fences. Extract
the LaTeX code and save to `workspace/drafts/paper.tex`.
### 4. Run the deterministic gates
```bash
# Orphan citation gate: every \cite{KEY} must exist in refs.bib
python skills/section-writing-agent/scripts/orphan_cite_gate.py \
workspace/drafts/paper.tex workspace/refs.bib
# Latex sanity: matched braces, matched begin/end, no unescaped specials
python skills/section-writing-agent/scripts/latex_sanity.py \
workspace/drafts/paper.tex
# Anti-leakage post-check: no author names, emails, affiliations
python skills/paper-orchestraTrust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (0)
No findings outside the package's declared scope.
Gates applied: no_behavioural_pass.
6a03bc20d0c1full audit observations/trust-audit/skill/ar9av__section-writing-agent.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-14 | 6a03bc20d0c1 | SAFE | B | 89 | first audit |
Questions
What does the Section Writing Agent skill do?
An automated AI research-paper writer based off Google's PaperOrchestra paper's implementation through a skills - benchmark + autoraters using any coding agent (Claude Code, Cursor, Antigravity, Cline, Aider). No API keys, no LLM SDKs.
Is Section Writing Agent safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can Section Writing Agent access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
How current is this page?
The grade is for one exact copy of the source (6a03bc20d0c1), read on 2026-10-14. The repository is watched, and a new audit runs when it changes — this is the first audit.