zed-industries/zed · error
Inline assistant stopped before completing `{REWRITE_SECTION
Error message
Inline assistant stopped before completing `{REWRITE_SECTION_TOOL_NAME}` ({reason:?}) What it means
Emitted in the streaming phase after the first rewrite_section tool has started: the completion stream stops (Stop event) before the in-progress rewrite completes. Unlike the pre-rewrite stop, this fires mid-edit; the offending condition is a premature Stop(reason) truncating the model's output while the rewrite payload is still incomplete.
Source
Thrown at crates/agent_ui/src/buffer_codegen.rs:1406
}
}
Ok(LanguageModelCompletionEvent::UsageUpdate(token_usage)) => {
*last_token_usage.lock() = token_usage;
None
}
Ok(LanguageModelCompletionEvent::ToolUseJsonParseError {
tool_name,
json_parse_error,
..
}) => Some(Err(anyhow!(
"Invalid input for inline assistant tool \
`{tool_name}`: {json_parse_error}"
)
.into())),
Ok(LanguageModelCompletionEvent::Stop(reason)) => {
let rewrite_complete = rewrite_state
.lock()
.as_ref()
.is_some_and(|state| state.is_input_complete);
if !rewrite_complete {
Some(Err(anyhow!(
"Inline assistant stopped before completing \
`{REWRITE_SECTION_TOOL_NAME}` ({reason:?})"
)
.into()))
} else if matches!(reason, StopReason::MaxTokens | StopReason::Refusal)
{
Some(Err(anyhow!(
"Inline assistant response was interrupted ({reason:?})"
)
.into()))
} else {
None
}
}
Ok(View on GitHub (pinned to 5a9b9558db)
Solutions
- Retry the inline assist — mid-rewrite truncation is usually transient
- Shrink the selection or instruction so the rewrite payload fits the output limit
- Use a model with a larger output budget for long rewrites
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/agent_ui/src/buffer_codegen.rs:1404 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20).
Data as JSON: /api/errors/5157e0a2de2e9992.
Report an issue: GitHub.