diff --git a/crates/goose-cli/src/session/mod.rs b/crates/goose-cli/src/session/mod.rs index fb0fd4ac6..381ca1a24 100644 --- a/crates/goose-cli/src/session/mod.rs +++ b/crates/goose-cli/src/session/mod.rs @@ -1329,6 +1329,7 @@ impl CliSession { .reply( user_message.clone(), session_config.clone(), + goose::agents::state_machine::enabled(), Some(cancel_token.clone()), ) .await?; @@ -1452,7 +1453,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(), Some(cancel_token.clone())).await?; + let _ = self.agent.reply(response_message, session_config.clone(), goose::agents::state_machine::enabled(), Some(cancel_token.clone())).await?; if should_cancel { cancel_token_clone.cancel(); drop(stream); diff --git a/crates/goose/examples/agent.rs b/crates/goose/examples/agent.rs index 9e12db22d..bba1eab1b 100644 --- a/crates/goose/examples/agent.rs +++ b/crates/goose/examples/agent.rs @@ -57,7 +57,14 @@ async fn main() -> anyhow::Result<()> { let user_message = Message::user() .with_text("can you summarize the readme.md in this dir using just a haiku?"); - let mut stream = agent.reply(user_message, session_config, None).await?; + let mut stream = agent + .reply( + user_message, + session_config, + goose::agents::state_machine::enabled(), + None, + ) + .await?; while let Some(Ok(AgentEvent::Message(message))) = stream.next().await { println!("{}", serde_json::to_string_pretty(&message)?); diff --git a/crates/goose/src/acp/server.rs b/crates/goose/src/acp/server.rs index fd2e1a791..7620826f2 100644 --- a/crates/goose/src/acp/server.rs +++ b/crates/goose/src/acp/server.rs @@ -2310,6 +2310,13 @@ impl GooseAcpAgent { } let user_message = Self::convert_acp_prompt_to_message(&args.prompt); + let use_state_machine = args + .meta + .as_ref() + .and_then(|meta| meta.get("goose")) + .and_then(|goose| goose.get("unrolledAgentLoop")) + .and_then(|value| value.as_bool()) + .unwrap_or_else(crate::agents::state_machine::enabled); let session_config = SessionConfig { id: session_id.clone(), schedule_id: None, @@ -2318,7 +2325,12 @@ impl GooseAcpAgent { }; let stream = match agent - .reply(user_message, session_config, Some(cancel_token.clone())) + .reply( + user_message, + session_config, + use_state_machine, + Some(cancel_token.clone()), + ) .await { Ok(stream) => stream, diff --git a/crates/goose/src/acp/server/config.rs b/crates/goose/src/acp/server/config.rs index 40dd51ce4..31ad339a3 100644 --- a/crates/goose/src/acp/server/config.rs +++ b/crates/goose/src/acp/server/config.rs @@ -36,7 +36,7 @@ impl GooseAcpAgent { Ok(value) => value, Err(crate::config::ConfigError::NotFound(_)) => serde_json::Value::Null, Err(e) => { - return Err(agent_client_protocol::Error::internal_error().data(e.to_string())) + return Err(agent_client_protocol::Error::internal_error().data(e.to_string())); } }; values.push(PreferenceValue { key, value }); @@ -88,7 +88,7 @@ impl GooseAcpAgent { Ok(value) => value, Err(crate::config::ConfigError::NotFound(_)) => serde_json::Value::Null, Err(e) => { - return Err(agent_client_protocol::Error::internal_error().data(e.to_string())) + return Err(agent_client_protocol::Error::internal_error().data(e.to_string())); } }; Ok(ConfigReadResponse { value }) diff --git a/crates/goose/src/agents/agent.rs b/crates/goose/src/agents/agent.rs index 53746a1f7..8139fb14e 100644 --- a/crates/goose/src/agents/agent.rs +++ b/crates/goose/src/agents/agent.rs @@ -342,10 +342,6 @@ fn agent_visible_message_text(message: &Message) -> String { message.agent_visible_content().as_concat_text() } -fn user_visible_message_text(message: &Message) -> String { - message.user_visible_content().as_concat_text() -} - fn attach_turn_usage( messages: &mut Conversation, usage: &ProviderUsage, @@ -1616,6 +1612,27 @@ impl Agent { false } + pub async fn handle_confirmation( + &self, + session_id: &str, + request_id: String, + confirmation: PermissionConfirmation, + ) { + if self + .try_route_tool_confirmation_to_provider(&request_id, &confirmation) + .await + { + return; + } + if !self + .tool_confirmation_router + .deliver(session_id, &request_id, confirmation) + .await + { + error!("Failed to deliver confirmation"); + } + } + pub async fn supports_action_required_permissions(&self) -> bool { if let Some(provider) = self.provider.lock().await.as_ref() { return provider.permission_routing() == PermissionRouting::ActionRequired; @@ -1997,7 +2014,7 @@ impl Agent { } #[instrument( - skip(self, user_message, session_config, cancel_token), + skip(self, user_message, session_config, use_state_machine, cancel_token), fields( user_message, trace_input, @@ -2015,11 +2032,17 @@ impl Agent { &self, user_message: Message, session_config: SessionConfig, + use_state_machine: bool, cancel_token: Option, ) -> Result>> { let reply_span = tracing::Span::current(); let events = self - .reply_impl(user_message, session_config, cancel_token) + .reply_impl( + user_message, + session_config, + use_state_machine, + cancel_token, + ) .await?; // This is the single live-event identity boundary. Callers that intentionally stream @@ -2035,6 +2058,7 @@ impl Agent { &self, user_message: Message, session_config: SessionConfig, + use_state_machine: bool, cancel_token: Option, ) -> Result>> { let user_message = user_message.with_generated_id_if_missing(); @@ -2087,10 +2111,7 @@ impl Agent { } } - if super::state_machine::enabled() - || super::state_machine::bang_shell_command(&user_visible_message_text(&user_message)) - .is_some() - { + if use_state_machine { tracing::info!("dispatching reply via experimental state machine"); return self .reply_with_state_machine(user_message, session_config, cancel_token) @@ -4985,7 +5006,12 @@ echo start >> "$PLUGIN_ROOT/hook.log" }; let reply_stream = agent - .reply(Message::user().with_text("hi"), session_config, None) + .reply( + Message::user().with_text("hi"), + session_config, + crate::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); let mut emitted_refusal_id = None; @@ -5095,6 +5121,7 @@ echo start >> "$PLUGIN_ROOT/hook.log" .reply( Message::user().with_text("input-super-secret-token"), session_config, + false, None, ) .await?; @@ -5178,7 +5205,12 @@ echo start >> "$PLUGIN_ROOT/hook.log" retry_config: None, }; let reply_stream = agent - .reply(Message::user().with_text(text), session_config, None) + .reply( + Message::user().with_text(text), + session_config, + crate::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -5314,6 +5346,7 @@ echo start >> "$PLUGIN_ROOT/hook.log" .reply( Message::user().with_content(user_only_content), session_config, + crate::agents::state_machine::enabled(), None, ) .await?; @@ -5340,6 +5373,7 @@ echo start >> "$PLUGIN_ROOT/hook.log" .reply( Message::user().with_text("agent-visible"), visible_session_config, + crate::agents::state_machine::enabled(), None, ) .await?; @@ -5359,6 +5393,7 @@ echo start >> "$PLUGIN_ROOT/hook.log" .reply( Message::user().with_text("second-agent-visible"), final_session_config, + crate::agents::state_machine::enabled(), None, ) .await?; @@ -5786,16 +5821,11 @@ echo start >> "$PLUGIN_ROOT/hook.log" } } - const RECORD_PRE_SCRIPT: &str = - "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/pre.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/pre.log\"\nexit 0\n"; - const RECORD_RESULT_SCRIPT: &str = - "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/result.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/result.log\"\nexit 0\n"; - const RECORD_POST_SCRIPT: &str = - "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/post.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/post.log\"\nexit 0\n"; - const RECORD_POST_FAILURE_SCRIPT: &str = - "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/postfail.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/postfail.log\"\nexit 0\n"; - const DENY_AND_RECORD_SCRIPT: &str = - "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/pre.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/pre.log\"\necho \"blocked by test policy\" >&2\nexit 2\n"; + const RECORD_PRE_SCRIPT: &str = "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/pre.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/pre.log\"\nexit 0\n"; + const RECORD_RESULT_SCRIPT: &str = "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/result.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/result.log\"\nexit 0\n"; + const RECORD_POST_SCRIPT: &str = "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/post.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/post.log\"\nexit 0\n"; + const RECORD_POST_FAILURE_SCRIPT: &str = "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/postfail.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/postfail.log\"\nexit 0\n"; + const DENY_AND_RECORD_SCRIPT: &str = "#!/bin/sh\ncat >> \"$PLUGIN_ROOT/pre.log\"\nprintf '\\n' >> \"$PLUGIN_ROOT/pre.log\"\necho \"blocked by test policy\" >&2\nexit 2\n"; /// Logs its stdin like the others, writes nothing to stdout, and exits /// non-zero. That is a hook that ran but never returned a decision. const ABNORMAL_EXIT_AND_RECORD_SCRIPT: &str = diff --git a/crates/goose/src/agents/platform_extensions/orchestrator.rs b/crates/goose/src/agents/platform_extensions/orchestrator.rs index 265a2e745..9392148f3 100644 --- a/crates/goose/src/agents/platform_extensions/orchestrator.rs +++ b/crates/goose/src/agents/platform_extensions/orchestrator.rs @@ -556,7 +556,12 @@ impl OrchestratorClient { }; let mut stream = agent - .reply(user_message, session_config, Some(cancel_token.clone())) + .reply( + user_message, + session_config, + crate::agents::state_machine::enabled(), + Some(cancel_token.clone()), + ) .await .map_err(|e| format!("Failed to start reply: {}", e))?; diff --git a/crates/goose/src/agents/state_machine/mod.rs b/crates/goose/src/agents/state_machine/mod.rs index 63ac285bd..7cbfc1855 100644 --- a/crates/goose/src/agents/state_machine/mod.rs +++ b/crates/goose/src/agents/state_machine/mod.rs @@ -49,7 +49,6 @@ pub(crate) use tool_confirmation::{ }; pub(super) use inference_preparation::GooseInferenceRequestPreparer; -pub(crate) use ops_bang_shell::bang_shell_command; pub(super) use ops_bang_shell::BangShellOperation; pub(super) use ops_compaction::CompactionOperation; pub(super) use ops_doctor::DoctorOperation; diff --git a/crates/goose/src/agents/state_machine/tests/agent_reply.rs b/crates/goose/src/agents/state_machine/tests/agent_reply.rs index 8a0d5be53..21f04b8d3 100644 --- a/crates/goose/src/agents/state_machine/tests/agent_reply.rs +++ b/crates/goose/src/agents/state_machine/tests/agent_reply.rs @@ -147,6 +147,7 @@ async fn state_machine_confirmation_through_agent_resumes_tool_call() -> Result< .reply( Message::user().with_text("add one"), session_config.clone(), + true, Some(CancellationToken::new()), ) .await?; @@ -325,8 +326,7 @@ async fn reply_streams_the_turn_and_ends() -> Result<()> { } #[tokio::test] -async fn bang_shell_uses_the_state_machine_when_the_flag_is_disabled() -> Result<()> { - let _guard = env_lock::lock_env([("GOOSE_STATE_MACHINE", None::<&str>)]); +async fn bang_shell_uses_state_machine_when_explicitly_enabled() -> Result<()> { let (agent, api, session_id, _temp_dir) = agent_with_dummy_api().await?; let session_config = SessionConfig { id: session_id, @@ -338,6 +338,7 @@ async fn bang_shell_uses_the_state_machine_when_the_flag_is_disabled() -> Result .reply( Message::user().with_text("!echo hello"), session_config, + true, Some(CancellationToken::new()), ) .await?; @@ -375,6 +376,7 @@ async fn reply_messages( max_turns: Some(2), retry_config: None, }, + crate::agents::state_machine::enabled(), Some(CancellationToken::new()), ) .await?; @@ -518,9 +520,15 @@ async fn assert_bang_shell_uses_only_user_visible_content() -> Result<()> { } #[tokio::test] -async fn bang_shell_visibility_is_enforced_when_state_machine_is_disabled() -> Result<()> { +async fn bang_shell_not_executed_in_legacy_loop() -> Result<()> { let _guard = env_lock::lock_env([("GOOSE_STATE_MACHINE", None::<&str>)]); - assert_bang_shell_uses_only_user_visible_content().await + let (agent, api, session_id, _temp_dir) = agent_with_dummy_api().await?; + api.on("!echo hello").reply("treated as text"); + let messages = + reply_messages(&agent, session_id, Message::user().with_text("!echo hello")).await?; + assert!(shell_commands(&messages).is_empty()); + assert_eq!(api.call_count(), 1); + Ok(()) } #[tokio::test] diff --git a/crates/goose/src/agents/subagent_handler.rs b/crates/goose/src/agents/subagent_handler.rs index 34efb677f..9b21aa12b 100644 --- a/crates/goose/src/agents/subagent_handler.rs +++ b/crates/goose/src/agents/subagent_handler.rs @@ -193,7 +193,12 @@ fn get_agent_messages(params: SubagentRunParams) -> AgentMessagesFuture { let mut stream = crate::session_context::with_session_id(Some(session_id.to_string()), async { agent - .reply(user_message, session_config, cancellation_token) + .reply( + user_message, + session_config, + crate::agents::state_machine::enabled(), + cancellation_token, + ) .await }) .await diff --git a/crates/goose/src/agents/types.rs b/crates/goose/src/agents/types.rs index fbafe8c99..684b7c290 100644 --- a/crates/goose/src/agents/types.rs +++ b/crates/goose/src/agents/types.rs @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Mutex; -// We use double Arc here to allow easy provider swaps while sharing concurrent access pub type SharedProvider = Arc>>>; /// Default timeout for retry operations (5 minutes) diff --git a/crates/goose/src/gateway/handler.rs b/crates/goose/src/gateway/handler.rs index f5091ab2a..8a9f81bca 100644 --- a/crates/goose/src/gateway/handler.rs +++ b/crates/goose/src/gateway/handler.rs @@ -522,6 +522,7 @@ impl GatewayHandler { agent.load_extensions_from_session(&session).await; let cancel = CancellationToken::new(); + let cancel_for_reply = cancel.clone(); let user_message = Message::user().with_text(&message.text); // Cap tool-calling loops so the agent doesn't run away doing @@ -546,7 +547,12 @@ impl GatewayHandler { }; let mut stream = match agent - .reply(user_message, session_config, Some(cancel.clone())) + .reply( + user_message, + session_config, + crate::agents::state_machine::enabled(), + Some(cancel_for_reply), + ) .await { Ok(s) => s, diff --git a/crates/goose/src/scheduler.rs b/crates/goose/src/scheduler.rs index f547afae0..846e75c12 100644 --- a/crates/goose/src/scheduler.rs +++ b/crates/goose/src/scheduler.rs @@ -1154,7 +1154,12 @@ async fn execute_job( }; let stream = agent - .reply(user_message, session_config, Some(cancel_token)) + .reply( + user_message, + session_config, + crate::agents::state_machine::enabled(), + Some(cancel_token), + ) .await?; use futures::StreamExt; diff --git a/crates/goose/tests/agent.rs b/crates/goose/tests/agent.rs index ed0cb5511..3f060a11a 100644 --- a/crates/goose/tests/agent.rs +++ b/crates/goose/tests/agent.rs @@ -611,7 +611,14 @@ mod tests { retry_config: None, }; - let reply_stream = agent.reply(user_message, session_config, None).await?; + let reply_stream = agent + .reply( + user_message, + session_config, + goose::agents::state_machine::enabled(), + None, + ) + .await?; tokio::pin!(reply_stream); let mut responses = Vec::new(); @@ -804,7 +811,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hello"), session_config, None) + .reply( + Message::user().with_text("Hello"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -1020,7 +1032,14 @@ mod tests { retry_config: None, }; - let reply_stream = agent.reply(user_message, session_config, None).await?; + let reply_stream = agent + .reply( + user_message, + session_config, + goose::agents::state_machine::enabled(), + None, + ) + .await?; tokio::pin!(reply_stream); // Drain the stream @@ -1384,6 +1403,7 @@ mod tests { .reply( Message::user().with_text("Do something then say hello"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -1438,6 +1458,7 @@ mod tests { .reply( Message::user().with_text("Tell me more"), session_config2, + goose::agents::state_machine::enabled(), Some(cancel_token), ) .await?; @@ -1630,6 +1651,7 @@ mod tests { .reply( Message::user().with_text("Use the test tool"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -1831,6 +1853,7 @@ mod tests { .reply( Message::user().with_text("Use the test tool"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -1996,6 +2019,7 @@ mod tests { .reply( Message::user().with_text("Use both tools"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -2145,6 +2169,7 @@ mod tests { .reply( Message::user().with_text("Use both tools"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -2343,7 +2368,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hello"), session_config, None) + .reply( + Message::user().with_text("Hello"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -2422,7 +2452,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hello"), session_config, None) + .reply( + Message::user().with_text("Hello"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -2521,6 +2556,7 @@ mod tests { .reply( Message::user().with_text("/goal make all tests pass"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -2582,7 +2618,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("/goal"), session_config, None) + .reply( + Message::user().with_text("/goal"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -2705,7 +2746,12 @@ mod tests { retry_config: None, }; let stream = agent - .reply(Message::user().with_text(text), session_config, None) + .reply( + Message::user().with_text(text), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(stream); while let Some(event) = stream.next().await { @@ -3115,6 +3161,7 @@ mod tests { max_turns: Some(3), retry_config: None, }, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -3398,7 +3445,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -3582,7 +3634,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); let mut emitted_steer_id = None; @@ -3668,6 +3725,7 @@ mod tests { max_turns: Some(3), retry_config: None, }, + goose::agents::state_machine::enabled(), None, ) .await?; @@ -3734,7 +3792,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -3852,7 +3915,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -3941,7 +4009,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); @@ -4003,7 +4076,12 @@ mod tests { }; let reply_stream = agent - .reply(Message::user().with_text("Hi"), session_config, None) + .reply( + Message::user().with_text("Hi"), + session_config, + goose::agents::state_machine::enabled(), + None, + ) .await?; tokio::pin!(reply_stream); diff --git a/crates/goose/tests/compaction.rs b/crates/goose/tests/compaction.rs index a65e5a96c..82dcec1f1 100644 --- a/crates/goose/tests/compaction.rs +++ b/crates/goose/tests/compaction.rs @@ -537,7 +537,14 @@ async fn test_auto_compaction_during_reply() -> Result<()> { retry_config: None, }; - let reply_stream = agent.reply(user_message, session_config, None).await?; + let reply_stream = agent + .reply( + user_message, + session_config, + goose::agents::state_machine::enabled(), + None, + ) + .await?; tokio::pin!(reply_stream); // Track compaction and context size changes @@ -694,6 +701,7 @@ async fn test_context_limit_recovery_compaction() -> Result<()> { .reply( Message::user().with_text("Tell me more"), session_config, + goose::agents::state_machine::enabled(), None, ) .await?; diff --git a/crates/goose/tests/providers.rs b/crates/goose/tests/providers.rs index 3f7794240..c6402b2d3 100644 --- a/crates/goose/tests/providers.rs +++ b/crates/goose/tests/providers.rs @@ -588,7 +588,15 @@ impl ProviderFixture { retry_config: None, }; - let mut stream = self.agent.reply(message, session_config, None).await?; + let mut stream = self + .agent + .reply( + message, + session_config, + goose::agents::state_machine::enabled(), + None, + ) + .await?; let mut saw_action_required = false; while let Some(event) = stream.next().await { diff --git a/ui/desktop/src/acp/prompt.ts b/ui/desktop/src/acp/prompt.ts index 4b622e08a..89e97e2a3 100644 --- a/ui/desktop/src/acp/prompt.ts +++ b/ui/desktop/src/acp/prompt.ts @@ -8,9 +8,11 @@ export async function acpPromptSession( message: Message ): Promise { const client = await getAcpClient(); + const useLegacyAgentLoop = await window.electron.getSetting('useLegacyAgentLoop'); return client.connection.agent.request(methods.agent.session.prompt, { sessionId, prompt: messageToAcpPromptContent(message), + _meta: { goose: { unrolledAgentLoop: !useLegacyAgentLoop } }, }); } diff --git a/ui/desktop/src/components/settings/chat/ChatSettingsSection.tsx b/ui/desktop/src/components/settings/chat/ChatSettingsSection.tsx index ebbf7acc2..4a32aff8c 100644 --- a/ui/desktop/src/components/settings/chat/ChatSettingsSection.tsx +++ b/ui/desktop/src/components/settings/chat/ChatSettingsSection.tsx @@ -4,6 +4,7 @@ import { SecurityToggle } from '../security/SecurityToggle'; import { ResponseStylesSection } from '../response_styles/ResponseStylesSection'; import { GoosehintsSection } from './GoosehintsSection'; import { SpellcheckToggle } from './SpellcheckToggle'; +import { LegacyAgentLoopToggle } from './LegacyAgentLoopToggle'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../ui/card'; import { defineMessages, useIntl } from '../../../i18n'; @@ -65,6 +66,12 @@ export default function ChatSettingsSection() { + + + + + + diff --git a/ui/desktop/src/components/settings/chat/LegacyAgentLoopToggle.tsx b/ui/desktop/src/components/settings/chat/LegacyAgentLoopToggle.tsx new file mode 100644 index 000000000..c5cd51b95 --- /dev/null +++ b/ui/desktop/src/components/settings/chat/LegacyAgentLoopToggle.tsx @@ -0,0 +1,42 @@ +import { useEffect, useState } from 'react'; +import { defineMessages, useIntl } from '../../../i18n'; +import { Switch } from '../../ui/switch'; + +const i18n = defineMessages({ + title: { + id: 'settings.legacyAgentLoop.title', + defaultMessage: 'Use Legacy Agent Loop', + }, + description: { + id: 'settings.legacyAgentLoop.description', + defaultMessage: 'Fall back to the classic agent loop if the new one causes issues', + }, +}); + +export function LegacyAgentLoopToggle() { + const intl = useIntl(); + const [enabled, setEnabled] = useState(false); + + useEffect(() => { + window.electron.getSetting('useLegacyAgentLoop').then((value) => setEnabled(value ?? false)); + }, []); + + const handleToggle = async (checked: boolean) => { + setEnabled(checked); + await window.electron.setSetting('useLegacyAgentLoop', checked); + }; + + return ( +
+
+

{intl.formatMessage(i18n.title)}

+

+ {intl.formatMessage(i18n.description)} +

+
+
+ +
+
+ ); +} diff --git a/ui/desktop/src/i18n/messages/de.json b/ui/desktop/src/i18n/messages/de.json index ae2cfda27..820dde181 100644 --- a/ui/desktop/src/i18n/messages/de.json +++ b/ui/desktop/src/i18n/messages/de.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Besuchen Sie" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/en.json b/ui/desktop/src/i18n/messages/en.json index c959a59d1..51ee867ce 100644 --- a/ui/desktop/src/i18n/messages/en.json +++ b/ui/desktop/src/i18n/messages/en.json @@ -4061,6 +4061,12 @@ "settings.language.zhTW": { "defaultMessage": "Chinese (Traditional)" }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" + }, "settings.menuBarIcon.description": { "defaultMessage": "Show goose in the menu bar" }, diff --git a/ui/desktop/src/i18n/messages/es.json b/ui/desktop/src/i18n/messages/es.json index 977d8fa65..9f82492c7 100644 --- a/ui/desktop/src/i18n/messages/es.json +++ b/ui/desktop/src/i18n/messages/es.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Visita" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/fr.json b/ui/desktop/src/i18n/messages/fr.json index 759d23994..3a9b8d38d 100644 --- a/ui/desktop/src/i18n/messages/fr.json +++ b/ui/desktop/src/i18n/messages/fr.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Visitez" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/hi.json b/ui/desktop/src/i18n/messages/hi.json index bd60f3185..b02d05c2e 100644 --- a/ui/desktop/src/i18n/messages/hi.json +++ b/ui/desktop/src/i18n/messages/hi.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "जाएं" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/id.json b/ui/desktop/src/i18n/messages/id.json index be47af36a..73d4db952 100644 --- a/ui/desktop/src/i18n/messages/id.json +++ b/ui/desktop/src/i18n/messages/id.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Kunjungi" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/it.json b/ui/desktop/src/i18n/messages/it.json index db569e39a..ead94f2e2 100644 --- a/ui/desktop/src/i18n/messages/it.json +++ b/ui/desktop/src/i18n/messages/it.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Visita" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/ja.json b/ui/desktop/src/i18n/messages/ja.json index 0614eca2b..bb2cecc6b 100644 --- a/ui/desktop/src/i18n/messages/ja.json +++ b/ui/desktop/src/i18n/messages/ja.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "次のURLにアクセスし、" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/ko.json b/ui/desktop/src/i18n/messages/ko.json index 3efc90efe..7278dc044 100644 --- a/ui/desktop/src/i18n/messages/ko.json +++ b/ui/desktop/src/i18n/messages/ko.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "방문하여" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/ms.json b/ui/desktop/src/i18n/messages/ms.json index a42eefe6e..e63b235c0 100644 --- a/ui/desktop/src/i18n/messages/ms.json +++ b/ui/desktop/src/i18n/messages/ms.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Lawati" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/pt.json b/ui/desktop/src/i18n/messages/pt.json index 1bfa99004..3cb703979 100644 --- a/ui/desktop/src/i18n/messages/pt.json +++ b/ui/desktop/src/i18n/messages/pt.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Acesse" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/ru.json b/ui/desktop/src/i18n/messages/ru.json index e867b60ca..939434646 100644 --- a/ui/desktop/src/i18n/messages/ru.json +++ b/ui/desktop/src/i18n/messages/ru.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Перейдите на" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/tr.json b/ui/desktop/src/i18n/messages/tr.json index c2563ce8b..65f54d7a6 100644 --- a/ui/desktop/src/i18n/messages/tr.json +++ b/ui/desktop/src/i18n/messages/tr.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Ziyaret edin" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/vi.json b/ui/desktop/src/i18n/messages/vi.json index e3085445d..2c68338ff 100644 --- a/ui/desktop/src/i18n/messages/vi.json +++ b/ui/desktop/src/i18n/messages/vi.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "Truy cập" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/zh-CN.json b/ui/desktop/src/i18n/messages/zh-CN.json index 5a2a34823..fe4da55d3 100644 --- a/ui/desktop/src/i18n/messages/zh-CN.json +++ b/ui/desktop/src/i18n/messages/zh-CN.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "访问" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/i18n/messages/zh-TW.json b/ui/desktop/src/i18n/messages/zh-TW.json index d0d4c9874..7a793c756 100644 --- a/ui/desktop/src/i18n/messages/zh-TW.json +++ b/ui/desktop/src/i18n/messages/zh-TW.json @@ -4669,5 +4669,11 @@ }, "providerConfigurationModal.deviceCodeVisit": { "defaultMessage": "前往" + }, + "settings.legacyAgentLoop.description": { + "defaultMessage": "Fall back to the classic agent loop if the new one causes issues" + }, + "settings.legacyAgentLoop.title": { + "defaultMessage": "Use Legacy Agent Loop" } } diff --git a/ui/desktop/src/main.ts b/ui/desktop/src/main.ts index 1d0391d90..f70b23e9c 100644 --- a/ui/desktop/src/main.ts +++ b/ui/desktop/src/main.ts @@ -1976,6 +1976,7 @@ const validSettingKeys: Set = new Set([ 'seenAnnouncementIds', 'disableAutoDownload', 'recentModels', + 'useLegacyAgentLoop', ]); ipcMain.handle('set-setting', (_event, key: SettingKey, value: unknown) => { diff --git a/ui/desktop/src/utils/settings.ts b/ui/desktop/src/utils/settings.ts index f693cd97c..9c02f3fe9 100644 --- a/ui/desktop/src/utils/settings.ts +++ b/ui/desktop/src/utils/settings.ts @@ -55,6 +55,7 @@ export interface Settings { showPricing: boolean; seenAnnouncementIds: string[]; recentModels: RecentModel[]; + useLegacyAgentLoop: boolean; } export type SettingKey = keyof Settings; @@ -96,6 +97,7 @@ export const defaultSettings: Settings = { showPricing: true, seenAnnouncementIds: [], recentModels: [], + useLegacyAgentLoop: false, }; export function getKeyboardShortcuts(settings: Settings): KeyboardShortcuts {