Skip to content

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

fix(composio): answer "not signed in" as unavailable, not as an empty list

Shanu6039e9ec9caa
diff --git a/.claude/memory.md b/.claude/memory.md
index 3a6322b346..8144196c5e 100644
--- a/.claude/memory.md
+++ b/.claude/memory.md
@@ -16,7 +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`.
+- **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` with the quiet `COMPOSIO_NO_SESSION` `Err` ("no backend session token", the wording `resolve_client` already uses, which `is_session_expired_message` demotes at the JSON-RPC boundary) and skips `report_composio_op_error` — NOT an `Ok(empty)`: Codex (PR#6178) pointed out that an empty success reads as authoritative to `memory::sources::reconcile` (`list_rpc` would hide every persisted Composio row) and to `flows::validate_connection_refs` (every `connection_ref` false-rejected), while `Err` keeps their documented fail-open path; direct-mode-without-key returns `Ok(empty)` only because no key ⇒ no tenant ⇒ truly no connections. 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. Also: 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 357459b61f..28e356a98f 100644
--- a/src/openhuman/integrations/composio/ops/connections.rs
+++ b/src/openhuman/integrations/composio/ops/connections.rs
@@ -18,6 +18,7 @@ use super::super::types::{
};
use super::error_utils::{
backend_mode_without_session, direct_mode_without_key, report_composio_op_error, OpResult,
+ COMPOSIO_NO_SESSION,
};
use super::memory_cleanup::composio_memory_targets_for_connection;
use tinymemory_api::composio::normalize_connection_identifier;
@@ -39,16 +40,21 @@ pub async fn composio_list_connections(
));
}
if backend_mode_without_session(config) {
+ // No session means no proxy route, so the connector module cannot
+ // answer — but the connections may well exist server-side. That makes
+ // this "unavailable", not "none": callers that tell the two apart
+ // (`memory::sources::reconcile` hides nothing on `Err`,
+ // `flows::validate_connection_refs` fails open on `Err`) must keep
+ // doing so, which an empty `Ok` would silently defeat. It is also not
+ // a fault, so it is not reported here: nothing reaches Sentry for a
+ // user who has simply not signed in yet (#6176). The wording is the one
+ // every other backend-mode member gives in this state, which the
+ // JSON-RPC boundary also recognises as expected.
tracing::debug!(
"[composio] list_connections: backend mode selected, not signed in yet \
- — returning empty connection list (valid setup state, not an error)"
+ — connections unavailable until sign-in (valid setup state, not reported)"
);
- return Ok(RpcOutcome::new(
- ComposioConnectionsResponse {
- connections: Vec::new(),
- },
- vec!["composio: backend mode — not signed in yet, 0 connection(s)".to_string()],
- ));
+ return Err(COMPOSIO_NO_SESSION.to_string());
}
// The connector module owns the backend-proxied route. Direct mode stays
// host-side because its client accepts the local loopback overrides used
diff --git a/src/openhuman/integrations/composio/ops/error_utils.rs b/src/openhuman/integrations/composio/ops/error_utils.rs
index 524ee13ba6..6e014ea066 100644
--- a/src/openhuman/integrations/composio/ops/error_utils.rs
+++ b/src/openhuman/integrations/composio/ops/error_utils.rs
@@ -30,14 +30,18 @@ pub(crate) fn should_forward_tags(toolkits: Option<&[String]>) -> bool {
/// Result alias used by every `composio_*` op in this module.
pub(super) type OpResult<T> = std::result::Result<T, String>;
+/// The answer every backend-mode member gives while there is no app-session
+/// JWT. Shared so the members agree on the wording, and because the wording is
+/// load-bearing: `is_session_expired_message` recognises "no backend session
+/// token", so the JSON-RPC boundary demotes this to an expected user-state
+/// error instead of paging Sentry.
+pub(crate) const COMPOSIO_NO_SESSION: &str =
+ "composio unavailable: no backend session token. Sign in first (auth_store_session).";
+
/// Resolve a backend-mode [`ComposioClient`] from the root config, or
/// return an error string that the caller can surface over RPC.
pub(crate) fn resolve_client(config: &Config) -> OpResult<ComposioClient> {
- build_composio_client(config).ok_or_else(|| {
- "composio unavailable: no backend session token. Sign in first \
- (auth_store_session)."
- .to_string()
- })
+ build_composio_client(config).ok_or_else(|| COMPOSIO_NO_SESSION.to_string())
}
/// True when the user has selected Composio **direct** mode but has not yet
@@ -84,8 +88,13 @@ pub(crate) fn direct_mode_without_key(config: &Config) -> OpResult<bool> {
/// 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.
+/// simply has not signed in (#6176). Callers answer with the quiet
+/// [`COMPOSIO_NO_SESSION`] error instead — deliberately not an empty list,
+/// unlike the direct-mode guard: no key means no tenant and truly no
+/// connections, whereas no session only means the connections cannot be
+/// reached yet, and `memory::sources::reconcile` /
+/// `flows::validate_connection_refs` rely on `Err` meaning "unknown" (fail
+/// open) rather than "none".
///
/// Session presence MUST mirror the module route's own resolution:
/// `module_config` calls `integrations::build_client`, whose only token source
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 b22576bd7a..bc50e8f6b0 100644
--- a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
+++ b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
@@ -83,28 +83,31 @@ async fn composio_list_capabilities_does_not_require_session() {
}
#[tokio::test]
-async fn composio_list_connections_returns_empty_without_session() {
+async fn composio_list_connections_is_quietly_unavailable_without_session() {
let _serialised = module_guard().await;
let tmp = tempfile::tempdir().unwrap();
let config = test_config(&tmp);
// 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");
+ // signed-out state, not a failure. The connector module has no proxy route
+ // to be given, so before #6176 this call reached the module and reported its
+ // "loaded without a connector route" answer at error level on every boot
+ // and periodic tick. Now the guard answers first with the same "no backend
+ // session token" error every other member gives here: still an `Err` — the
+ // connections may exist server-side, so "unavailable" is the truthful
+ // answer and the reconcile / flows callers keep their fail-open handling —
+ // but nothing is reported to Sentry, and the JSON-RPC boundary demotes the
+ // wording as expected user state (`is_session_expired_message`).
+ let err = composio_list_connections(&config).await.unwrap_err();
assert!(
- outcome.value.connections.is_empty(),
- "no session → no route → no connections"
+ err.contains("no backend session token"),
+ "the error should say what is missing: {err}"
);
+ // The module's own wording is what used to be reported at error level; its
+ // absence proves the call never reached the module (and so never reached
+ // `report_composio_op_error`).
assert!(
- 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
+ !err.contains("loaded without a connector route"),
+ "the guard must answer before the connector module does: {err}"
);
}