feat(agent): route Desktop to state-machine loop via ACP prompt meta (#11247)
Signed-off-by: Abhijay Jain <Abhijay007j@gmail.com> Co-authored-by: Douwe Osinga <douwe.osinga@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)?);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -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<CancellationToken>,
|
||||
) -> Result<BoxStream<'_, Result<AgentEvent>>> {
|
||||
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<CancellationToken>,
|
||||
) -> Result<BoxStream<'_, Result<AgentEvent>>> {
|
||||
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 =
|
||||
|
||||
@@ -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))?;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<Mutex<Option<Arc<dyn Provider>>>>;
|
||||
|
||||
/// Default timeout for retry operations (5 minutes)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
+91
-13
@@ -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);
|
||||
|
||||
|
||||
@@ -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?;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -8,9 +8,11 @@ export async function acpPromptSession(
|
||||
message: Message
|
||||
): Promise<PromptResponse> {
|
||||
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 } },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="pb-2 rounded-lg">
|
||||
<CardContent className="px-4 pt-4">
|
||||
<LegacyAgentLoopToggle />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="pb-2 rounded-lg">
|
||||
<CardContent className="px-2">
|
||||
<SecurityToggle />
|
||||
|
||||
@@ -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 (
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="text-text-primary text-xs">{intl.formatMessage(i18n.title)}</h3>
|
||||
<p className="text-xs text-text-secondary max-w-md mt-[2px]">
|
||||
{intl.formatMessage(i18n.description)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
<Switch checked={enabled} onCheckedChange={handleToggle} variant="mono" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1976,6 +1976,7 @@ const validSettingKeys: Set<string> = new Set([
|
||||
'seenAnnouncementIds',
|
||||
'disableAutoDownload',
|
||||
'recentModels',
|
||||
'useLegacyAgentLoop',
|
||||
]);
|
||||
|
||||
ipcMain.handle('set-setting', (_event, key: SettingKey, value: unknown) => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user