Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
eval: Fix stalling on tool confirmation (#28786)
Agus Zubiagaff4334efc72c
diff --git a/Cargo.lock b/Cargo.lockindex e2f767145f4..bb4d080ac23 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4877,7 +4877,6 @@ version = "0.1.0"dependencies = ["agent","anyhow",- "assistant_settings","assistant_tool","assistant_tools","async-watch",diff --git a/crates/eval/Cargo.toml b/crates/eval/Cargo.tomlindex 42597393a12..235ae22c846 100644--- a/crates/eval/Cargo.toml+++ b/crates/eval/Cargo.toml@@ -8,7 +8,6 @@ edition.workspace = trueagent.workspace = trueanyhow.workspace = trueasync-watch.workspace = true-assistant_settings.workspace = trueassistant_tool.workspace = trueassistant_tools.workspace = truechrono.workspace = truediff --git a/crates/eval/runner_settings.json b/crates/eval/runner_settings.jsonnew file mode 100644index 00000000000..53d853023c7--- /dev/null+++ b/crates/eval/runner_settings.json@@ -0,0 +1,6 @@+{+ "assistant": {+ "always_allow_tool_actions": true,+ "version": "2"+ }+}diff --git a/crates/eval/src/eval.rs b/crates/eval/src/eval.rsindex 2e69b12845b..f78293dbf1f 100644--- a/crates/eval/src/eval.rs+++ b/crates/eval/src/eval.rs@@ -1,6 +1,5 @@mod example;-use assistant_settings::AssistantSettings;use client::{Client, ProxySettings, UserStore};pub(crate) use example::*;@@ -10,7 +9,7 @@ use clap::Parser;use extension::ExtensionHostProxy;use futures::future;use gpui::http_client::{Uri, read_proxy_from_env};-use gpui::{App, AppContext, Application, AsyncApp, Entity, SemanticVersion, Task};+use gpui::{App, AppContext, Application, AsyncApp, Entity, SemanticVersion, Task, UpdateGlobal};use gpui_tokio::Tokio;use language::LanguageRegistry;use language_model::{@@ -390,13 +389,10 @@ pub fn init(cx: &mut App) -> Arc<AgentAppState> {let prompt_builder = PromptBuilder::load(fs.clone(), stdout_is_a_pty, cx);agent::init(fs.clone(), client.clone(), prompt_builder.clone(), cx);- AssistantSettings::override_global(- AssistantSettings {- always_allow_tool_actions: true,- ..AssistantSettings::get_global(cx).clone()- },- cx,- );+ SettingsStore::update_global(cx, |store, cx| {+ store.set_user_settings(include_str!("../runner_settings.json"), cx)+ })+ .unwrap();Arc::new(AgentAppState {languages,diff --git a/crates/eval/src/example.rs b/crates/eval/src/example.rsindex 7f4b6de3498..70140a360aa 100644--- a/crates/eval/src/example.rs+++ b/crates/eval/src/example.rs@@ -330,7 +330,11 @@ impl Example {Ok(StopReason::MaxTokens) => {return Err(anyhow!("Exceeded maximum tokens"));}- Ok(StopReason::ToolUse) => {}+ Ok(StopReason::ToolUse) => {+ if std::env::var("ZED_EVAL_DEBUG").is_ok() {+ println!("{}StopReason: Tool use", log_prefix);+ }+ }Err(error) => {return Err(anyhow!(error.clone()));}@@ -371,7 +375,20 @@ impl Example {}})?;}- _ => {}+ ThreadEvent::ToolConfirmationNeeded => {+ panic!("{}Bug: Tool confirmation should not be required in eval", log_prefix);+ },+ ThreadEvent::StreamedCompletion |+ ThreadEvent::MessageAdded(_) |+ ThreadEvent::MessageEdited(_) |+ ThreadEvent::MessageDeleted(_) |+ ThreadEvent::SummaryChanged |+ ThreadEvent::SummaryGenerated |+ ThreadEvent::CheckpointChanged => {+ if std::env::var("ZED_EVAL_DEBUG").is_ok() {+ println!("{}Event: {:#?}", log_prefix, event);+ }+ }}output_file.flush().log_err();@@ -387,16 +404,22 @@ impl Example {event_handler_task.await?;+ println!("{}Stopped", this.log_prefix);+if let Some((_, lsp_store)) = lsp_open_handle_and_store.as_ref() {wait_for_lang_server(lsp_store, this.log_prefix.clone(), cx).await?;}+ println!("{}Getting repository diff", this.log_prefix);let repository_diff = this.repository_diff().await?;++ println!("{}Getting diagnostics", this.log_prefix);let diagnostics = cx.update(move |cx| {cx.spawn(async move |cx| query_lsp_diagnostics(project, cx).await)})?.await?;+ println!("{}Got diagnostics", this.log_prefix);drop(subscription);drop(lsp_open_handle_and_store);