feat(agent): 实现摘要自动生成(SummaryConfig + 内联检查点)
SummaryConfig 6 字段配置(trigger_token_ratio / max_context_tokens / summary_prompt / debounce_turns / summary_model / max_tool_result_chars), AgentBuilder 链式 summary_config();AgentSession 在 submit_turn / finalize_turn 的 OnTurnEnd 之后内联检查点:水位 + 防抖(首次不受 约束)→ 独立 LlmCycle 调 submit_messages 生成摘要 → 写入 FocusedConfig.summary_override + slot.save() + SessionMemory 全局快照。 should_summarize 接收 current_turn 参数避免流式路径 turn_index 偏差; format_messages_as_text 简洁版格式化含 30K 整体截断保留最新;空消息 守卫直接返回空串。所有错误静默 tracing::error!,成功路径 tracing::info!。 src/agent/summary.rs 新增 ~240 行;agent/session.rs +428 行(双路径 检查点 + 关联函数 + 测试 + 公开 API)。零新外部依赖。全量 335 → 353 测试(+18 新测试),clippy 0 警告,doc 0 warning。两轮审查 PASS—— 第一轮 PM/SA 修复 11 项,第二轮 Code Reviewer 修复 9 项(含 🔴 generate_summary 空消息 bug + 🟡 5 项 + 💭 2 项)。方案文档 docs/ 22-phase16-summary-auto-generation.md(471 行);roadmap.md 标记 Phase 16 完成 + M12 里程碑达成。
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::agent::summary::SummaryConfig;
|
||||
use crate::llm::compact::CompactConfig;
|
||||
use crate::llm::hooks::HookExecutor;
|
||||
use crate::llm::provider::LlmProvider;
|
||||
@@ -33,6 +34,10 @@ pub struct AgentConfig {
|
||||
pub session_ttl: Option<Duration>,
|
||||
/// 上下文压缩配置(None 表示不启用自动压缩),默认 None。
|
||||
pub compact_config: Option<CompactConfig>,
|
||||
/// 摘要自动生成配置(`None` = 不启用)。
|
||||
/// 设置后 `AgentSession` 每轮 OnTurnEnd 之后进行水位 + 防抖检查,触发时调 LLM
|
||||
/// 生成摘要并写入 `FocusedConfig.summary_override` 与 `SessionMemory["conversation_summary"]`。
|
||||
pub summary_config: Option<SummaryConfig>,
|
||||
}
|
||||
|
||||
impl Default for AgentConfig {
|
||||
@@ -42,6 +47,7 @@ impl Default for AgentConfig {
|
||||
max_tool_turns: 10,
|
||||
session_ttl: None,
|
||||
compact_config: None,
|
||||
summary_config: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user