MCPcopy Index your code
hub / github.com/AI45Lab/Code / record_event

Method record_event

core/src/subagent_task_tracker.rs:159–277  ·  view source on GitHub ↗

Apply a single agent event to the tracker. Non-subagent events are ignored.

(&self, event: &AgentEvent)

Source from the content-addressed store, hash-verified

157
158 /// Apply a single agent event to the tracker. Non-subagent events are ignored.
159 pub async fn record_event(&self, event: &AgentEvent) {
160 match event {
161 AgentEvent::SubagentStart {
162 task_id,
163 session_id,
164 parent_session_id,
165 agent,
166 description,
167 } => {
168 let now = now_ms();
169 let mut tasks = self.tasks.write().await;
170 tasks
171 .entry(task_id.clone())
172 .and_modify(|task| {
173 // Late start (e.g. background path) — keep the first-seen
174 // started_ms but refresh fields we now know.
175 task.parent_session_id = parent_session_id.clone();
176 task.child_session_id = session_id.clone();
177 task.agent = agent.clone();
178 task.description = description.clone();
179 task.updated_ms = now;
180 })
181 .or_insert_with(|| SubagentTaskSnapshot {
182 task_id: task_id.clone(),
183 parent_session_id: parent_session_id.clone(),
184 child_session_id: session_id.clone(),
185 agent: agent.clone(),
186 description: description.clone(),
187 status: SubagentStatus::Running,
188 started_ms: now,
189 updated_ms: now,
190 finished_ms: None,
191 output: None,
192 success: None,
193 progress: Vec::new(),
194 });
195 }
196 AgentEvent::SubagentProgress {
197 task_id,
198 session_id,
199 status,
200 metadata,
201 } => {
202 let now = now_ms();
203 let mut tasks = self.tasks.write().await;
204 let entry = tasks
205 .entry(task_id.clone())
206 .or_insert_with(|| SubagentTaskSnapshot {
207 task_id: task_id.clone(),
208 parent_session_id: String::new(),
209 child_session_id: session_id.clone(),
210 agent: String::new(),
211 description: String::new(),
212 status: SubagentStatus::Running,
213 started_ms: now,
214 updated_ms: now,
215 finished_ms: None,
216 output: None,

Calls 4

writeMethod · 0.80
now_msFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected