zed-industries/zed · error
Inline assistant called `{REWRITE_SECTION_TOOL_NAME}` multip
Error message
Inline assistant called `{REWRITE_SECTION_TOOL_NAME}` multiple times What it means
Raised by the inline assistant's tool-use processor when the model emits a second rewrite_section tool call while a previous rewrite is already in progress. The protocol for inline edits allows exactly one rewrite_section invocation per response; a duplicate indicates the model violated that contract. The offending input is the redundant REWRITE_SECTION tool call in the completion stream.
Source
Thrown at crates/agent_ui/src/buffer_codegen.rs:1201
}
let rewrite_state: Arc<Mutex<Option<RewriteState>>> = Arc::new(Mutex::new(None));
let process_rewrite_state = rewrite_state.clone();
let process_tool_use =
move |tool_use: LanguageModelToolUse| -> Result<Option<ToolUseOutput>> {
match tool_use.name.as_ref() {
REWRITE_SECTION_TOOL_NAME => {
let input = match tool_use.input.parse::<RewriteSectionInput>() {
Ok(input) => input,
Err(_) if !tool_use.is_input_complete => return Ok(None),
Err(error) => {
return Err(error.context(format!(
"invalid input for `{REWRITE_SECTION_TOOL_NAME}` tool"
)));
}
};
let mut rewrite_state = process_rewrite_state.lock();
if let Some(state) = rewrite_state.as_ref()
&& state.tool_use_id != tool_use.id
{
return Err(anyhow!(
"Inline assistant called `{REWRITE_SECTION_TOOL_NAME}` \
multiple times"
));
}
let state = rewrite_state.get_or_insert_with(|| RewriteState {
tool_use_id: tool_use.id,
chars_read: 0,
is_input_complete: false,
});
let Some(text_slice) = input.replacement_text.get(state.chars_read..)
else {
return Ok(None);
};
let text = text_slice.to_string();
state.chars_read = input.replacement_text.len();View on GitHub (pinned to 5a9b9558db)
Solutions
- Retry the inline assist so the model produces a single rewrite_section call
- Rephrase the instruction so only one contiguous rewrite is needed
- Split very large edits into multiple sequential inline assists
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/agent_ui/src/buffer_codegen.rs:1199 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/491b07cdc31e2004.
Report an issue: GitHub.