zed-industries/zed · error

Inline assistant stopped before completing `{REWRITE_SECTION

Error message

Inline assistant stopped before completing `{REWRITE_SECTION_TOOL_NAME}` or `{FAILURE_MESSAGE_TOOL_NAME}` ({reason:?})

What it means

Emitted when the inline assistant's completion stream ends with a Stop event before the model finished either the rewrite_section or failure_message tool call. The response was cut short by a stop reason other than normal completion; the offending condition is the premature Stop(reason) on the language-model stream, leaving the edit protocol incomplete.

Source

Thrown at crates/agent_ui/src/buffer_codegen.rs:1314

                                    failure_complete |= is_input_complete;
                                    if is_input_complete
                                        && codegen
                                            .update(cx, |this, cx| {
                                                this.failure = Some(message);
                                                cx.notify();
                                            })
                                            .is_err()
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    Ok(LanguageModelCompletionEvent::UsageUpdate(token_usage)) => {
                        *last_token_usage.lock() = token_usage;
                    }
                    Ok(LanguageModelCompletionEvent::Stop(reason)) => {
                        if !failure_complete {
                            finish_with_status(
                                CodegenStatus::Error(anyhow!(
                                    "Inline assistant stopped before completing \
                                     `{REWRITE_SECTION_TOOL_NAME}` or \
                                     `{FAILURE_MESSAGE_TOOL_NAME}` ({reason:?})"
                                )),
                                cx,
                            );
                        } else if matches!(reason, StopReason::MaxTokens | StopReason::Refusal) {
                            finish_with_status(
                                CodegenStatus::Error(anyhow!(
                                    "Inline assistant response was interrupted ({reason:?})"
                                )),
                                cx,
                            );
                        } else {
                            finish_with_status(CodegenStatus::Done, cx);

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Retry the inline assist — premature stops are often transient
  2. Reduce the size of the selection being rewritten
  3. Switch to a model with a larger output limit if the stop reason is length-related
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/agent_ui/src/buffer_codegen.rs:1312 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/f124a06b8cf2242a. Report an issue: GitHub.