Skip to content

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

fix(composio): drop a loaded module's route when answering signed-out

Shanu5b344938b6d3
diff --git a/.claude/memory.md b/.claude/memory.md
index 8144196c5e..f261137543 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` 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`.
+- **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. Because the early answer skips the per-call `ensure_routed`, the guard branch also calls `modules::connectors::reconcile_route_if_loaded` (touches only a module whose `ops::state_of` is `Ready`; sends `{"route":"none"}` for a signed-out config) so a module configured while signed in drops the bearer on the next tick after sign-out — Codex P1 on PR#6178. 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/module_client.rs b/src/openhuman/integrations/composio/module_client.rs
index f6fecd6037..917461d38c 100644
--- a/src/openhuman/integrations/composio/module_client.rs
+++ b/src/openhuman/integrations/composio/module_client.rs
@@ -168,6 +168,30 @@ where
Err(format!("{member}: {WITHOUT_MODULES}"))
}
+/// Give an already-serving connector module the route the current config
+/// selects — for a signed-out user, that means dropping the credential it was
+/// configured with while signed in — without loading a module that is not
+/// serving. See `modules::connectors::reconcile_route_if_loaded`.
+///
+/// # Errors
+///
+/// As the module function: the module is serving but could not be reached or
+/// refused the reconfiguration.
+#[cfg(feature = "modules")]
+pub async fn reconcile_route_if_loaded(
+ config: &crate::openhuman::config::Config,
+) -> Result<(), String> {
+ crate::openhuman::modules::connectors::reconcile_route_if_loaded(config).await
+}
+
+/// Without the module loader there is no module holding a route. Always `Ok`.
+#[cfg(not(feature = "modules"))]
+pub async fn reconcile_route_if_loaded(
+ _config: &crate::openhuman::config::Config,
+) -> Result<(), String> {
+ Ok(())
+}
+
/// Call a member that takes no arguments.
///
/// # Errors
diff --git a/src/openhuman/integrations/composio/ops/connections.rs b/src/openhuman/integrations/composio/ops/connections.rs
index 28e356a98f..a64874cbdf 100644
--- a/src/openhuman/integrations/composio/ops/connections.rs
+++ b/src/openhuman/integrations/composio/ops/connections.rs
@@ -54,6 +54,17 @@ pub async fn composio_list_connections(
"[composio] list_connections: backend mode selected, not signed in yet \
— connections unavailable until sign-in (valid setup state, not reported)"
);
+ // A module configured while the user was signed in still holds that
+ // bearer, and the per-call route reconciliation that would tell it to
+ // drop it is exactly what answering here skips. Give an already-loaded
+ // module the instruction now; a module that was never loaded holds no
+ // credential and is not loaded for this.
+ if let Err(error) = connectors::reconcile_route_if_loaded(config).await {
+ tracing::warn!(
+ "[composio] list_connections: could not drop the connector module's route \
+ after sign-out ({error}); the next routed call retries"
+ );
+ }
return Err(COMPOSIO_NO_SESSION.to_string());
}
// The connector module owns the backend-proxied route. Direct mode stays
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 bc50e8f6b0..97ca47852a 100644
--- a/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
+++ b/src/openhuman/integrations/composio/ops_tests_part_01_tests.rs
@@ -304,6 +304,64 @@ async fn composio_list_connections_via_mock_counts_active() {
assert!(outcome.logs.iter().any(|l| l.contains("2 active")));
}
+#[cfg(feature = "modules")]
+#[tokio::test]
+async fn composio_list_connections_drops_the_module_route_once_signed_out() {
+ use crate::openhuman::integrations::composio::module_client::methods;
+ use crate::openhuman::modules::connectors::{last_route_is_none, proxy_without_reconcile};
+
+ let _serialised = module_guard().await;
+ let app = Router::new().route(
+ "/agent-integrations/composio/connections",
+ get(|| async {
+ Json(json!({
+ "success": true,
+ "data": {"connections": [{"id":"c1","toolkit":"gmail","status":"ACTIVE"}]}
+ }))
+ }),
+ );
+ let base = start_mock_backend(app).await;
+ let signed_in_tmp = tempfile::tempdir().unwrap();
+ let signed_in = config_with_backend(&signed_in_tmp, base);
+ // Signed in: the module is loaded and routed to the mock backend.
+ let outcome = composio_list_connections(&signed_in).await.unwrap();
+ assert_eq!(outcome.value.connections.len(), 1);
+ assert!(
+ !last_route_is_none(),
+ "the signed-in call must have routed the module"
+ );
+
+ // Signed out: a config whose auth store holds no session. The guard
+ // answers without a module call — but the module still holds the
+ // signed-in bearer, and telling it to drop that is the host's job (the
+ // module chooses no route on its own), so the guard must do so before
+ // answering.
+ let signed_out_tmp = tempfile::tempdir().unwrap();
+ let signed_out = test_config(&signed_out_tmp);
+ let err = composio_list_connections(&signed_out).await.unwrap_err();
+ assert!(err.contains("no backend session token"), "{err}");
+ assert!(
+ last_route_is_none(),
+ "the module must have been told to drop its route"
+ );
+ // And the module really did drop it: a proxy that does NOT reconcile the
+ // route first gets the module's own no-route answer, not the mock's list.
+ let proxy = proxy_without_reconcile()
+ .await
+ .expect("the module is serving");
+ let err = proxy
+ .call::<crate::openhuman::integrations::composio::types::ComposioConnectionsResponse>(
+ methods::LIST_CONNECTIONS,
+ (),
+ )
+ .await
+ .expect_err("a module without a route cannot list connections");
+ assert!(
+ err.to_string().contains("without a connector route"),
+ "{err}"
+ );
+}
+
#[tokio::test]
async fn composio_authorize_clears_pending_meta_connection_before_handoff() {
let _serialised = module_guard().await;
diff --git a/src/openhuman/modules/connectors.rs b/src/openhuman/modules/connectors.rs
index 8ebb26c881..25d247ed5e 100644
--- a/src/openhuman/modules/connectors.rs
+++ b/src/openhuman/modules/connectors.rs
@@ -35,6 +35,7 @@ use serde::Serialize;
use tinybus::Proxy;
use tinyconnectors_bus::names;
+use super::types::ModuleState;
use super::{ops, registry};
use crate::openhuman::config::schema::{COMPOSIO_MODE_BACKEND, COMPOSIO_MODE_DIRECT};
use crate::openhuman::config::Config;
@@ -211,19 +212,64 @@ async fn ensure_routed(config: &Config, proxy: &Proxy) -> Result<(), String> {
/// proxy.
pub async fn proxy(config: &Config) -> Result<Proxy, String> {
ops::ensure_loaded(config, MODULE_ID).await?;
+ let proxy = proxy_to_serving().await?;
+ ensure_routed(config, &proxy).await?;
+ Ok(proxy)
+}
+/// A proxy to the module as it is serving right now — no load, no route
+/// reconciliation. Callers decide which of those they need.
+async fn proxy_to_serving() -> Result<Proxy, String> {
let record =
registry::find(MODULE_ID).ok_or_else(|| format!("unknown module '{MODULE_ID}'"))?;
let runtime = super::host::runtime()
.await
.map_err(|error| format!("the module runtime is unavailable: {error}"))?;
-
- let proxy = runtime
+ runtime
.proxy(record.bus_name, record.object_path)
- .map_err(|error| format!("could not reach '{MODULE_ID}': {error}"))?;
+ .map_err(|error| format!("could not reach '{MODULE_ID}': {error}"))
+}
- ensure_routed(config, &proxy).await?;
- Ok(proxy)
+/// Give an already-serving module the route the current configuration
+/// selects, without loading a module that is not serving.
+///
+/// Every call reconciles the route (`ensure_routed`), and that is how sign-out
+/// reaches a module configured while the user was signed in: the next call
+/// sends `{"route": "none"}` and the module drops the bearer. A caller that
+/// answers a signed-out user itself — `composio_list_connections`, which the
+/// periodic sync drives every minute — makes no such call, so it uses this to
+/// give the instruction anyway; otherwise the credential would stay resident
+/// until some other member happened to be used. A module that was never
+/// loaded holds no credential, and boot is the wrong moment to download one,
+/// so a module that is not serving is left alone.
+///
+/// # Errors
+///
+/// Returns a message when the module is serving but could not be reached or
+/// refused the reconfiguration. Nothing is recorded in that case, so the next
+/// call retries.
+pub async fn reconcile_route_if_loaded(config: &Config) -> Result<(), String> {
+ if ops::state_of(MODULE_ID) != ModuleState::Ready {
+ return Ok(());
+ }
+ let proxy = proxy_to_serving().await?;
+ ensure_routed(config, &proxy).await
+}
+
+/// Whether the route the module last accepted is the signed-out one.
+#[cfg(test)]
+pub(crate) fn last_route_is_none() -> bool {
+ *last_route()
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ == Some(fingerprint(&serde_json::json!({ "route": "none" })))
+}
+
+/// A proxy to the serving module that does NOT reconcile the route first —
+/// for tests that need to observe what the module currently holds.
+#[cfg(test)]
+pub(crate) async fn proxy_without_reconcile() -> Result<Proxy, String> {
+ proxy_to_serving().await
}
/// Call one member with an argument and decode its reply.
diff --git a/src/openhuman/modules/connectors_tests.rs b/src/openhuman/modules/connectors_tests.rs
index 2d471734cb..034659ff3a 100644
--- a/src/openhuman/modules/connectors_tests.rs
+++ b/src/openhuman/modules/connectors_tests.rs
@@ -145,3 +145,17 @@ fn the_backend_route_needs_a_session() {
let error = module_config(&config).expect_err("no session token");
assert!(error.contains("Sign in"), "{error}");
}
+
+#[tokio::test]
+async fn reconciling_the_route_of_a_module_that_is_not_serving_loads_nothing() {
+ // One module instance per process — serialise with every test that
+ // reaches it, since a signed-out reconcile drops whatever route it holds.
+ let _serialised = crate::openhuman::integrations::composio::module_client::module_guard().await;
+ let before = crate::openhuman::modules::ops::state_of(MODULE_ID);
+ super::reconcile_route_if_loaded(&bare_config())
+ .await
+ .expect("nothing to reconcile is not a failure");
+ // A module that was not serving must not have been loaded to answer this;
+ // one that was serving stays serving.
+ assert_eq!(crate::openhuman::modules::ops::state_of(MODULE_ID), before);
+}