Skip to content

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

fix(memory): let a source sync outlive 30 s, and hand the module real cloud defaults

Shanudcca71e6787e
diff --git a/app/src/services/memorySourcesService.test.ts b/app/src/services/memorySourcesService.test.ts
index a899c85ea9..4a590403bf 100644
--- a/app/src/services/memorySourcesService.test.ts
+++ b/app/src/services/memorySourcesService.test.ts
@@ -10,6 +10,7 @@ import {
ingestCodingSessions,
isIngestTimeout,
listMemorySources,
+ MEMORY_SYNC_RPC_TIMEOUT_MS,
type MemorySourceEntry,
removeMemorySource,
SOURCE_KIND_ICONS,
@@ -142,7 +143,10 @@ describe('memorySourcesService', () => {
const result = await applyAllIn();
- expect(mockedCall).toHaveBeenCalledWith({ method: 'openhuman.memory_sources_apply_all_in' });
+ expect(mockedCall).toHaveBeenCalledWith({
+ method: 'openhuman.memory_sources_apply_all_in',
+ timeoutMs: MEMORY_SYNC_RPC_TIMEOUT_MS,
+ });
expect(result.sync_triggered).toBe(1);
expect(result.sources).toHaveLength(1);
expect(result.sources[0].id).toBe('src_1');
diff --git a/app/src/services/memorySourcesService.ts b/app/src/services/memorySourcesService.ts
index 0177b43ccd..55310b8b8c 100644
--- a/app/src/services/memorySourcesService.ts
+++ b/app/src/services/memorySourcesService.ts
@@ -159,11 +159,25 @@ export async function memorySourcesStatusList(): Promise<SourceStatus[]> {
return data.statuses ?? [];
}
+/**
+ * Per-call budget for the RPCs that run a whole source sync before answering
+ * (`memory_sources_sync`, `memory_sources_apply_all_in`).
+ *
+ * The client's default per-call timeout is 30 s and one Gmail page alone takes
+ * ~31 s end to end, so the default aborted the fetch while the core kept
+ * syncing: the row flipped to "failed" for work that then completed, and the
+ * run never showed as done (#5820). This is the client's own clamp ceiling
+ * (`PER_CALL_TIMEOUT_MAX_MS`); the core's bus deadline is sized to outlast it
+ * so this abort, with its clean message, is the one that fires if a run wedges.
+ */
+export const MEMORY_SYNC_RPC_TIMEOUT_MS = 10 * 60 * 1_000;
+
export async function syncMemorySource(sourceId: string): Promise<void> {
log('sync source_id=%s', sourceId);
await callCoreRpc<{ requested: boolean }>({
method: 'openhuman.memory_sources_sync',
params: { source_id: sourceId },
+ timeoutMs: MEMORY_SYNC_RPC_TIMEOUT_MS,
});
}
@@ -203,8 +217,11 @@ export interface ApplyAllInResult {
*/
export async function applyAllIn(): Promise<ApplyAllInResult> {
log('apply_all_in');
+ // All In runs every enabled source's sync to completion, one after another,
+ // before it answers; the budget has to cover the whole sweep.
const resp = await callCoreRpc<ApplyAllInResult>({
method: 'openhuman.memory_sources_apply_all_in',
+ timeoutMs: MEMORY_SYNC_RPC_TIMEOUT_MS,
});
const data = unwrap<ApplyAllInResult>(resp);
return {
diff --git a/src/openhuman/inference/embeddings/factory.rs b/src/openhuman/inference/embeddings/factory.rs
index 0020713f93..4415884ebb 100644
--- a/src/openhuman/inference/embeddings/factory.rs
+++ b/src/openhuman/inference/embeddings/factory.rs
@@ -38,6 +38,17 @@ pub(crate) fn model_supports_dimensions(model: &str) -> bool {
model.starts_with("text-embedding-3-")
}
+/// The members of that family, by name, for a consumer that cannot call the
+/// predicate.
+///
+/// The tinymemory module's `EmbeddingHost::model_supports_dimensions` is
+/// synchronous and runs inside the module, so it is told a list at load time
+/// (`modules::ops::module_config`) rather than asking over the bus. Absent from
+/// the list means "does not support it", the safe direction: the engine omits
+/// the parameter instead of writing a batch the provider rejects halfway.
+pub(crate) const MODELS_SUPPORTING_DIMENSIONS: [&str; 2] =
+ ["text-embedding-3-small", "text-embedding-3-large"];
+
/// Creates an embedding provider based on the specified name and configuration.
///
/// Supported provider names:
diff --git a/src/openhuman/inference/embeddings/mod.rs b/src/openhuman/inference/embeddings/mod.rs
index 7a4cfa39bc..85c26eab4f 100644
--- a/src/openhuman/inference/embeddings/mod.rs
+++ b/src/openhuman/inference/embeddings/mod.rs
@@ -50,7 +50,7 @@ pub use factory::{
// configs whose dimension the fixed-1024 tree can't store (#4056). Not part of
// the public surface, so it can't ride the `pub use` above (E0364).
// Its sole caller is `memory::host_impls`, which is unconditional again.
-pub(crate) use factory::model_supports_dimensions;
+pub(crate) use factory::{model_supports_dimensions, MODELS_SUPPORTING_DIMENSIONS};
// #002 FR-015: the memory-tree OpenAI-compat embedder reuses the same key
// resolution the embeddings RPC uses, so there is one source of truth.
pub use noop::NoopEmbedding;
diff --git a/src/openhuman/modules/memory.rs b/src/openhuman/modules/memory.rs
index 0f5cf85c20..2d82161f29 100644
--- a/src/openhuman/modules/memory.rs
+++ b/src/openhuman/modules/memory.rs
@@ -1091,6 +1091,26 @@ impl MemoryMaintenance for ModuleMemoryProvider {
}
}
+/// Bus deadline for the three calls that run a whole source sync inside the
+/// module: `RunConnectionSync`, `RunSourceSync` and `BootstrapConnection`.
+///
+/// tinybus gives every call a 30 s default deadline if nobody sets one, and a
+/// sync is routinely longer than that: one Gmail page is ~31 s end to end, an
+/// initial bootstrap of a connection is minutes. With the default, the caller
+/// was released with "call to `RunSourceSync` timed out after 30000ms" while
+/// the module kept fetching and ingesting, and finished; the UI reported a
+/// failure for work that succeeded (openhuman#5820). Same failure class, same
+/// fix as `IngestCodingSessions` above: the deadline here is the wedged-forever
+/// backstop tinybus requires, not a ceiling anyone is meant to hit.
+///
+/// Sized from the frontend's clamp, `PER_CALL_TIMEOUT_MAX_MS = 600 s`
+/// (`app/src/services/coreRpcClient.ts`): that is the longest wait any RPC
+/// caller can observe, so the bus must outlast it, plus [`INGEST_BUS_GRACE`]
+/// so the client's own abort, with its clean message, is the one that fires
+/// first when a run really does wedge.
+const SOURCE_SYNC_BUS_TIMEOUT: std::time::Duration =
+ std::time::Duration::from_secs(600).saturating_add(INGEST_BUS_GRACE);
+
#[async_trait]
impl MemorySourceSync for ModuleMemoryProvider {
async fn run_connection_sync(
@@ -1098,27 +1118,32 @@ impl MemorySourceSync for ModuleMemoryProvider {
toolkit: &str,
connection_id: &str,
) -> Result<SyncRunOutcome, MemoryError> {
- module_call!(
- self,
- "run_connection_sync",
- "RunConnectionSync",
- (toolkit, connection_id)
- )
+ self.proxy("run_connection_sync")
+ .await?
+ .with_timeout(SOURCE_SYNC_BUS_TIMEOUT)
+ .call("RunConnectionSync", (toolkit, connection_id))
+ .await
+ .map_err(|error| from_bus(&error))
}
async fn run_source_sync(&self, source_id: &str) -> Result<SyncRunOutcome, MemoryError> {
- module_call!(self, "run_source_sync", "RunSourceSync", (source_id,))
+ self.proxy("run_source_sync")
+ .await?
+ .with_timeout(SOURCE_SYNC_BUS_TIMEOUT)
+ .call("RunSourceSync", (source_id,))
+ .await
+ .map_err(|error| from_bus(&error))
}
async fn bootstrap_connection(
&self,
toolkit: &str,
connection_id: &str,
) -> Result<(), MemoryError> {
- module_call!(
- self,
- "bootstrap_connection",
- "BootstrapConnection",
- (toolkit, connection_id)
- )
+ self.proxy("bootstrap_connection")
+ .await?
+ .with_timeout(SOURCE_SYNC_BUS_TIMEOUT)
+ .call("BootstrapConnection", (toolkit, connection_id))
+ .await
+ .map_err(|error| from_bus(&error))
}
async fn is_toolkit_syncable(&self, toolkit: &str) -> Result<bool, MemoryError> {
module_call!(self, "is_toolkit_syncable", "IsToolkitSyncable", (toolkit,))
diff --git a/src/openhuman/modules/memory_host_tests.rs b/src/openhuman/modules/memory_host_tests.rs
index b1a1711f62..7c0fa19219 100644
--- a/src/openhuman/modules/memory_host_tests.rs
+++ b/src/openhuman/modules/memory_host_tests.rs
@@ -17,8 +17,8 @@
//! can be honest, in `tinymemory`'s own module E2E against a real module.
use super::{
- serve_interfaces, ComposioCallbacks, CHAT_NAME, CHAT_PATH, COMPOSIO_NAME, COMPOSIO_PATH,
- EMBEDDING_NAME, EMBEDDING_PATH, RUNTIME_NAME, RUNTIME_PATH,
+ serve_interfaces, ComposioCallbacks, EmbeddingCallbacks, CHAT_NAME, CHAT_PATH, COMPOSIO_NAME,
+ COMPOSIO_PATH, EMBEDDING_NAME, EMBEDDING_PATH, RUNTIME_NAME, RUNTIME_PATH,
};
use crate::openhuman::config::Config;
use crate::openhuman::integrations::composio::client::create_composio_client;
@@ -299,3 +299,41 @@ async fn execute_forwards_an_absent_connection_pin_as_absent() {
assert_eq!(error.wire_name(), HOST_ERROR, "{error}");
}
}
+
+#[tokio::test]
+async fn embed_takes_its_four_arguments_in_the_order_the_module_sends_them() {
+ // `Embed` is `(provider, model, dimensions, texts)`. The module shipped
+ // sending three — `(model, dimensions, texts)` — so `dimensions` landed in
+ // `model` and every call was refused at decode with "invalid type:
+ // integer, expected a string"; nothing ingested in module mode got a vector
+ // (#5820). Same cheapest-honest-check as `Execute` above: the right arity
+ // gets as far as the host's provider factory, the wrong one never does.
+ let dir = tempfile::tempdir().expect("tempdir");
+ let callbacks = EmbeddingCallbacks(scoped_config(dir.path()));
+
+ let error = callbacks
+ .call(
+ &MemberName::new("Embed").expect("member name"),
+ json!(["no-such-provider", "some-model", 4, ["alpha"]]),
+ )
+ .await
+ .expect_err("an unknown provider slug fails inside the host's factory");
+ assert_eq!(
+ error.wire_name(),
+ HOST_ERROR,
+ "a well-formed call must reach the host's provider factory: {error}"
+ );
+
+ let error = callbacks
+ .call(
+ &MemberName::new("Embed").expect("member name"),
+ json!(["some-model", 4, ["alpha"]]),
+ )
+ .await
+ .expect_err("the module's old three-argument form is malformed");
+ assert_eq!(
+ error.wire_name(),
+ "ai.tinyhumans.tinybus.Error.BadArguments",
+ "a malformed call must be refused at decode, not inside the host: {error}"
+ );
+}
diff --git a/src/openhuman/modules/ops.rs b/src/openhuman/modules/ops.rs
index be363ca580..6618cfb108 100644
--- a/src/openhuman/modules/ops.rs
+++ b/src/openhuman/modules/ops.rs
@@ -289,9 +289,20 @@ fn module_config(config: &Config, id: &str) -> serde_json::Value {
"embedding_routes": config.embedding_routes,
"storage_provider": config.storage.provider.config,
"ollama_base_url": crate::openhuman::inference::local::ollama_base_url_from_config(config),
- "cloud_embedding_model": config.memory.embedding_model,
- "cloud_embedding_dimensions": config.memory.embedding_dimensions,
- "models_supporting_dimensions": [],
+ // The module's `EmbeddingHost::default_cloud_embedding_model`: what the
+ // engine switches to when the opted-in local model is unreachable
+ // (`store::factories`). That is the host's managed-cloud default, the
+ // same constant the in-process `OpenHumanEmbeddingHost` answers with.
+ // It is NOT `config.memory.embedding_model`, which is the user's
+ // intended model and is usually the local one; sending that here made
+ // the cloud fallback ask the managed embedder for `nomic-embed-text`
+ // (openhuman#5820).
+ "cloud_embedding_model":
+ crate::openhuman::inference::embeddings::DEFAULT_CLOUD_EMBEDDING_MODEL,
+ "cloud_embedding_dimensions":
+ crate::openhuman::inference::embeddings::DEFAULT_CLOUD_EMBEDDING_DIMENSIONS,
+ "models_supporting_dimensions":
+ crate::openhuman::inference::embeddings::MODELS_SUPPORTING_DIMENSIONS,
// The periodic composio and workspace-source sync loops run INSIDE the
// module now (tinymemory#100), and these three are what let them run at
// all. Without the cadence the module answers manual-only and skips
diff --git a/src/openhuman/modules/ops_tests.rs b/src/openhuman/modules/ops_tests.rs
index e6c907e24c..45083d0e28 100644
--- a/src/openhuman/modules/ops_tests.rs
+++ b/src/openhuman/modules/ops_tests.rs
@@ -144,3 +144,37 @@ fn errors_never_leak_a_path_or_a_url() {
);
}
}
+
+#[test]
+fn module_config_hands_the_module_the_hosts_cloud_embedding_defaults() {
+ // `cloud_embedding_model` is what the module's engine falls back to when
+ // the opted-in local model is unreachable, so it must be the host's
+ // managed-cloud default, never the user's intended (usually local) model.
+ // Sending `config.memory.embedding_model` here made the fallback ask the
+ // managed embedder for `nomic-embed-text` (#5820).
+ let mut config = offline_config();
+ config.memory.embedding_model = "nomic-embed-text:latest".to_string();
+ config.memory.embedding_dimensions = 768;
+
+ let sent = ops::module_config(&config, crate::openhuman::modules::memory::MODULE_ID);
+
+ assert_eq!(
+ sent["cloud_embedding_model"],
+ crate::openhuman::inference::embeddings::DEFAULT_CLOUD_EMBEDDING_MODEL
+ );
+ assert_eq!(
+ sent["cloud_embedding_dimensions"],
+ crate::openhuman::inference::embeddings::DEFAULT_CLOUD_EMBEDDING_DIMENSIONS
+ );
+ let supports = sent["models_supporting_dimensions"]
+ .as_array()
+ .expect("a list of model ids");
+ assert!(
+ supports
+ .iter()
+ .any(|model| model == "text-embedding-3-large"),
+ "the dimension-aware family is named: {supports:?}"
+ );
+ // The user's own model still travels, just not as the cloud fallback.
+ assert_eq!(sent["memory"]["embedding_model"], "nomic-embed-text:latest");
+}