fix(reflection): 降低模式检测阈值 5→3/20→15 以产生更多有意义反思
- task/preference/lesson 累积: 5→3 - high-access memories: 3→2 - low-importance: >20 → >15 - 文案微调: "建议清理" → "可考虑清理"
This commit is contained in:
@@ -390,7 +390,7 @@ impl ReflectionEngine {
|
|||||||
|
|
||||||
// Pattern: Too many tasks accumulating
|
// Pattern: Too many tasks accumulating
|
||||||
let task_count = *type_counts.get("task").unwrap_or(&0);
|
let task_count = *type_counts.get("task").unwrap_or(&0);
|
||||||
if task_count >= 5 {
|
if task_count >= 3 {
|
||||||
let evidence: Vec<String> = memories
|
let evidence: Vec<String> = memories
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|m| m.memory_type == "task")
|
.filter(|m| m.memory_type == "task")
|
||||||
@@ -408,7 +408,7 @@ impl ReflectionEngine {
|
|||||||
|
|
||||||
// Pattern: Strong preference accumulation
|
// Pattern: Strong preference accumulation
|
||||||
let pref_count = *type_counts.get("preference").unwrap_or(&0);
|
let pref_count = *type_counts.get("preference").unwrap_or(&0);
|
||||||
if pref_count >= 5 {
|
if pref_count >= 3 {
|
||||||
let evidence: Vec<String> = memories
|
let evidence: Vec<String> = memories
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|m| m.memory_type == "preference")
|
.filter(|m| m.memory_type == "preference")
|
||||||
@@ -426,7 +426,7 @@ impl ReflectionEngine {
|
|||||||
|
|
||||||
// Pattern: Many lessons learned
|
// Pattern: Many lessons learned
|
||||||
let lesson_count = *type_counts.get("lesson").unwrap_or(&0);
|
let lesson_count = *type_counts.get("lesson").unwrap_or(&0);
|
||||||
if lesson_count >= 5 {
|
if lesson_count >= 3 {
|
||||||
let evidence: Vec<String> = memories
|
let evidence: Vec<String> = memories
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|m| m.memory_type == "lesson")
|
.filter(|m| m.memory_type == "lesson")
|
||||||
@@ -447,7 +447,7 @@ impl ReflectionEngine {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|m| m.access_count >= 5 && m.importance >= 7)
|
.filter(|m| m.access_count >= 5 && m.importance >= 7)
|
||||||
.collect();
|
.collect();
|
||||||
if high_access.len() >= 3 {
|
if high_access.len() >= 2 {
|
||||||
let evidence: Vec<String> = high_access.iter().take(3).map(|m| m.content.clone()).collect();
|
let evidence: Vec<String> = high_access.iter().take(3).map(|m| m.content.clone()).collect();
|
||||||
|
|
||||||
patterns.push(PatternObservation {
|
patterns.push(PatternObservation {
|
||||||
@@ -460,9 +460,9 @@ impl ReflectionEngine {
|
|||||||
|
|
||||||
// Pattern: Low-importance memories accumulating
|
// Pattern: Low-importance memories accumulating
|
||||||
let low_importance_count = memories.iter().filter(|m| m.importance <= 3).count();
|
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 {
|
patterns.push(PatternObservation {
|
||||||
observation: format!("有 {} 条低重要性记忆,建议清理", low_importance_count),
|
observation: format!("有 {} 条低重要性记忆,可考虑清理", low_importance_count),
|
||||||
frequency: low_importance_count,
|
frequency: low_importance_count,
|
||||||
sentiment: Sentiment::Neutral,
|
sentiment: Sentiment::Neutral,
|
||||||
evidence: vec![],
|
evidence: vec![],
|
||||||
@@ -721,6 +721,18 @@ pub fn pop_restored_result(agent_id: &str) -> Option<ReflectionResult> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Peek restored state from cache (non-destructive read)
|
||||||
|
pub fn peek_restored_state(agent_id: &str) -> Option<ReflectionState> {
|
||||||
|
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<ReflectionResult> {
|
||||||
|
let cache = get_result_cache();
|
||||||
|
cache.read().ok()?.get(agent_id).cloned()
|
||||||
|
}
|
||||||
|
|
||||||
// === Tauri Commands ===
|
// === Tauri Commands ===
|
||||||
|
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|||||||
Reference in New Issue
Block a user