Delete the legacy agent loop (#12760)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1508,7 +1508,6 @@ async fn handle_mcp_probe(extension_command: String, script_path: Option<String>
|
||||
std::sync::Arc::new(SessionManager::instance()),
|
||||
goose::config::permission::PermissionManager::instance(),
|
||||
None,
|
||||
config.get_goose_mode().unwrap_or_default(),
|
||||
true,
|
||||
GoosePlatform::GooseCli,
|
||||
);
|
||||
@@ -1557,7 +1556,7 @@ async fn handle_mcp_probe(extension_command: String, script_path: Option<String>
|
||||
std::env::current_dir()?,
|
||||
"MCP Probe".to_string(),
|
||||
goose::session::session_manager::SessionType::Hidden,
|
||||
agent.config.goose_mode,
|
||||
config.get_goose_mode().unwrap_or_default(),
|
||||
)
|
||||
.await?;
|
||||
let session_id = session.id.as_str();
|
||||
|
||||
@@ -1794,7 +1794,7 @@ pub async fn configure_tool_permissions_dialog() -> anyhow::Result<()> {
|
||||
std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(".")),
|
||||
"Tool Permission Configuration".to_string(),
|
||||
SessionType::Hidden,
|
||||
agent.config.goose_mode,
|
||||
config.get_goose_mode().unwrap_or_default(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -689,8 +689,12 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
let session_id =
|
||||
resolve_session_id(&session_config, &session_manager, agent.config.goose_mode).await;
|
||||
let session_id = resolve_session_id(
|
||||
&session_config,
|
||||
&session_manager,
|
||||
config.get_goose_mode().unwrap_or_default(),
|
||||
)
|
||||
.await;
|
||||
|
||||
if session_config.container.is_some() {
|
||||
session_manager
|
||||
@@ -824,7 +828,7 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
|
||||
});
|
||||
|
||||
agent
|
||||
.update_goose_mode(agent.config.goose_mode, &session_id)
|
||||
.update_goose_mode(config.get_goose_mode().unwrap_or_default(), &session_id)
|
||||
.await
|
||||
.unwrap_or_else(|e| {
|
||||
output::render_error(&format!("Failed to set session mode: {}", e));
|
||||
@@ -883,7 +887,6 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
|
||||
session_config.scheduled_job_id.clone(),
|
||||
session_config.max_turns,
|
||||
edit_mode,
|
||||
recipe.and_then(|r| r.retry.clone()),
|
||||
session_config.output_format.clone(),
|
||||
session_config.stats,
|
||||
session_config.interactive,
|
||||
|
||||
@@ -33,7 +33,6 @@ use goose::utils::safe_truncate;
|
||||
use anyhow::Result;
|
||||
use completion::GooseCompleter;
|
||||
use goose::agents::extension::{Envs, ExtensionConfig, PLATFORM_EXTENSIONS};
|
||||
use goose::agents::types::RetryConfig;
|
||||
use goose::agents::{
|
||||
context_management_unsupported_message, Agent, SessionConfig, COMPACT_TRIGGERS,
|
||||
};
|
||||
@@ -241,7 +240,6 @@ pub struct CliSession {
|
||||
scheduled_job_id: Option<String>,
|
||||
max_turns: Option<u32>,
|
||||
edit_mode: Option<EditMode>,
|
||||
retry_config: Option<RetryConfig>,
|
||||
output_format: String,
|
||||
stats: bool,
|
||||
/// Background extension loader; drained exclusively by
|
||||
@@ -292,7 +290,6 @@ impl CliSession {
|
||||
scheduled_job_id: Option<String>,
|
||||
max_turns: Option<u32>,
|
||||
edit_mode: Option<EditMode>,
|
||||
retry_config: Option<RetryConfig>,
|
||||
output_format: String,
|
||||
stats: bool,
|
||||
refresh_completions: bool,
|
||||
@@ -330,7 +327,6 @@ impl CliSession {
|
||||
scheduled_job_id,
|
||||
max_turns,
|
||||
edit_mode,
|
||||
retry_config,
|
||||
output_format,
|
||||
stats,
|
||||
extension_loading,
|
||||
@@ -559,10 +555,7 @@ impl CliSession {
|
||||
|
||||
/// Start an interactive session, optionally with an initial message
|
||||
pub async fn interactive(&mut self, prompt: Option<String>) -> Result<()> {
|
||||
let banners = self
|
||||
.agent
|
||||
.emit_hook_with_banners(goose::hooks::HookEvent::SessionStart, &self.session_id)
|
||||
.await;
|
||||
let banners = self.agent.emit_session_start(&self.session_id).await?;
|
||||
if !banners.is_empty() {
|
||||
output::display_banner(&banners);
|
||||
}
|
||||
@@ -1125,23 +1118,21 @@ impl CliSession {
|
||||
}
|
||||
};
|
||||
|
||||
let extension_configs = self.agent.get_extension_configs().await;
|
||||
let extension_configs = self.agent.get_extension_configs(&self.session_id).await;
|
||||
|
||||
self.agent
|
||||
.emit_hook(goose::hooks::HookEvent::SessionEnd, &self.session_id)
|
||||
.await;
|
||||
|
||||
self.agent.discard_pending_steers(&self.session_id).await;
|
||||
self.agent.extension_manager.release(&self.session_id).await;
|
||||
self.agent.config.providers.release(&self.session_id);
|
||||
|
||||
self.session_id = new_session_id;
|
||||
self.messages.clear();
|
||||
|
||||
if let Err(e) = self
|
||||
.agent
|
||||
.update_goose_mode(self.agent.goose_mode().await, &self.session_id)
|
||||
.await
|
||||
{
|
||||
let mode = self.agent.goose_mode(&self.session_id).await?;
|
||||
if let Err(e) = self.agent.update_goose_mode(mode, &self.session_id).await {
|
||||
output::render_error(&format!("Failed to apply the current mode: {}", e));
|
||||
}
|
||||
|
||||
@@ -1149,14 +1140,6 @@ impl CliSession {
|
||||
output::goose_mode_message("Restarting extensions for the new session...");
|
||||
}
|
||||
|
||||
// MCP clients pin themselves to the first session id they see a request for, so
|
||||
// extensions must be torn down and re-added under the new session id.
|
||||
for name in self.agent.list_extensions().await {
|
||||
if let Err(e) = self.agent.remove_extension(&name, &self.session_id).await {
|
||||
output::render_extension_error(&name, &e.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
let mut unavailable = Vec::new();
|
||||
for config in extension_configs {
|
||||
let name = config.name();
|
||||
@@ -1185,8 +1168,7 @@ impl CliSession {
|
||||
let session_manager = &self.agent.config.session_manager;
|
||||
let old_session = session_manager.get_session(&self.session_id, false).await?;
|
||||
let new_session_id =
|
||||
create_successor_session(session_manager, &old_session, self.agent.goose_mode().await)
|
||||
.await?;
|
||||
create_successor_session(session_manager, &old_session, old_session.goose_mode).await?;
|
||||
self.agent.persist_extension_state(&new_session_id).await?;
|
||||
Ok(new_session_id)
|
||||
}
|
||||
@@ -1311,7 +1293,6 @@ impl CliSession {
|
||||
id: self.session_id.clone(),
|
||||
schedule_id: self.scheduled_job_id.clone(),
|
||||
max_turns: self.max_turns,
|
||||
retry_config: self.retry_config.clone(),
|
||||
};
|
||||
let user_message = self
|
||||
.messages
|
||||
@@ -1330,7 +1311,6 @@ impl CliSession {
|
||||
.reply(
|
||||
user_message.clone(),
|
||||
session_config.clone(),
|
||||
goose::agents::state_machine::enabled(),
|
||||
Some(cancel_token.clone()),
|
||||
)
|
||||
.await?;
|
||||
@@ -1455,7 +1435,7 @@ impl CliSession {
|
||||
self.messages.push(response_message.clone());
|
||||
// Elicitation responses return an empty stream - the response
|
||||
// unblocks the waiting tool call via ActionRequiredManager
|
||||
let _ = self.agent.reply(response_message, session_config.clone(), goose::agents::state_machine::enabled(), Some(cancel_token.clone())).await?;
|
||||
let _ = self.agent.reply(response_message, session_config.clone(), Some(cancel_token.clone())).await?;
|
||||
if should_cancel {
|
||||
cancel_token_clone.cancel();
|
||||
drop(stream);
|
||||
@@ -3212,7 +3192,6 @@ mod tests {
|
||||
Arc::new(session_manager),
|
||||
Arc::new(goose::config::PermissionManager::new(data_dir.clone())),
|
||||
None,
|
||||
GooseMode::default(),
|
||||
// Disable background session naming so the test agent starts no
|
||||
// provider-dependent tasks.
|
||||
true,
|
||||
@@ -3234,7 +3213,6 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
"text".to_string(),
|
||||
false,
|
||||
refresh_completions,
|
||||
|
||||
Reference in New Issue
Block a user