zed-industries/zed · error
missing <|fim_middle|> in model output
Error message
missing <|fim_middle|> in model output
What it means
apply_variable_edit splits the model output on the <|fim_middle|> token; its absence means the output is not in the expected prefix/middle/suffix FIM shape, so there is no boundary between context lines and new text.
Source
Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4392
///
/// The model output has the form:
///
/// - prefix context lines
/// - `<|fim_middle|>`
/// - new text
/// - `<|fim_suffix|>`
/// - suffix context lines
///
/// We locate the prefix/suffix context lines in the original text and replace
/// everything between them with the new text.
pub fn apply_variable_edit(
context: &str,
model_output: &str,
) -> Result<(Range<usize>, String)> {
let (prefix_context, rest) = model_output
.split_once("<|fim_middle|>\n")
.or_else(|| model_output.split_once("<|fim_middle|>"))
.ok_or_else(|| anyhow::anyhow!("missing <|fim_middle|> in model output"))?;
let (new_text, suffix_context) = rest
.split_once("<|fim_suffix|>\n")
.or_else(|| rest.split_once("<|fim_suffix|>"))
.unwrap_or((rest, ""));
let suffix_context = if prefix_context.is_empty() && !suffix_context.is_empty() {
suffix_context.strip_prefix('\n').unwrap_or(suffix_context)
} else {
suffix_context
};
let prefix_offset = find_substring_at_line_boundary(context, prefix_context)
.ok_or_else(|| anyhow!("could not locate prefix lines"))?
+ prefix_context.len();
let suffix_offset = if suffix_context.is_empty() {
context.len()
} else {View on GitHub (pinned to f4178619ac)
Solutions
- Reject the output and re-request the edit in proper FIM variable-edit format
- Check for token-stripping post-processing that removed the fim_middle marker before parsing
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4392 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/e561a2ffb6bfde53.
Report an issue: GitHub.