feat(intelligence): Phase 5 主动行为激活 — 注入格式 + 跨会话连续性 + 触发持久化
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Task 5.1+5.4: ButlerRouter/experience 注入格式升级为 <butler-context> XML fencing - butler_router: [路由上下文] → <butler-context><routing>...</routing></butler-context> - experience: [过往经验] → <butler-context><experience>...</experience></butler-context> - 统一 system-note 提示,引导 LLM 自然运用上下文 Task 5.2: 跨会话连续性 — pre_conversation_hook 注入活跃痛点 + 相关经验 - 从 VikingStorage 检索相关记忆(相似度>=0.3) - 从 pain_aggregator 获取 High severity 痛点(top 3) Task 5.3: 触发信号持久化 — post_conversation_hook 将触发信号存入 VikingStorage - store_trigger_experience(): 模板提取,零 LLM 成本 - 为未来 LLM 深度反思积累数据基础
This commit is contained in:
@@ -204,6 +204,7 @@ impl ExperienceExtractor {
|
||||
|
||||
/// Format experiences for system prompt injection.
|
||||
/// Returns a concise block capped at ~200 Chinese characters.
|
||||
/// Uses `<butler-context>` XML fencing for structured injection.
|
||||
/// Includes industry context when available.
|
||||
pub fn format_for_injection(
|
||||
experiences: &[zclaw_growth::experience_store::Experience],
|
||||
@@ -224,14 +225,14 @@ impl ExperienceExtractor {
|
||||
.map(|s| truncate(s, 40))
|
||||
.unwrap_or_default();
|
||||
let industry_tag = exp.industry_context.as_ref()
|
||||
.map(|i| format!(", 行业:{}", i))
|
||||
.map(|i| format!(" 行业:{}", i))
|
||||
.unwrap_or_default();
|
||||
let line = format!(
|
||||
"[过往经验{}] 类似「{}」做过:{},结果是{}",
|
||||
industry_tag,
|
||||
"- 类似「{}」做过:{},结果是{} ({})",
|
||||
truncate(&exp.pain_pattern, 30),
|
||||
step_summary,
|
||||
exp.outcome
|
||||
exp.outcome,
|
||||
industry_tag.trim_start()
|
||||
);
|
||||
total_chars += line.chars().count();
|
||||
parts.push(line);
|
||||
@@ -241,7 +242,10 @@ impl ExperienceExtractor {
|
||||
return String::new();
|
||||
}
|
||||
|
||||
format!("\n\n--- 过往经验参考 ---\n{}", parts.join("\n"))
|
||||
format!(
|
||||
"\n\n<butler-context>\n<experience>\n{}\n</experience>\n</butler-context>",
|
||||
parts.join("\n")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +349,8 @@ mod tests {
|
||||
"成功解决",
|
||||
);
|
||||
let formatted = ExperienceExtractor::format_for_injection(&[exp]);
|
||||
assert!(formatted.contains("过往经验"));
|
||||
assert!(formatted.contains("butler-context"));
|
||||
assert!(formatted.contains("experience"));
|
||||
assert!(formatted.contains("出口包装问题"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user