Track history, notes, and async messages as control tools (#40496)

## What changed

- Emit control-tool analytics for history and notes extension calls and for
  `send_user_message_async`.
- Preserve non-default namespaces in reported tool names, such as
  `history.read_item` and `notes.write_file`.

## Testing

- Add an app-server integration test covering successful and failed calls,
  turn-level tool counts, and omission of tool argument values from analytics.

GitOrigin-RevId: b15a53a311228339f4d577a7b96146ed67f22253
This commit is contained in:
jif authored and copyberry committed 2026-08-24 23:19:03 +00:00
1 parent 5a51caf04d
commit be3a666143
4 files changed
+216 -4

No files matched your search

@@ -64,11 +64,26 @@ impl ToolExecutor<ToolInvocation> for ExtensionToolAdapter {
impl CoreToolRuntime for ExtensionToolAdapter {
fn is_builtin_control_tool(&self) -> bool {
let tool_name = self.0.tool_name();
tool_name.is_default_namespace()
&& matches!(
if tool_name.is_default_namespace() {
return matches!(
tool_name.name.as_str(),
"get_goal" | "create_goal" | "update_goal"
);
}
matches!(
(tool_name.namespace.as_deref(), tool_name.name.as_str()),
(
Some("notes"),
"list_files_by_prefix"
| "read_file"
| "search_contents"
| "append_to_file"
| "write_file"
) | (
Some("history"),
"list_windows" | "list_items" | "read_item" | "search_contents"
)
)
}
fn matches_kind(&self, payload: &ToolPayload) -> bool {
@@ -98,4 +98,8 @@ impl ToolExecutor<ToolInvocation> for SendUserMessageAsyncHandler {
}
}
impl CoreToolRuntime for SendUserMessageAsyncHandler {}
impl CoreToolRuntime for SendUserMessageAsyncHandler {
fn is_builtin_control_tool(&self) -> bool {
true
}
}