From 8a869f699088bacbcd3d01f967b2e5de77ba2752 Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 11 Apr 2026 12:51:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(reflection):=20=E9=99=8D=E4=BD=8E=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=A3=80=E6=B5=8B=E9=98=88=E5=80=BC=205=E2=86=923/20?= =?UTF-8?q?=E2=86=9215=20=E4=BB=A5=E4=BA=A7=E7=94=9F=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E6=9C=89=E6=84=8F=E4=B9=89=E5=8F=8D=E6=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - task/preference/lesson 累积: 5→3 - high-access memories: 3→2 - low-importance: >20 → >15 - 文案微调: "建议清理" → "可考虑清理" --- .../src-tauri/src/intelligence/reflection.rs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/desktop/src-tauri/src/intelligence/reflection.rs b/desktop/src-tauri/src/intelligence/reflection.rs index fe7a5c0..be5172f 100644 --- a/desktop/src-tauri/src/intelligence/reflection.rs +++ b/desktop/src-tauri/src/intelligence/reflection.rs @@ -390,7 +390,7 @@ impl ReflectionEngine { // Pattern: Too many tasks accumulating let task_count = *type_counts.get("task").unwrap_or(&0); - if task_count >= 5 { + if task_count >= 3 { let evidence: Vec = memories .iter() .filter(|m| m.memory_type == "task") @@ -408,7 +408,7 @@ impl ReflectionEngine { // Pattern: Strong preference accumulation let pref_count = *type_counts.get("preference").unwrap_or(&0); - if pref_count >= 5 { + if pref_count >= 3 { let evidence: Vec = memories .iter() .filter(|m| m.memory_type == "preference") @@ -426,7 +426,7 @@ impl ReflectionEngine { // Pattern: Many lessons learned let lesson_count = *type_counts.get("lesson").unwrap_or(&0); - if lesson_count >= 5 { + if lesson_count >= 3 { let evidence: Vec = memories .iter() .filter(|m| m.memory_type == "lesson") @@ -447,7 +447,7 @@ impl ReflectionEngine { .iter() .filter(|m| m.access_count >= 5 && m.importance >= 7) .collect(); - if high_access.len() >= 3 { + if high_access.len() >= 2 { let evidence: Vec = high_access.iter().take(3).map(|m| m.content.clone()).collect(); patterns.push(PatternObservation { @@ -460,9 +460,9 @@ impl ReflectionEngine { // Pattern: Low-importance memories accumulating let low_importance_count = memories.iter().filter(|m| m.importance <= 3).count(); - if low_importance_count > 20 { + if low_importance_count > 15 { patterns.push(PatternObservation { - observation: format!("有 {} 条低重要性记忆,建议清理", low_importance_count), + observation: format!("有 {} 条低重要性记忆,可考虑清理", low_importance_count), frequency: low_importance_count, sentiment: Sentiment::Neutral, evidence: vec![], @@ -721,6 +721,18 @@ pub fn pop_restored_result(agent_id: &str) -> Option { } } +/// Peek restored state from cache (non-destructive read) +pub fn peek_restored_state(agent_id: &str) -> Option { + let cache = get_state_cache(); + cache.read().ok()?.get(agent_id).cloned() +} + +/// Peek restored result from cache (non-destructive read) +pub fn peek_restored_result(agent_id: &str) -> Option { + let cache = get_result_cache(); + cache.read().ok()?.get(agent_id).cloned() +} + // === Tauri Commands === use tokio::sync::Mutex;