Files
agcore/src/agent.rs
T
徐涛 cc1c68b69d 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 里程碑达成。
2026-07-10 06:43:06 +08:00

36 lines
1.2 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Agent Runtime —— 智能体(Agent)核心胶水层。
//!
//! 把 Phase 0-3 的能力(LlmCycle / ToolRegistry / MemoryStore / HookExecutor"装配"为
//! 上层可用的智能体抽象:`Agent` / `AgentSession` / `RuntimeBundle` / `AgentBuilder` / `Plan`。
//!
//! **不**实现业务循环,**不**假设上层如何使用 memory。
//! 详细设计见 `docs/7-agent-runtime.md`。
// 模块根文件 `agent.rs` 与子模块 `agent/agent.rs` 同名(项目惯例,与 `llm/cycle.rs` 一致)。
#![allow(clippy::module_inception)]
pub mod agent;
pub mod builder;
pub mod context;
pub mod error;
pub mod runtime;
pub mod session;
pub mod session_memory;
pub mod summary;
pub mod task;
// 重导出公共 API(按使用频度排序)
pub use agent::Agent;
pub use builder::AgentBuilder;
pub use context::{
ContextBudget, ContextSlot, DeriveStrategy, FocusedConfig, MergeStrategy, SlotConfig,
SlotMeta, SlotMode, SlotSource,
};
pub use error::AgentError;
pub use runtime::{AgentConfig, RuntimeBundle};
pub use session::AgentSession;
pub use session_memory::SessionMemory;
pub use summary::SummaryConfig;
pub use task::JsonPlanParser;
pub use task::{Plan, PlanParser, Step, StepStatus, TaskAgent};