tinyharness_lib/tools/
auto_compact.rs1use std::collections::HashMap;
2
3use crate::tools::tool::{BoxFuture, ToolCategory, build_string_params_schema, make_tool};
4
5pub fn auto_compact_tool_entry() -> crate::tools::tool::Tool {
6 make_tool(
7 "auto_compact",
8 "Compact the conversation history by summarizing older messages. Use this when the conversation is getting long and you need to free up context space. The recent messages will be preserved, while older messages will be summarized into a concise summary.",
9 ToolCategory::Signal,
10 build_string_params_schema(
11 &[],
12 &[(
13 "focus",
14 "Specific topics, decisions, or details to preserve in the summary",
15 "",
16 )],
17 ),
18 |args| Box::pin(auto_compact_tool(args)),
19 )
20}
21
22pub fn auto_compact_tool(args: HashMap<String, String>) -> BoxFuture<'static, String> {
23 Box::pin(async move {
24 let focus = args.get("focus").cloned().unwrap_or_default();
25
26 if focus.is_empty() {
30 "AUTO_COMPACT_REQUESTED: The model has requested to compact the conversation history. No specific focus provided.".to_string()
31 } else {
32 format!(
33 "AUTO_COMPACT_REQUESTED: The model has requested to compact the conversation history with focus on: {}",
34 focus
35 )
36 }
37 })
38}