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

Method get_working

sdk/python/src/lib.rs:3169–3184  ·  view source on GitHub ↗

Get current working memory items. Working memory holds the active context items for the current task. Returns: List of memory item dicts currently in working memory.

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

Source from the content-addressed store, hash-verified

3167 /// Returns:
3168 /// List of memory item dicts currently in working memory.
3169 fn get_working<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyList>> {
3170 let memory = self
3171 .inner
3172 .memory()
3173 .ok_or_else(|| PyRuntimeError::new_err("Memory not configured for this session"))?
3174 .clone();
3175 let items = py.allow_threads(move || get_runtime().block_on(memory.get_working()));
3176 let json_str = serde_json::to_string(&items)
3177 .map_err(|e| PyRuntimeError::new_err(format!("Serialization error: {e}")))?;
3178 let json_mod = py.import("json")?;
3179 let py_obj = json_mod.call_method1("loads", (json_str,))?;
3180 py_obj
3181 .downcast::<PyList>()
3182 .cloned()
3183 .map_err(|e| PyRuntimeError::new_err(format!("Unexpected result: {e}")))
3184 }
3185
3186 /// Clear working memory.
3187 ///

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected