feat(agent): 实现 ContextSlot fork/merge

- 新增 MergeStrategy 枚举(#[non_exhaustive],为 Phase 16 Summarize 预留)
- 新增 ContextSlot::fork() 从父 slot 派生独立子 slot(Full / Focused 策略)
- 新增 ContextSlot::merge() 将子 slot 消息合入父 slot(Append / Replace 策略)
- 防御性检查:禁止 self-merge、跨 session merge、合并到 Readonly slot
- 重构 AgentSession::derive_slot 复用 fork() 消除重复代码
- 新增 9 个内联测试覆盖 fork/merge happy path 与 error path
- agent.rs 追加 MergeStrategy re-export(agcore::agent::MergeStrategy 路径可用)
This commit is contained in:
徐涛
2026-07-08 22:52:38 +08:00
parent 993118f661
commit 802518b5fe
3 changed files with 232 additions and 35 deletions
+2 -2
View File
@@ -22,8 +22,8 @@ pub mod task;
pub use agent::Agent;
pub use builder::AgentBuilder;
pub use context::{
ContextBudget, ContextSlot, DeriveStrategy, FocusedConfig, SlotConfig, SlotMeta, SlotMode,
SlotSource,
ContextBudget, ContextSlot, DeriveStrategy, FocusedConfig, MergeStrategy, SlotConfig,
SlotMeta, SlotMode, SlotSource,
};
pub use error::AgentError;
pub use runtime::{AgentConfig, RuntimeBundle};