From 5a0a937953060f10d7d1f04e795cd3d617521f71 Mon Sep 17 00:00:00 2001 From: Alex Holder Date: Tue, 21 Oct 2025 20:32:20 +0100 Subject: [PATCH 1/2] improvement: add useful error message when attempting to use unauthenticated cursor-agent Signed-off-by: Alex Holder --- crates/goose/src/providers/cursor_agent.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/goose/src/providers/cursor_agent.rs b/crates/goose/src/providers/cursor_agent.rs index 31b185f3ddae..67ae2296fc87 100644 --- a/crates/goose/src/providers/cursor_agent.rs +++ b/crates/goose/src/providers/cursor_agent.rs @@ -47,6 +47,17 @@ impl CursorAgentProvider { }) } + /// Get authentication status from cursor-agent + async fn get_authentication_status(&self) -> bool { + Command::new(&self.command) + .arg("status") + .output() + .await + .ok() + .map(|output| String::from_utf8_lossy(&output.stdout).contains("✓ Logged in as")) + .unwrap_or(false) + } + /// Search for cursor-agent executable in common installation locations fn find_cursor_agent_executable(command_name: &str) -> Option { let home = std::env::var("HOME").ok()?; @@ -248,6 +259,12 @@ impl CursorAgentProvider { messages: &[Message], _tools: &[Tool], ) -> Result, ProviderError> { + if !self.get_authentication_status().await { + return Err(ProviderError::Authentication( + "You are not logged in to cursor-agent. Please run 'cursor-agent login' to authenticate first." + .to_string())); + } + let prompt = self.messages_to_cursor_agent_format(system, messages); if std::env::var("GOOSE_CURSOR_AGENT_DEBUG").is_ok() { From be51025f042e524f6d0193095b8eeef1ec7f09bf Mon Sep 17 00:00:00 2001 From: Alex Holder Date: Wed, 22 Oct 2025 01:12:50 +0100 Subject: [PATCH 2/2] fix: move cursor-agent auth check Signed-off-by: Alex Holder --- crates/goose/src/providers/cursor_agent.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/goose/src/providers/cursor_agent.rs b/crates/goose/src/providers/cursor_agent.rs index 67ae2296fc87..225d09e0265d 100644 --- a/crates/goose/src/providers/cursor_agent.rs +++ b/crates/goose/src/providers/cursor_agent.rs @@ -259,12 +259,6 @@ impl CursorAgentProvider { messages: &[Message], _tools: &[Tool], ) -> Result, ProviderError> { - if !self.get_authentication_status().await { - return Err(ProviderError::Authentication( - "You are not logged in to cursor-agent. Please run 'cursor-agent login' to authenticate first." - .to_string())); - } - let prompt = self.messages_to_cursor_agent_format(system, messages); if std::env::var("GOOSE_CURSOR_AGENT_DEBUG").is_ok() { @@ -336,6 +330,11 @@ impl CursorAgentProvider { })?; if !exit_status.success() { + if !self.get_authentication_status().await { + return Err(ProviderError::Authentication( + "You are not logged in to cursor-agent. Please run 'cursor-agent login' to authenticate first." + .to_string())); + } return Err(ProviderError::RequestFailed(format!( "Command failed with exit code: {:?}", exit_status.code()