Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agent-harness): report a missing Cursor key as not connected instead of 502 (#7903)

teoc8e8dfe204f0
diff --git a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json b/apps/web/src/lib/service-clients/service-agent-harness/openapi.json
index 5f2bad61a0..0c9e06eccc 100644
--- a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json
+++ b/apps/web/src/lib/service-clients/service-agent-harness/openapi.json
@@ -46,7 +46,7 @@
"description": "Harness is not visible to caller"
},
"409": {
- "description": "Macrod runtime is disconnected"
+ "description": "Macrod runtime or Cursor account is not connected"
},
"502": {
"description": "Provider probe failed"
@@ -184,7 +184,7 @@
"description": "Harness is not visible to caller"
},
"409": {
- "description": "Macrod runtime is disconnected"
+ "description": "Macrod runtime or Cursor account is not connected"
},
"502": {
"description": "Provider probe failed"
diff --git a/crates/agent_harness/src/domain/capability_discovery.rs b/crates/agent_harness/src/domain/capability_discovery.rs
index 643ae7f945..736f219ac2 100644
--- a/crates/agent_harness/src/domain/capability_discovery.rs
+++ b/crates/agent_harness/src/domain/capability_discovery.rs
@@ -69,7 +69,7 @@ pub enum RawCapabilityProbe {
/// A provider probe failure.
#[derive(Debug, thiserror::Error)]
pub enum CapabilityProbeError {
- /// A required live runtime is not connected.
+ /// A required live runtime, or the caller's Cursor account, is not connected.
#[error("the requested harness is disconnected")]
Disconnected,
/// Provider-specific probing failed.
diff --git a/crates/agent_harness/src/domain/model_load.rs b/crates/agent_harness/src/domain/model_load.rs
index cead249cb8..4959a9ccfb 100644
--- a/crates/agent_harness/src/domain/model_load.rs
+++ b/crates/agent_harness/src/domain/model_load.rs
@@ -91,7 +91,7 @@ pub enum RawModelProbe {
/// A provider probe failure.
#[derive(Debug, thiserror::Error)]
pub enum ModelProbeError {
- /// A required live runtime is not connected.
+ /// A required live runtime, or the caller's Cursor account, is not connected.
#[error("the requested harness is disconnected")]
Disconnected,
/// Provider-specific probing failed.
diff --git a/crates/agent_harness/src/inbound/capability_discovery.rs b/crates/agent_harness/src/inbound/capability_discovery.rs
index 6def87b3c3..e40223c099 100644
--- a/crates/agent_harness/src/inbound/capability_discovery.rs
+++ b/crates/agent_harness/src/inbound/capability_discovery.rs
@@ -228,7 +228,7 @@ where
(status = 400, description = "Invalid target"),
(status = 401, description = "Unauthenticated"),
(status = 403, description = "Harness is not visible to caller"),
- (status = 409, description = "Macrod runtime is disconnected"),
+ (status = 409, description = "Macrod runtime or Cursor account is not connected"),
(status = 504, description = "Macrod probe timed out"),
(status = 502, description = "Provider probe failed"),
)
diff --git a/crates/agent_harness/src/inbound/model_load.rs b/crates/agent_harness/src/inbound/model_load.rs
index faff0ead93..f6662d2239 100644
--- a/crates/agent_harness/src/inbound/model_load.rs
+++ b/crates/agent_harness/src/inbound/model_load.rs
@@ -188,7 +188,7 @@ where
(status = 400, description = "Invalid target"),
(status = 401, description = "Unauthenticated"),
(status = 403, description = "Harness is not visible to caller"),
- (status = 409, description = "Macrod runtime is disconnected"),
+ (status = 409, description = "Macrod runtime or Cursor account is not connected"),
(status = 504, description = "Macrod probe timed out"),
(status = 502, description = "Provider probe failed"),
)
diff --git a/packages/sdk/generated/agent-harness/types.gen.ts b/packages/sdk/generated/agent-harness/types.gen.ts
index 95d49acb13..6abd6e5bd2 100644
--- a/packages/sdk/generated/agent-harness/types.gen.ts
+++ b/packages/sdk/generated/agent-harness/types.gen.ts
@@ -1562,7 +1562,7 @@ export type DiscoverAgentCapabilitiesHandlerErrors = {
*/
403: unknown;
/**
- * Macrod runtime is disconnected
+ * Macrod runtime or Cursor account is not connected
*/
409: unknown;
/**
@@ -1645,7 +1645,7 @@ export type LoadAgentModelsHandlerErrors = {
*/
403: unknown;
/**
- * Macrod runtime is disconnected
+ * Macrod runtime or Cursor account is not connected
*/
409: unknown;
/**
diff --git a/packages/sdk/specs/agent-harness.json b/packages/sdk/specs/agent-harness.json
index 5f2bad61a0..0c9e06eccc 100644
--- a/packages/sdk/specs/agent-harness.json
+++ b/packages/sdk/specs/agent-harness.json
@@ -46,7 +46,7 @@
"description": "Harness is not visible to caller"
},
"409": {
- "description": "Macrod runtime is disconnected"
+ "description": "Macrod runtime or Cursor account is not connected"
},
"502": {
"description": "Provider probe failed"
@@ -184,7 +184,7 @@
"description": "Harness is not visible to caller"
},
"409": {
- "description": "Macrod runtime is disconnected"
+ "description": "Macrod runtime or Cursor account is not connected"
},
"502": {
"description": "Provider probe failed"
diff --git a/services/agent_harness_service/src/model_providers/cursor.rs b/services/agent_harness_service/src/model_providers/cursor.rs
index be05137ec8..23252c670e 100644
--- a/services/agent_harness_service/src/model_providers/cursor.rs
+++ b/services/agent_harness_service/src/model_providers/cursor.rs
@@ -1,6 +1,7 @@
//! Cursor model discovery adapter.
use agent_harness::domain::capability_discovery::{CapabilityProbeError, RawCapabilityProbe};
+use agent_harness::domain::error::HarnessError;
use agent_harness::domain::model_load::{CursorModelProbe, ModelProbeError, RawModelProbe};
use agent_harness::outbound::cursor::CursorApiKeys;
use cursor_cloud_agents::api::{ApiKey, CursorClient, CursorConfig};
@@ -36,7 +37,10 @@ where
.keys
.resolve(caller)
.await
- .map_err(|error| ModelProbeError::Failed(error.to_string()))?;
+ .map_err(|error| match error {
+ HarnessError::CursorNotConnected => ModelProbeError::Disconnected,
+ error => ModelProbeError::Failed(error.to_string()),
+ })?;
let client = CursorClient::new(CursorConfig {
api_key: ApiKey::new(config.key.expose()),
base_url: self.base_url.clone(),
@@ -71,7 +75,10 @@ impl<Keys: CursorApiKeys> agent_harness::domain::capability_discovery::Capabilit
.keys
.resolve(caller)
.await
- .map_err(|error| CapabilityProbeError::Failed(error.to_string()))?;
+ .map_err(|error| match error {
+ HarnessError::CursorNotConnected => CapabilityProbeError::Disconnected,
+ error => CapabilityProbeError::Failed(error.to_string()),
+ })?;
let client = CursorClient::new(CursorConfig {
api_key: ApiKey::new(config.key.expose()),
base_url: self.base_url.clone(),
diff --git a/services/agent_harness_service/src/model_providers/cursor/test.rs b/services/agent_harness_service/src/model_providers/cursor/test.rs
index afa7ea36e3..87e5a15854 100644
--- a/services/agent_harness_service/src/model_providers/cursor/test.rs
+++ b/services/agent_harness_service/src/model_providers/cursor/test.rs
@@ -23,6 +23,17 @@ impl CursorApiKeys for TestCursorKeys {
}
}
+struct NoCursorKey;
+
+impl CursorApiKeys for NoCursorKey {
+ async fn resolve(
+ &self,
+ _owner: &MacroUserIdStr<'_>,
+ ) -> agent_harness::domain::error::Result<ResolvedCursorConfig> {
+ Err(HarnessError::CursorNotConnected)
+ }
+}
+
/// Every (method, path) the fake Cursor API was asked for.
type RecordedCalls = Arc<Mutex<Vec<(String, String)>>>;
@@ -102,3 +113,19 @@ async fn capabilities_use_the_selected_model_instead_of_the_account_default() {
);
server.abort();
}
+
+#[tokio::test]
+async fn a_caller_without_a_cursor_key_is_not_connected_rather_than_a_provider_failure() {
+ use agent_harness::domain::capability_discovery::CapabilityProbe;
+ let provider = CursorModels::new(NoCursorKey, "http://127.0.0.1:9".to_owned());
+ let caller = MacroUserIdStr::try_from_email("[email protected]").unwrap();
+
+ assert!(matches!(
+ CapabilityProbe::probe(&provider, &caller, None).await,
+ Err(CapabilityProbeError::Disconnected)
+ ));
+ assert!(matches!(
+ CursorModelProbe::probe(&provider, &caller).await,
+ Err(ModelProbeError::Disconnected)
+ ));
+}