{"record":{"id":"491b07cdc31e2004","repo":"zed-industries/zed","slug":"inline-assistant-called-rewrite-section-tool-nam","errorCode":null,"errorMessage":"Inline assistant called `{REWRITE_SECTION_TOOL_NAME}` multiple times","messagePattern":"Inline assistant called `(.+?)` multiple times","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/buffer_codegen.rs","lineNumber":1201,"sourceCode":"            }\n\n            let rewrite_state: Arc<Mutex<Option<RewriteState>>> = Arc::new(Mutex::new(None));\n            let process_rewrite_state = rewrite_state.clone();\n            let process_tool_use =\n                move |tool_use: LanguageModelToolUse| -> Result<Option<ToolUseOutput>> {\n                    match tool_use.name.as_ref() {\n                        REWRITE_SECTION_TOOL_NAME => {\n                            let input = match tool_use.input.parse::<RewriteSectionInput>() {\n                                Ok(input) => input,\n                                Err(_) if !tool_use.is_input_complete => return Ok(None),\n                                Err(error) => {\n                                    return Err(error.context(format!(\n                                        \"invalid input for `{REWRITE_SECTION_TOOL_NAME}` tool\"\n                                    )));\n                                }\n                            };\n                            let mut rewrite_state = process_rewrite_state.lock();\n                            if let Some(state) = rewrite_state.as_ref()\n                                && state.tool_use_id != tool_use.id\n                            {\n                                return Err(anyhow!(\n                                    \"Inline assistant called `{REWRITE_SECTION_TOOL_NAME}` \\\n                                     multiple times\"\n                                ));\n                            }\n                            let state = rewrite_state.get_or_insert_with(|| RewriteState {\n                                tool_use_id: tool_use.id,\n                                chars_read: 0,\n                                is_input_complete: false,\n                            });\n                            let Some(text_slice) = input.replacement_text.get(state.chars_read..)\n                            else {\n                                return Ok(None);\n                            };\n                            let text = text_slice.to_string();\n                            state.chars_read = input.replacement_text.len();","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/agent_ui/src/buffer_codegen.rs#L1183-L1219","documentation":"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.","triggerScenarios":"Thrown at crates/agent_ui/src/buffer_codegen.rs:1199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}