Re-exports§
pub use super::policy::KEY_TOOL_NAMES as BUILTIN_EXEMPT_TOOLS;
Structs§
- Auto
Compact Params - auto_compact 的只读参数(messages 作为被操作对象单独传递)
- Compact
Config - Context compact 配置
- Compact
Result - auto_compact 执行结果
- Invoked
Skill - 记录一次技能调用的完整信息(用于 auto_compact 后恢复)
Functions§
- auto_
compact - Layer 2: auto_compact - 保存 transcript + LLM 摘要 + 替换消息
- build_
invoked_ skills_ attachment - 构建 auto_compact 后需恢复的技能附件内容 按最近调用时间排序,总预算 COMPACT_SKILL_TOKEN_BUDGET tokens, 每个技能截断到 COMPACT_SKILL_PER_SKILL_TOKEN_BUDGET tokens
- estimate_
tokens - 粗略估算 messages 的 token 数(~4 chars per token)
- extract_
recent_ user_ messages - 提取最近 N 条 user 消息原文(不限于未被回复的)。
从末尾向前扫描,取最后
count条 role=user 的消息,保留原始顺序。 用于 auto_compact 场景:压缩后必须保留用户最近的消息原文, 否则 LLM 只能看到摘要而丢失用户的精确措辞和当前任务意图。 - is_
exempt_ tool - 判断工具名是否应被豁免(KeyTool + 用户扩展清单)
- micro_
compact - Layer 1: micro_compact - 替换旧 tool result 为占位符,保留最近 keep_recent 个
- new_
invoked_ skills_ map - 创建空的 InvokedSkillsMap
- record_
skill_ invocation - 记录一次技能调用(由 LoadSkill 工具执行后调用)
Type Aliases§
- Invoked
Skills Map - 会话内已调用技能的共享状态(Agent 线程写入,auto_compact 读取)
使用 Arc<Mutex
> 以便跨线程共享