Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(composio): treat backend mode without a session as a setup state in list_connections

Shanud5f04c306b8f
diff --git a/.claude/memory.md b/.claude/memory.md
index 9793eacd3c..3a6322b346 100644
--- a/.claude/memory.md
+++ b/.claude/memory.md
@@ -16,6 +16,7 @@ Quick reference for anyone starting with Claude on this project. Updated by the
- **"I don't have that stored" on a personal question while the fact is in memory (issue #6040)** — the turn injects no memory of the user by itself, and the `MemoryAccessSection` instruction was gated on `learning.enabled` (default `false`), so the model was never told to look before claiming absence. Now: Lane C (`src/openhuman/memory/auto_recall/`) runs a lexically gated, bounded `fast_retrieve` through the session binding's guard and prepends a `## Relevant memory for this message` block to the **user message** (never the system prompt — KV-cache prefix); the instruction is added whenever a retrieval tool is registered, regardless of learning; `memory_recall` no longer requires `namespace`. Switch: `[subsystems.memory.hooks] auto_recall` / `OPENHUMAN_MEMORY_HOOKS_AUTO_RECALL` — the flag existed before and was read by nothing. `core_turn.rs` sits near the 750-line gate: per-turn memory lanes live in `turn/recall_lanes.rs`, add there. `RecordingProvider::with_fast_retrieve_result` scripts the guarded retrieval family in tests. The sub-agent fast path (#4677) still skips entity-less queries; Lane C calls the engine directly, whose empty-entity path is dense retrieval. **Latency:** every `fast_retrieve` asks the host for spaCy over the bus (`memory_host.rs::extract_spacy` → the Python server) plus a query embed, so a warm lookup is ~1.5–3 s and the first after boot was >5 s (Python server + model load) — `memory::auto_recall::warm::spawn_at_boot`, hooked in `modules/boot.rs` right after the TinyMemory module loads, runs one throwaway retrieval so the user's first question is warm (measured: warm-up 2.4 s at boot, first real lookup 1.6 s). Lane budget is 5 s; `[memory_host] embed/extract_spacy elapsed_ms` debug lines give the split.
- **A `Memory` trait method left on its default is a silent no-op in production (issue #6041)** — the session's `Arc<dyn Memory>` is `agent/experience/ops.rs::DriverMemory` (since `7a4278378`), and `tinymemory-api`'s `Memory::recall_relevant_by_vector` defaults to `Ok(vec![])`, so situational preferences (Lane B) injected nothing on every module-backed install while every turn test stayed green — the harness tests bind the embedded `tinymemory_core::store::create_memory`, which overrides it. `DriverMemory` now answers through `preferences::recall_by_vector_over` (one body with the guard path). Rule: a turn-level test that pins production behaviour must bind `DriverMemory` over `guard::test_support::RecordingProvider` (`with_namespace_hits`, `with_list_result`), not the embedded store; and before leaving a trait default in place, grep who actually holds the handle. Costs measured on the desktop once the lane was live: the vector recall is one query-embed round trip, 0.8–3 s per turn, so `recall_situational_preferences_on` lists the namespace first (no embed) and skips the recall when nothing is stored; Lane B's budget is 5 s (3 s lost the block on both on-topic turns). Floor tuning data: `[pref_recall] namespace= kept= top_similarity= floor= elapsed_ms=` — with the managed embedder, unrelated message↔preference pairs score 0.28–0.33, a rule-phrased travel preference vs a trip-planning message 0.349, a coffee preference vs a café question 0.575; the 0.35 floor is thin but lowering it pulls cross-topic preferences in.
- **`memory_store` writes land where the pre-turn lane never looked (issue #6063)** — `memory_store` files a fact as a namespace document in `global` (`memory_docs` + a `vector_chunks` embedding, the same path `save_preference` takes), while Lane C read only the memory tree (`fast_retrieve`), which namespace documents never enter; the archivist's chat→tree ingest runs at segment close (days late on a live profile) and short turns stay `buffered`/`dropped`, so "remember X" → new chat → "X is not on record" reproduced on a default install with the #6052 write in place. Now Lane C runs two legs side by side (`tokio::join!`, a 5 s bound **per leg**): the tree walk and `recall_namespace_scored("global", message, 3)` through the same guard (`AutoRecallSource::recall_namespace_scored` — required, no trait default, per the #6041 rule), floored at `AUTO_RECALL_NOTE_MIN_SIMILARITY = 0.35` on the vector component (Lane B's floor data), notes rendered first as `- <content> (note: <key>)`, wrapped when `ExternalSync`-tainted or connector-keyed. The block also opens with `AUTO_RECALL_HINT` ("pre-fetched, not a search") because the model read the old block as the retrieval the memory-access rule demands and claimed absence over three unrelated tree hits. Tell in the log: `[auto_recall] … hits= total= notes= notes_top= tree_ms= notes_ms=` — a `total` unchanged after a store means the fact never reached the tree. `RecordingProvider::with_namespace_hits` + `guard::test_support::namespace_hit` script the leg; `guarded_with` + `AutoRecall::from_guard` is the production wiring in a turn test.
+- **Composio `list_connections` at boot while signed out reported ERR + Sentry (issue #6176)** — in backend mode with no app-session JWT, `modules::connectors::module_config` fails, `ensure_routed` sends the connector module `{"route": "none"}`, and every routed member answers "this module was loaded without a connector route … or call Configure" (Configure _was_ called; the text is misleading). `start_bootstrap_jobs` → `memory::sources::reconcile::ensure_composio_sources` → `composio_list_connections` hit it at every boot (the reconcile `debug!`-swallows the failure one layer up, after `report_composio_op_error` had already fired), and `start_periodic_sync` repeated it every 60 s. Fix: `integrations/composio/ops/error_utils.rs::backend_mode_without_session`, the twin of `direct_mode_without_key`, short-circuits `composio_list_connections` to an empty list. It reads `api::jwt::get_session_token` — the single token source `integrations::build_client` uses — and not `build_client` itself, which WARNs on every call; a _failed_ lookup returns `false` so a real store fault still surfaces. Two things to know: signed out now yields `Some(empty)` from `ensure_composio_sources`, so `list_rpc` hides Composio memory-source rows until sign-in (display-only, same as direct-mode-without-key); and a corrupt `auth-profiles.json` is quarantined + reset rather than an error, so to test the `Err` branch make `config_path.parent()` a regular file (the `auth_profile_lock_errors_do_not_include_local_paths` trick). `ops_tests_part_03_tests.rs` sits at 720 of the 750-line layout gate — new Composio op tests go in `ops_tests_part_04_tests.rs`.
## Strict Rules
diff --git a/src/openhuman/integrations/composio/ops/connections.rs b/src/openhuman/integrations/composio/ops/connections.rs
index f6db0d82c6..357459b61f 100644
--- a/src/openhuman/integrations/composio/ops/connections.rs
+++ b/src/openhuman/integrations/composio/ops/connections.rs
@@ -16,7 +16,9 @@ use super::super::types::{
ComposioAuthorizeRequest, ComposioAuthorizeResponse, ComposioConnectionsResponse,
ComposioDeleteConnectionRequest, ComposioDeleteResponse,
};
-use super::error_utils::{direct_mode_without_key, report_composio_op_error, OpResult};
+use super::error_utils::{
+ backend_mode_without_session, direct_mode_without_key, report_composio_op_error, OpResult,
+};
use super::memory_cleanup::composio_memory_targets_for_connection;
use tinymemory_api::composio::normalize_connection_identifier;
@@ -36,6 +38,18 @@ pub async fn composio_list_connections(
vec!["composio: direct mode — no api key configured yet, 0 connection(s)".to_string()],
));
}
+ if backend_mode_without_session(config) {
+ tracing::debug!(
+ "[composio] list_connections: backend mode selected, not signed in yet \
+ — returning empty connection list (valid setup state, not an error)"
+ );
+ return Ok(RpcOutcome::new(
+ ComposioConnectionsResponse {
+ connections: Vec::new(),
+ },
+ vec!["composio: backend mode — not signed in yet, 0 connection(s)".to_string()],
+ ));
+ }
// The connector module owns the backend-proxied route. Direct mode stays
// host-side because its client accepts the local loopback overrides used
// by desktop development and its v3 response mapper lives here.
diff --git a/src/openhuman/integrations/composio/ops/error_utils.rs b/src/openhuman/integrations/composio/ops/error_utils.rs
index ee5cafa203..524ee13ba6 100644
--- a/src/openhuman/integrations/composio/ops/error_utils.rs
+++ b/src/openhuman/integrations/composio/ops/error_utils.rs
@@ -74,6 +74,45 @@ pub(crate) fn direct_mode_without_key(config: &Config) -> OpResult<bool> {
Ok(!has_key)
}
+/// True when the user is in Composio **backend** mode (the default) but has no
+/// app-session JWT yet — a fresh install before sign-in, or signed out.
+///
+/// Like [`direct_mode_without_key`], this is a valid *setup* state, not an
+/// operation failure. Without a session there is no proxy route to give the
+/// connector module: `modules::connectors::module_config` fails, `ensure_routed`
+/// reconfigures the module with `{"route": "none"}`, and every routed member
+/// answers "this module was loaded without a connector route" — which the op
+/// layer then reported at error level (and to Sentry) once at boot from the
+/// memory-source reconcile and again on every periodic tick, for a user who
+/// simply has not signed in (#6176). Callers short-circuit to an empty result
+/// instead.
+///
+/// Session presence MUST mirror the module route's own resolution:
+/// `module_config` calls `integrations::build_client`, whose only token source
+/// is the app-session JWT (`crate::api::jwt::get_session_token`). Read that
+/// same source — not `build_client` itself, which logs a warning per call and
+/// would recreate the noise this guard removes.
+///
+/// A *failed* token lookup (store unreadable) deliberately returns `false`:
+/// that is a real fault, and it must keep surfacing through the normal error
+/// path rather than being read as "not signed in".
+pub(crate) fn backend_mode_without_session(config: &Config) -> bool {
+ let mode = config.composio.mode.trim();
+ if !(mode.is_empty() || mode == crate::openhuman::config::schema::COMPOSIO_MODE_BACKEND) {
+ return false;
+ }
+ match crate::api::jwt::get_session_token(config) {
+ Ok(token) => token.as_deref().map(str::trim).is_none_or(str::is_empty),
+ Err(error) => {
+ tracing::warn!(
+ "[composio] backend_mode_without_session: session lookup failed ({error}); \
+ not treating as signed out"
+ );
+ false
+ }
+ }
+}
+
/// Defense-in-depth Sentry funnel for composio op-layer errors.
///
/// The shared [`crate::openhuman::integrations::IntegrationClient`]
diff --git a/src/openhuman/integrations/composio/ops/mod.rs b/src/openhuman/integrations/composio/ops/mod.rs
index b13dfa97eb..7e9e2b2e10 100644
--- a/src/openhuman/integrations/composio/ops/mod.rs
+++ b/src/openhuman/integrations/composio/ops/mod.rs
@@ -106,8 +106,8 @@ pub(crate) use crate::openhuman::integrations::composio::providers::SyncReason;
pub(crate) use connections::enrich_connections_with_identity;
#[cfg(test)]
pub(crate) use error_utils::{
- classify_composio_failure_tag, direct_mode_without_key, extract_backend_returned_status,
- resolve_client,
+ backend_mode_without_session, classify_composio_failure_tag, direct_mode_without_key,
+ extract_backend_returned_status, resolve_client,
};
#[cfg(test)]
pub(crate) use providers_ops::parse_sync_reason;
diff --git a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
index 3d8cca77fc..b22576bd7a 100644
--- a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
+++ b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
@@ -83,20 +83,28 @@ async fn composio_list_capabilities_does_not_require_session() {
}
#[tokio::test]
-async fn composio_list_connections_errors_without_session() {
+async fn composio_list_connections_returns_empty_without_session() {
let _serialised = module_guard().await;
let tmp = tempfile::tempdir().unwrap();
let config = test_config(&tmp);
- let err = composio_list_connections(&config).await.unwrap_err();
- // Same contract as `composio_list_toolkits_errors_without_session`: it
- // fails rather than answering with an empty list, and says what is missing.
+ // Backend mode (the default) with no app-session JWT is the fresh-install /
+ // signed-out state, not a failure: the module has no proxy route to be
+ // given, so the old `Err` path reported "loaded without a connector route"
+ // at error level on every boot and periodic tick (#6176). Unlike
+ // `composio_list_toolkits_errors_without_session`, this member answers with
+ // an empty list — exactly as the direct-mode-without-key guard does
+ // (TAURI-RUST-R4) — and the log says why the list is empty.
+ let outcome = composio_list_connections(&config)
+ .await
+ .expect("backend mode without a session must return an empty list, not an error");
assert!(
- err.to_lowercase().contains("composio"),
- "the error should name the domain: {err}"
+ outcome.value.connections.is_empty(),
+ "no session → no route → no connections"
);
assert!(
- err.contains("no backend session") || err.contains("unavailable") || err.contains("route"),
- "the error should say what is missing: {err}"
+ outcome.logs.iter().any(|l| l.contains("not signed in")),
+ "log must explain the empty list is the signed-out setup state, got {:?}",
+ outcome.logs
);
}
diff --git a/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs b/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs
index bd7579199a..dbc90dcf34 100644
--- a/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs
+++ b/src/openhuman/integrations/composio/ops_tests_part_04_tests.rs
@@ -570,3 +570,77 @@ fn source_depth_matches_the_row_and_treats_zero_as_unbounded() {
);
assert_eq!(pick_source_sync_depth_days([], "gmail", "conn-1"), None);
}
+
+// ── Backend mode with no session yet (#6176) ──────────────────────────
+//
+// The twin of the direct-mode-without-key guard: backend mode (the default)
+// with no app-session JWT is the fresh-install / signed-out state.
+// `composio_list_connections` must answer with an empty list instead of
+// letting the connector module report "loaded without a connector route",
+// which the boot-time memory-source reconcile and the 60 s periodic tick
+// would otherwise turn into an error-level report and a Sentry event.
+
+/// Store an app-session JWT in the auth store `config` points at, the same
+/// way `client_tests::config_with_session_token` does.
+fn store_test_session_token(config: &crate::openhuman::config::Config) {
+ crate::openhuman::security::credentials::AuthService::from_config(config)
+ .store_provider_token(
+ crate::openhuman::security::credentials::APP_SESSION_PROVIDER,
+ crate::openhuman::security::credentials::DEFAULT_AUTH_PROFILE_NAME,
+ "test-session-token",
+ std::collections::HashMap::new(),
+ true,
+ )
+ .expect("store test session token");
+}
+
+#[test]
+fn backend_mode_without_session_is_true_for_default_mode_and_no_session() {
+ let tmp = tempfile::tempdir().unwrap();
+ // `Config::default()` leaves `composio.mode` empty, which is backend mode.
+ let config = test_config(&tmp);
+ assert!(backend_mode_without_session(&config));
+}
+
+#[test]
+fn backend_mode_without_session_is_true_for_explicit_backend_mode() {
+ let tmp = tempfile::tempdir().unwrap();
+ let mut config = test_config(&tmp);
+ config.composio.mode = crate::openhuman::config::schema::COMPOSIO_MODE_BACKEND.into();
+ assert!(backend_mode_without_session(&config));
+}
+
+#[test]
+fn backend_mode_without_session_is_false_in_direct_mode() {
+ let tmp = tempfile::tempdir().unwrap();
+ // Direct mode never needs a session; its no-key state belongs to
+ // `direct_mode_without_key`, and the two guards must not overlap.
+ let config = direct_mode_no_key_config(&tmp);
+ assert!(!backend_mode_without_session(&config));
+}
+
+#[test]
+fn backend_mode_without_session_is_false_once_signed_in() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = test_config(&tmp);
+ store_test_session_token(&config);
+ // A stored session means the module gets a proxy route — the guard must
+ // step aside, or a signed-in user would see a silent empty list.
+ assert!(!backend_mode_without_session(&config));
+}
+
+#[test]
+fn backend_mode_without_session_is_false_when_the_session_store_is_unreadable() {
+ let tmp = tempfile::tempdir().unwrap();
+ // The auth-profile store lives in `config_path.parent()`
+ // (`state_dir_from_config`); a regular file there makes it fail to load,
+ // the same trick `auth_profile_lock_errors_do_not_include_local_paths`
+ // uses. A lookup that *failed* is not "signed out": the guard must step
+ // aside so the real fault keeps surfacing through the normal error path
+ // instead of being hidden behind a silent empty list.
+ let occupied = tmp.path().join("occupied");
+ std::fs::write(&occupied, "not a directory").unwrap();
+ let mut config = test_config(&tmp);
+ config.config_path = occupied.join("config.toml");
+ assert!(!backend_mode_without_session(&config));
+}