Skip to content

Intelligent Merge workflow

The problem: partial agent outputs

When running targeted agents like correct or polish, the model may focus its modifications on specific sections, emitting an output round (such as r0/draft.tex or r1/draft.tex) containing only the modified fragments rather than the entire document. While this conserves processing time and token budget, attempting to compare this excerpt directly against your complete original source using latexdiff yields syntactically broken or unreadable diffs.

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 (possibly partial) Edited File to generate a new, complete document that incorporates the AI's changes.

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

spectral-gap.texBase · full
\section{Introduction}
Spectral graph theory studies…
\section{Preliminaries}
Let G be a d-regular graph…
\section{Spectral Gap}
The gap d − λ₂ governs…
r1/spectral-gap.texEdited · partial
% only the revised section
\section{Spectral Gap}
The gap d − λ₂ tightly bounds
the mixing time of the random walk…
% (other sections omitted)
mergeClaude Opus 5synthesizes a complete document
r0/spectral-gap.texComplete
\section{Introduction}
\section{Preliminaries}
\section{Spectral Gap}
The gap d − λ₂ tightly bounds
the mixing time of the random walk…
valid latexdiff input vs spectral-gap.tex

The full Base File and the agent's partial Edited File both feed the merge agent, which emits a complete merged document: the valid latexdiff input.

The merge workflow

Open the merge action from the "LaTeXDiffs" section ( LaTeXDiffs) in the main TeXRA interface:

LaTeXDiffs
Base1
spectral-gap.tex
Edited
2
r1/spectral-gap.tex

The LaTeXDiffs section: pick an Edited File, then select the highlighted Merge action in the Edited row. Merge writes into the agent panel's primary Input file.

  1. Select the base file: Merge uses the primary Input file selected in the agent panel (the first input file) as the document to merge changes into. The LaTeXDiffs "Base File" dropdown ( Base) is used by Diff, Compare, and Accept, not by Merge. If no input file is selected, TeXRA says "Choose both the input and edited files to merge."
  2. Select the edited file: Choose the document containing the suggested changes from the "Edited File" dropdown ( Edited).
  3. Select Merge: Select the "Merge" button () in the "Edited File" row. The merge runs on TeXRA's helper model, set from the Dashboard → Providers & Models tab. Models with strong reasoning (such as Claude Opus 5, GPT-6 / GPT-5.6, or Gemini 3.1 Pro) are recommended for complex merges.

There is a second entry point. In the ProgressBoard, each generated output file has a Merge edits action ("Merge edits into the workspace file") that runs the same merge agent against the corresponding workspace file, with no dropdowns to fill in.

Extension and desktop feature

The Intelligent Merge action pairs a base file with a separate Edited File, which the VS Code extension and the desktop app supply through their file pickers and the ProgressBoard. The texra run CLI command takes only --input/--context files and has no edited-file slot, so this merge workflow is not available from the CLI.

TeXRA then invokes the specialized merge agent:

  • The agent receives the base file, the edited file, and the configured helper model.
  • It analyzes both versions to identify meaningful differences.
  • It generates a new merge output (r0/<base filename> inside the run folder) containing the content of the base file updated with the accepted changes from the edited file.
  • You can monitor the process and results in the ProgressBoard.

What happens behind the scenes

  1. TeXRA sends both files to the configured helper model
  2. The model synthesizes a complete document preserving the Base File structure while incorporating Edited File changes
  3. TeXRA saves the result

The output: a complete, merged file

The merge process generates a new file in run storage, named after the base file:

r0/<base filename>.tex

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

This merged file is now ready to be compared against your original basename.tex with the latexdiff command (through the UI button, or automatically if configured) to visualize the changes the agent made.

Next steps

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