Skip to content

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

refactor(helpers): replace raw client call with policy-aware document listing\n\nChanged `query_limit_for_request` to use `MemoryDocuments::list_documents` through the `MemoryGuard` instead of calling `list_documents` directly on the raw `MemoryClient`. This ensures the document count used for over-fetching the retrieval limit runs through the same policy enforcement steps as the main query path, making the limit calculation consistent with the actual filtered results.\n\nAuto-committed-on: dragonfly\n

Steven Enamakelb305d242d4ad
diff --git a/src/openhuman/memory/ops/helpers.rs b/src/openhuman/memory/ops/helpers.rs
index e8eda41f46..69061fdda0 100644
--- a/src/openhuman/memory/ops/helpers.rs
+++ b/src/openhuman/memory/ops/helpers.rs
@@ -532,16 +532,27 @@ pub(crate) fn parse_memory_document_summaries(
.collect()
}
+/// Resolve the retrieval limit, over-fetching when the caller filtered on
+/// document ids so the filter has enough candidates to work with.
+///
+/// Takes the **guard**, not a `MemoryClient`: `MemoryDocuments::list_documents`
+/// is the contract twin of the call this used to make, returns the same
+/// `serde_json::Value`, and runs the read through the policy steps the raw
+/// client skipped.
pub(crate) async fn query_limit_for_request(
- client: &MemoryClient,
+ guard: &crate::openhuman::memory::guard::MemoryGuard,
request: &QueryNamespaceRequest,
) -> Result<u32, String> {
+ use tinymemory_api::provider::MemoryDocuments;
+
let requested = request.resolved_limit();
if request.document_ids.is_none() {
return Ok(requested);
}
- let raw = client.list_documents(Some(&request.namespace)).await?;
+ let raw = MemoryDocuments::list_documents(guard, Some(&request.namespace))
+ .await
+ .map_err(|e| e.to_string())?;
let documents = parse_memory_document_summaries(raw)?;
let total_documents = u32::try_from(documents.len()).unwrap_or(u32::MAX);
Ok(requested.max(total_documents))