﻿# Continue Apply reconciles proposed code with the existing file

Continue separates generating an edit from applying proposed code to a file; the Apply template needs both original and new content to preserve unrelated code.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-continue-apply-role-input-contract/
Language: en

## Locate the failure after generation

A chat response proposes the correct validation condition, but applying it removes a neighboring helper. That failure may occur after the useful proposal was generated. Continue's [Apply role guide](https://docs.continue.dev/customize/model-roles/apply) describes a model stage that reconciles proposed code with existing content to produce a precise change. Distinguish the desired code from the final file diff before replacing the model responsible for every operation in the editor.

## Preserve both sides of the application task

The documented Apply template exposes `original_code` and `new_code`. The former supplies the existing file material; the latter supplies the proposed revision. A custom template that presents only the new fragment loses information needed to preserve surrounding behavior. For a targeted fix, make clear which condition changes and which adjacent code should remain. Avoid interpreting an abbreviated chat snippet as a complete replacement file unless the task actually requests that replacement.

## Separate Edit selection from Apply selection

The [Edit role](https://docs.continue.dev/customize/model-roles/edit) generates code from an edit instruction and has its own contextual variables. Its guide also describes falling back to the selected chat model when no edit model is specified. That fallback does not erase the separate Apply purpose. The [YAML reference](https://docs.continue.dev/reference) defines role assignments and role-specific templates; inspect the active configuration instead of assuming the visible chat selector identifies every stage involved.

## Review the resulting file against the proposal

Use a small example with a target condition and an unrelated helper that must survive. Compare the requested behavior, generated proposal and applied diff. If the proposal is wrong, investigate generation context. If the proposal is right but placement or preservation fails, investigate application inputs and template behavior. A syntactically valid final file can still have lost unrelated functionality, so syntax alone is an incomplete acceptance condition.

## Keep verification tied to the final artifact

Run the relevant check against the actual applied file rather than citing the correctness of the chat explanation. The [task-contract guide](/journal/learn-codex-task-contract/) defines the intended change and preservation requirements; [tool observations](/journal/learn-codex-tool-observation/) separate generated text, application and validation. Record the active role configuration when diagnosing a regression. This makes the repair actionable without turning a role label into a guarantee of correct placement.
