Skip to content

Intelligent Merge Workflow

The Problem: Partial Agent Outputs

When you run agents like correct or polish, the AI might intelligently focus its changes on specific sections, potentially resulting in an output file (*_r0_*.tex or *_r1_*.tex) that only contains the modified parts, not the entire document. While this saves processing time and tokens, comparing this partial output directly against your full original document using latexdiff wouldn't produce a meaningful result.

The Solution: Intelligent Merge Button

TeXRA's Intelligent Merge workflow solves this problem. It uses an LLM to combine your original Base File with the agent's (potentially partial) Edited File to generate a new, complete document that incorporates the AI's changes.

This generated full document can then be cleanly compared against your original base file using latexdiff.

Using the Merge Button

The primary way to use this feature is via the UI button in the "LaTeXdiffs" section:

  1. Select Base File: Choose your original, complete document (e.g., paper.tex).
  2. Select Edited File: Choose the output file generated by another TeXRA agent (e.g., paper_polish_r0_sonnet37.tex).
  3. Click Merge: Press the "Merge" button ().

What Happens Behind the Scenes

When you click the Merge button (prepare for some AI wizardry):

  1. TeXRA sends the content of both the Base File and the Edited File to a selected AI model (defaults can be configured in settings, sonnet37 is often a good choice).
  2. The model is instructed to intelligently synthesize a new, complete document that preserves the structure and unchanged content of the Base File while incorporating the modifications present in the Edited File.
  3. TeXRA saves this synthesized result.

The Output: A Complete, Merged File

The merge process generates a new file, typically named following the pattern:

basename_agent_rX_full_model.tex

(e.g., paper_polish_r0_full_sonnet37.tex)

This _full_ file contains the complete document content, incorporating the changes from the agent's output.

Crucially, this _full_*.tex file is now ready to be compared against your original basename.tex using the latexdiff command (either via the UI button or automatically if configured) to clearly visualize the changes the agent effectively made.

Advanced Control (Using merge Agent Directly)

While the Merge button handles the most common scenario, you can achieve more fine-grained control for complex merges by:

  1. Selecting the merge agent directly in the main TeXRA panel.
  2. Providing specific instructions on how to prioritize content from the Base vs. Edited files.
  3. Selecting the Base and Edited files as Input/Edited files in the main panel.
  4. Executing the agent.

This approach is generally needed only for complex scenarios beyond integrating a standard agent's output.

Next Steps

  • LaTeX Diff: Learn how to use latexdiff to compare the merged (_full_) file with your original.
  • Built-in Agents: Review the agents whose outputs you might want to merge.