Skip to content

Commit da49ff5

Browse files
JihaoXinclaude
andcommitted
Use planner (not visualizer) to decide concept figures, based on idea/findings
Problem: visualizer analyzed empty main.tex template and said "no concept figures needed". In Dev phase, main.tex is empty when figures are generated. Fix: - Use planner agent instead of visualizer for figure planning - Base decisions on idea, findings.yaml, deep_research.md (available in Dev phase) instead of main.tex content - Fallback: if planner returns nothing, auto-create a system overview figure using the project idea as context - Every paper gets at least 1 concept figure (system overview) - main.tex only used as additional context if it has >1000 chars (not an empty template) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9f35b66 commit da49ff5

File tree

1 file changed

+51
-36
lines changed

1 file changed

+51
-36
lines changed

ark/compiler.py

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -635,66 +635,81 @@ def _generate_nano_banana_figures(self):
635635
venue = self.config.get("venue", "")
636636
latex_dir = self.config.get("latex_dir", "Latex")
637637

638-
# Ask agent to identify concept figures that need AI generation
639-
analysis_output = self.run_agent("visualizer", f"""
640-
Analyze the paper {latex_dir}/main.tex and identify ALL figures that would benefit from
641-
AI-generated concept diagrams (architecture diagrams, mechanism illustrations, overview figures,
642-
workflow diagrams, system diagrams, pipeline diagrams).
638+
# Gather context for planner — use idea, findings, deep research (NOT main.tex which may be empty)
639+
idea = self.config.get("idea", "")
640+
title = self.config.get("title", "")
641+
findings_file = self.state_dir / "findings.yaml" if hasattr(self, 'state_dir') else None
642+
dr_file = self.state_dir / "deep_research.md" if hasattr(self, 'state_dir') else None
643+
644+
paper_context = f"Paper title: {title}\n\n"
645+
if idea:
646+
paper_context += f"Research idea:\n{idea[:2000]}\n\n"
647+
if findings_file and findings_file.exists():
648+
paper_context += f"Experiment findings:\n{findings_file.read_text()[:2000]}\n\n"
649+
if dr_file and dr_file.exists():
650+
paper_context += f"Background research:\n{dr_file.read_text()[:1500]}\n"
651+
652+
# Also check main.tex if it has content (for review phase, not empty template)
653+
main_tex = self.latex_dir / "main.tex"
654+
if main_tex.exists():
655+
tex_content = main_tex.read_text()
656+
# Only use main.tex if it has real content (not just a template skeleton)
657+
if len(tex_content) > 1000:
658+
paper_context += f"\nCurrent paper content:\n{tex_content[:2000]}\n"
643659

644-
Do NOT include data plots (bar charts, line charts, scatter plots) — those should remain as matplotlib.
660+
# Ask PLANNER (not visualizer) to decide what concept figures are needed
661+
analysis_output = self.run_agent("planner", f"""Based on the research described below, identify concept figures that should be
662+
AI-generated for this paper. These are architecture diagrams, system overviews, pipeline illustrations,
663+
mechanism diagrams — NOT data plots (bar charts, line charts etc. are handled separately).
645664
646-
For each concept figure, output a JSON block with this exact format:
665+
## Research Context
666+
{paper_context[:5000]}
667+
668+
## Your Task
669+
Identify 1-3 concept figures that would best illustrate this research. Every paper needs at least
670+
one system overview/architecture figure. Output a JSON block:
647671
648672
```json
649673
[
650674
{{
651675
"name": "fig_overview",
652-
"caption": "System architecture overview",
653-
"section_context": "Detailed description of what the figure should show, including all components, connections, data flows, and key metrics mentioned in the paper. Be as detailed as possible — the more context, the better the generated figure.",
676+
"caption": "System architecture overview showing the main components and data flow",
677+
"section_context": "Detailed description of what the figure should show all components, connections, stages, data flows. Be specific about the research system's structure.",
654678
"latex_label": "fig:overview",
655679
"placement": "full_width"
656680
}}
657681
]
658682
```
659683
660-
For each figure, you MUST decide the "placement" field:
661-
- "full_width": for complex figures — multi-stage pipelines, system architectures with many components, diagrams that need horizontal space. Uses `\\begin{{figure*}}` spanning all columns.
662-
- "single_column": for simpler figures — single concept with few components, small diagrams. Uses `\\begin{{figure}}` in one column.
663-
664-
Decision criteria: if the figure has 4+ components, multiple stages, or branching paths → "full_width". If it's a simple 2-3 component relationship → "single_column".
684+
Rules for "placement":
685+
- "full_width": for complex multi-stage pipelines, architectures with 4+ components
686+
- "single_column": for simple 2-3 component diagrams
665687
666-
Only include figures that:
667-
1. Are referenced in LaTeX but have no existing file, OR
668-
2. Are concept/architecture/mechanism diagrams that could be improved with AI generation
669-
670-
If no concept figures are needed, output: NO_CONCEPT_FIGURES
688+
You MUST output at least 1 figure (system overview). Output up to 3 figures maximum.
689+
Do NOT output NO_CONCEPT_FIGURES — every paper needs at least one architecture diagram.
671690
""", timeout=600)
672691

673-
if not analysis_output or "NO_CONCEPT_FIGURES" in analysis_output:
674-
self.log_step("No concept figures needed", "info")
675-
return
676-
677692
# Parse figure list from agent output
678693
figures = []
679694
try:
680-
json_match = re.search(r'\[[\s\S]*?\]', analysis_output)
695+
json_match = re.search(r'\[[\s\S]*?\]', analysis_output or "")
681696
if json_match:
682697
figures = json.loads(json_match.group())
683698
except (json.JSONDecodeError, AttributeError):
684-
self.log("Failed to parse concept figure list from agent output", "WARN")
685-
return
699+
self.log("Failed to parse concept figure list from planner output", "WARN")
686700

701+
# Fallback: if planner returned nothing, create a default system overview
687702
if not figures:
688-
return
689-
690-
# Read paper context for prompt generation
691-
paper_text = ""
692-
main_tex = self.latex_dir / "main.tex"
693-
if main_tex.exists():
694-
try:
695-
paper_text = main_tex.read_text()[:5000]
696-
except Exception:
697-
pass
703+
self.log("Planner did not suggest figures, creating default system overview", "INFO")
704+
figures = [{
705+
"name": "fig_overview",
706+
"caption": f"System overview of {title or 'the proposed approach'}",
707+
"section_context": idea[:2000] if idea else paper_context[:2000],
708+
"latex_label": "fig:overview",
709+
"placement": "full_width",
710+
}]
711+
712+
paper_text = paper_context
698713

699714
# Get geometry for sizing
700715
from ark.latex_geometry import get_geometry

0 commit comments

Comments
 (0)