MCPcopy Create free account
hub / github.com/AI45Lab/Code / memory_recent

Method memory_recent

sdk/python/src/lib.rs:3121–3138  ·  view source on GitHub ↗
(&self, py: Python<'py>, limit: usize)

Source from the content-addressed store, hash-verified

3119 /// List of memory item dicts.
3120 #[pyo3(signature = (limit=10))]
3121 fn memory_recent<'py>(&self, py: Python<'py>, limit: usize) -> PyResult<Bound<'py, PyList>> {
3122 let memory = self
3123 .inner
3124 .memory()
3125 .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))?
3126 .clone();
3127 let items = py
3128 .allow_threads(move || get_runtime().block_on(memory.get_recent(limit)))
3129 .map_err(|e| PyRuntimeError::new_err(format!("Recall failed: {e}")))?;
3130 let json_str = serde_json::to_string(&items)
3131 .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?;
3132 let json_mod = py.import("json")?;
3133 let py_obj = json_mod.call_method1("loads", (json_str,))?;
3134 py_obj
3135 .downcast::<PyList>()
3136 .cloned()
3137 .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}")))
3138 }
3139
3140 /// Get memory statistics.
3141 ///

Callers

nothing calls this directly

Calls 5

block_onMethod · 0.80
get_recentMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
memoryMethod · 0.45

Tested by

no test coverage detected