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

Method memory_stats

sdk/python/src/lib.rs:3144–3161  ·  view source on GitHub ↗

Get memory statistics. Returns: Dict with long_term_count, short_term_count, working_count.

(&self, py: Python<'py>)

Source from the content-addressed store, hash-verified

3142 /// Returns:
3143 /// Dict with long_term_count, short_term_count, working_count.
3144 fn memory_stats<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyDict>> {
3145 let memory = self
3146 .inner
3147 .memory()
3148 .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))?
3149 .clone();
3150 let stats = py
3151 .allow_threads(move || get_runtime().block_on(memory.stats()))
3152 .map_err(|e| PyRuntimeError::new_err(format!("Stats failed: {e}")))?;
3153 let json_str = serde_json::to_string(&stats)
3154 .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?;
3155 let json_mod = py.import("json")?;
3156 let py_obj = json_mod.call_method1("loads", (json_str,))?;
3157 py_obj
3158 .downcast::<PyDict>()
3159 .cloned()
3160 .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}")))
3161 }
3162
3163 /// Get current working memory items.
3164 ///

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected