Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent: Add telemetry events for subagents (#50849)

Katie Geerf05d756913c6
diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs
index 77c7ab02eb9..a93c2d2062b 100644
--- a/crates/agent/src/agent.rs
+++ b/crates/agent/src/agent.rs
@@ -1629,6 +1629,16 @@ impl NativeThreadEnvironment {
agent.register_session(subagent_thread.clone(), cx)
})?;
+ let depth = current_depth + 1;
+
+ telemetry::event!(
+ "Subagent Started",
+ session = parent_thread_entity.read(cx).id().to_string(),
+ subagent_session = session_id.to_string(),
+ depth,
+ is_resumed = false,
+ );
+
self.prompt_subagent(session_id, subagent_thread, acp_thread)
}
@@ -1645,6 +1655,18 @@ impl NativeThreadEnvironment {
anyhow::Ok((session.thread.clone(), session.acp_thread.clone()))
})??;
+ let depth = subagent_thread.read(cx).depth();
+
+ if let Some(parent_thread_entity) = self.thread.upgrade() {
+ telemetry::event!(
+ "Subagent Started",
+ session = parent_thread_entity.read(cx).id().to_string(),
+ subagent_session = session_id.to_string(),
+ depth,
+ is_resumed = true,
+ );
+ }
+
self.prompt_subagent(session_id, subagent_thread, acp_thread)
}
diff --git a/crates/agent/src/tools/spawn_agent_tool.rs b/crates/agent/src/tools/spawn_agent_tool.rs
index 162de68b861..9c10b2fbf12 100644
--- a/crates/agent/src/tools/spawn_agent_tool.rs
+++ b/crates/agent/src/tools/spawn_agent_tool.rs
@@ -163,6 +163,17 @@ impl AgentTool for SpawnAgentTool {
let send_result = subagent.send(input.message, cx).await;
+ let status = if send_result.is_ok() {
+ "completed"
+ } else {
+ "error"
+ };
+ telemetry::event!(
+ "Subagent Completed",
+ subagent_session = session_info.session_id.to_string(),
+ status,
+ );
+
session_info.message_end_index =
cx.update(|cx| Some(subagent.num_entries(cx).saturating_sub(1)));
diff --git a/crates/agent_ui/src/connection_view/thread_view.rs b/crates/agent_ui/src/connection_view/thread_view.rs
index af8675f9466..abf5ba5b8f9 100644
--- a/crates/agent_ui/src/connection_view/thread_view.rs
+++ b/crates/agent_ui/src/connection_view/thread_view.rs
@@ -6756,6 +6756,9 @@ impl ThreadView {
this.expanded_tool_calls
.insert(tool_call_id.clone());
}
+ let expanded =
+ this.expanded_tool_calls.contains(&tool_call_id);
+ telemetry::event!("Subagent Toggled", expanded);
cx.notify();
}
}))
@@ -6774,6 +6777,7 @@ impl ThreadView {
|this, thread| {
this.on_click(cx.listener(
move |_this, _event, _window, cx| {
+ telemetry::event!("Subagent Stopped");
thread.update(cx, |thread, cx| {
thread.cancel(cx).detach();
});
@@ -6809,6 +6813,7 @@ impl ThreadView {
)
.tooltip(Tooltip::text("Make Subagent Full Screen"))
.on_click(cx.listener(move |this, _event, window, cx| {
+ telemetry::event!("Subagent Maximized");
this.server_view
.update(cx, |this, cx| {
this.navigate_to_session(session_id.clone(), window, cx);