diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rs index 963e41cad0c68b..29734033974edc 100644 --- a/crates/acp_thread/src/acp_thread.rs +++ b/crates/acp_thread/src/acp_thread.rs @@ -2831,6 +2831,9 @@ impl AcpThread { } else { log::error!("Max tokens reached. Usage: {:?}", this.token_usage); } + if is_same_turn { + this.mark_pending_entries_as_canceled(cx); + } return Err(anyhow!(MaxOutputTokensError)); } @@ -2893,7 +2896,9 @@ impl AcpThread { } Err(e) => { Self::flush_streaming_text(&mut this.streaming_text_buffer, cx); - + if is_same_turn { + this.mark_pending_entries_as_canceled(cx); + } this.had_error = true; cx.emit(AcpThreadEvent::Error); log::error!("Error in run turn: {:?}", e);