{"record":{"id":"77e9c54b584289b6","repo":"tinyhumansai/openhuman","slug":"learning-reset-cache-e","errorCode":null,"errorMessage":"learning_reset_cache: {e:#}","messagePattern":"learning_reset_cache: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/learning/tools.rs","lineNumber":473,"sourceCode":"        \"Delete every automatically-managed facet from the cache, preserving \\\n         only user-pinned facets. Irreversible. Only use when the user wants to \\\n         wipe the assistant's learned model of them.\"\n    }\n\n    fn parameters_schema(&self) -> serde_json::Value {\n        json!({ \"type\": \"object\", \"properties\": {} })\n    }\n\n    fn permission_level(&self) -> PermissionLevel {\n        PermissionLevel::Dangerous\n    }\n\n    async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {\n        log::debug!(\"[tool][learning] reset_cache invoked\");\n        let cache = get_cache()?;\n        let all = cache\n            .list_all()\n            .map_err(|e| anyhow::anyhow!(\"learning_reset_cache: {e:#}\"))?;\n        let pinned_preserved = all\n            .iter()\n            .filter(|f| f.user_state == UserState::Pinned)\n            .count();\n        let mut deleted = 0usize;\n        for f in &all {\n            if f.user_state != UserState::Pinned && cache.delete(&f.key).unwrap_or(false) {\n                deleted += 1;\n            }\n        }\n        Ok(ToolResult::success(serde_json::to_string(&json!({\n            \"deleted\": deleted,\n            \"pinned_preserved\": pinned_preserved,\n        }))?))\n    }\n}\n\n/// Write PROFILE.md from supplied markdown. Default-OFF.","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/src/openhuman/agent/learning/tools.rs#L455-L491","documentation":"Thrown by learning_reset_cache when FacetCache::list_all() fails before any deletion happens. reset_cache is the Dangerous-permission, default-OFF tool that deletes every non-Pinned facet; it must first enumerate all rows, and that read failed. Note the asymmetry: only list_all errors surface — per-row delete failures are swallowed by unwrap_or(false) and merely count as not-deleted.","triggerScenarios":"Invoking learning_reset_cache while a rebuild or reflection cycle holds/writes the DB; unreadable or corrupted user_profile table; workspace DB missing. Requires the learning_manage tool toggle to even be reachable.","commonSituations":"User-initiated cache wipe colliding with the nightly stability cycle; reset attempted during core startup before the memory store finished opening.","solutions":["Retry the reset when no rebuild/reflection cycle is running","Verify the store is reachable first via learning_cache_stats (cheap read of the same table)","Check the returned 'deleted' count after a successful run — swallowed delete errors under-report, so spot-check with learning_list_facets"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-flight: the same table must be readable before a destructive reset\ntool_exec(\"learning_cache_stats\", json!({})).await?; // Err => do not reset\ntool_exec(\"learning_list_facets\", json!({})).await?;  // note pinned facets to preserve","typeGuard":null,"tryCatchPattern":"match tool_exec(\"learning_reset_cache\", json!({})).await {\n    Ok(res) => { /* verify: deleted + surviving rows should equal pre-flight list length */ }\n    Err(e) => { /* nothing was deleted (failure precedes deletion) — resolve store health, retry */ }\n}","preventionTips":["Pin facets you care about before reset — reset deletes every non-Pinned row","Remember per-row delete errors are swallowed (unwrap_or(false)): verify the survivor list afterwards with learning_list_facets","Requires the learning_manage tool toggle and Dangerous permission — keep it default-OFF in production agent configs"],"tags":["rust","sqlite","learning","reset","dangerous-tool"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}