Skip to content

Commit 5be70dd

Browse files
committed
feat(core): summarize ToolSearch calls in the chat
Claude Code loads our MCP tools on demand, so a bot calls ToolSearch before its first send_message. The tool line now reads "load send_message" instead of an empty summary.
1 parent af1a0fc commit 5be70dd

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎crates/botloft-core/src/chat.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ pub fn tool_summary(name: &str, input: &Value) -> String {
5959
"WebSearch" => field(input, "query").map(str::to_owned),
6060
"Task" | "Agent" => field(input, "description").map(str::to_owned),
6161
"TodoWrite" => Some("Updated the plan".to_owned()),
62+
// Claude Code loads deferred tools (such as ours) by name first.
63+
"ToolSearch" => field(input, "query").map(|query| match query.strip_prefix("select:") {
64+
Some(names) => {
65+
let labels: Vec<_> = names.split(',').map(|n| tool_label(n.trim())).collect();
66+
format!("load {}", labels.join(", "))
67+
}
68+
None => query.to_owned(),
69+
}),
6270
"mcp__botloft__send_message" => {
6371
field(input, "to").map(|to| format!("to @{}", to.trim_start_matches('@')))
6472
}
@@ -145,6 +153,17 @@ mod tests {
145153
),
146154
"to @writer"
147155
);
156+
assert_eq!(
157+
tool_summary(
158+
"ToolSearch",
159+
&json!({ "query": "select:mcp__botloft__send_message,Read", "max_results": 3 })
160+
),
161+
"load send_message, Read"
162+
);
163+
assert_eq!(
164+
tool_summary("ToolSearch", &json!({ "query": "notebook jupyter" })),
165+
"notebook jupyter"
166+
);
148167
assert_eq!(tool_summary("SomethingNew", &json!({ "a": 1 })), "");
149168
assert_eq!(tool_label("mcp__botloft__send_message"), "send_message");
150169
assert_eq!(tool_label("Bash"), "Bash");

0 commit comments

Comments
 (0)